DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ ToggleDebugActionsMask()

static void SpawnItemOnLocation::ToggleDebugActionsMask ( int mask)
staticprivate

См. определение в файле ItemBase.c строка 5700

5705{
5706 override bool CanPutAsAttachment(EntityAI parent)
5707 {
5708 return true;
5709 }
5710};
5711
5713{
5714
5715};
5716
5717//const bool QUANTITY_DEBUG_REMOVE_ME = false;
5718
5719class ItemBase extends InventoryItem
5720{
5724
5726
5727 static int m_DebugActionsMask;
5729 // ============================================
5730 // Variable Manipulation System
5731 // ============================================
5732 // Quantity
5733
5734 float m_VarQuantity;
5735 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
5737 int m_VarQuantityMin;
5738 int m_VarQuantityMax;
5739 int m_Count;
5740 float m_VarStackMax;
5741 float m_StoreLoadedQuantity = float.LOWEST;
5742 // Wet
5743 float m_VarWet;
5744 float m_VarWetPrev;//for client to know wetness changed during synchronization
5745 float m_VarWetInit;
5746 float m_VarWetMin;
5747 float m_VarWetMax;
5748 // Cleanness
5749 int m_Cleanness;
5750 int m_CleannessInit;
5751 int m_CleannessMin;
5752 int m_CleannessMax;
5753 // impact sounds
5755 bool m_CanPlayImpactSound = true;
5756 float m_ImpactSpeed;
5758 //
5759 float m_HeatIsolation;
5760 float m_ItemModelLength;
5761 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
5763 int m_VarLiquidType;
5764 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
5765 int m_QuickBarBonus;
5766 bool m_IsBeingPlaced;
5767 bool m_IsHologram;
5768 bool m_IsTakeable;
5769 bool m_ThrowItemOnDrop;
5772 bool m_FixDamageSystemInit = false; //can be changed on storage version check
5773 bool can_this_be_combined; //Check if item can be combined
5774 bool m_CanThisBeSplit; //Check if item can be split
5775 bool m_IsStoreLoad = false;
5776 bool m_CanShowQuantity;
5777 bool m_HasQuantityBar;
5778 protected bool m_CanBeDigged;
5779 protected bool m_IsResultOfSplit
5780
5781 string m_SoundAttType;
5782 // items color variables
5787 //-------------------------------------------------------
5788
5789 // light source managing
5791
5795
5796 //==============================================
5797 // agent system
5798 private int m_AttachedAgents;
5799
5801 void TransferModifiers(PlayerBase reciever);
5802
5803
5804 // Weapons & suppressors particle effects
5808 ref static map<string, int> m_WeaponTypeToID;
5809 static int m_LastRegisteredWeaponID = 0;
5810
5811 // Overheating effects
5813 float m_OverheatingShots;
5814 ref Timer m_CheckOverheating;
5815 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
5816 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
5817 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
5818 ref array <ref OverheatingParticle> m_OverheatingParticles;
5819
5821 protected bool m_HideSelectionsBySlot;
5822
5823 // Admin Log
5824 PluginAdminLog m_AdminLog;
5825
5826 // misc
5827 ref Timer m_PhysDropTimer;
5828
5829 // Attachment Locking variables
5830 ref array<int> m_CompatibleLocks;
5831 protected int m_LockType;
5832 protected ref EffectSound m_LockingSound;
5833 protected string m_LockSoundSet;
5834
5835 // ItemSoundHandler variables
5836 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
5837 protected int m_SoundSyncPlay; // id for sound to play
5838 protected int m_SoundSyncStop; // id for sound to stop
5839 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
5840
5842
5843 //temperature
5844 private float m_TemperaturePerQuantityWeight;
5845
5846 // -------------------------------------------------------------------------
5847 void ItemBase()
5848 {
5849 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
5853
5854 if (!g_Game.IsDedicatedServer())
5855 {
5856 if (HasMuzzle())
5857 {
5859
5861 {
5863 }
5864 }
5865
5867 m_ActionsInitialize = false;
5868 }
5869
5870 m_OldLocation = null;
5871
5872 if (g_Game.IsServer())
5873 {
5874 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
5875 }
5876
5877 if (ConfigIsExisting("headSelectionsToHide"))
5878 {
5880 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
5881 }
5882
5883 m_HideSelectionsBySlot = false;
5884 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
5885 {
5886 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
5887 }
5888
5889 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
5890
5891 m_IsResultOfSplit = false;
5892
5894 }
5895
5896 override void InitItemVariables()
5897 {
5898 super.InitItemVariables();
5899
5900 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
5901 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
5902 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
5903 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
5904 m_VarStackMax = ConfigGetFloat("varStackMax");
5905 m_Count = ConfigGetInt("count");
5906
5907 m_CanShowQuantity = ConfigGetBool("quantityShow");
5908 m_HasQuantityBar = ConfigGetBool("quantityBar");
5909
5910 m_CleannessInit = ConfigGetInt("varCleannessInit");
5912 m_CleannessMin = ConfigGetInt("varCleannessMin");
5913 m_CleannessMax = ConfigGetInt("varCleannessMax");
5914
5915 m_WantPlayImpactSound = false;
5916 m_ImpactSpeed = 0.0;
5917
5918 m_VarWetInit = ConfigGetFloat("varWetInit");
5920 m_VarWetMin = ConfigGetFloat("varWetMin");
5921 m_VarWetMax = ConfigGetFloat("varWetMax");
5922
5923 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
5924 if (IsLiquidContainer() && GetQuantity() != 0)
5926 m_IsBeingPlaced = false;
5927 m_IsHologram = false;
5928 m_IsTakeable = true;
5929 m_CanBeMovedOverride = false;
5933 m_CanBeDigged = ConfigGetBool("canBeDigged");
5934
5935 m_CompatibleLocks = new array<int>();
5936 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
5937 m_LockType = ConfigGetInt("lockType");
5938
5939 //Define if item can be split and set ability to be combined accordingly
5940 m_CanThisBeSplit = false;
5941 can_this_be_combined = false;
5942 if (ConfigIsExisting("canBeSplit"))
5943 {
5944 can_this_be_combined = ConfigGetBool("canBeSplit");
5946 }
5947
5948 m_ItemBehaviour = -1;
5949 if (ConfigIsExisting("itemBehaviour"))
5950 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
5951
5952 //RegisterNetSyncVariableInt("m_VariablesMask");
5953 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
5954 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
5955 RegisterNetSyncVariableInt("m_VarLiquidType");
5956 RegisterNetSyncVariableInt("m_Cleanness",0,1);
5957
5958 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
5959 RegisterNetSyncVariableFloat("m_ImpactSpeed");
5960 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
5961
5962 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
5963 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
5964 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
5965 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
5966
5967 RegisterNetSyncVariableBool("m_IsBeingPlaced");
5968 RegisterNetSyncVariableBool("m_IsTakeable");
5969 RegisterNetSyncVariableBool("m_IsHologram");
5970
5973 {
5974 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
5975 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
5976 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
5977 }
5978
5979 m_LockSoundSet = ConfigGetString("lockSoundSet");
5980
5982 if (ConfigIsExisting("temperaturePerQuantityWeight"))
5983 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
5984
5985 m_SoundSyncSlotID = -1;
5986 }
5987
5988 override int GetQuickBarBonus()
5989 {
5990 return m_QuickBarBonus;
5991 }
5992
5993 void InitializeActions()
5994 {
5996 if (!m_InputActionMap)
5997 {
5999 m_InputActionMap = iam;
6000 SetActions();
6002 }
6003 }
6004
6005 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
6006 {
6008 {
6009 m_ActionsInitialize = true;
6011 }
6012
6013 actions = m_InputActionMap.Get(action_input_type);
6014 }
6015
6016 void SetActions()
6017 {
6018 AddAction(ActionTakeItem);
6019 AddAction(ActionTakeItemToHands);
6020 AddAction(ActionWorldCraft);
6022 AddAction(ActionAttachWithSwitch);
6023 }
6024
6025 void SetActionAnimOverrides(); // Override action animation for specific item
6026
6027 void AddAction(typename actionName)
6028 {
6029 ActionBase action = ActionManagerBase.GetAction(actionName);
6030
6031 if (!action)
6032 {
6033 Debug.LogError("Action " + actionName + " dosn't exist!");
6034 return;
6035 }
6036
6037 typename ai = action.GetInputType();
6038 if (!ai)
6039 {
6040 m_ActionsInitialize = false;
6041 return;
6042 }
6043
6044 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
6045 if (!action_array)
6046 {
6047 action_array = new array<ActionBase_Basic>;
6048 m_InputActionMap.Insert(ai, action_array);
6049 }
6050 if (LogManager.IsActionLogEnable())
6051 {
6052 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
6053 }
6054
6055 if (action_array.Find(action) != -1)
6056 {
6057 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
6058 }
6059 else
6060 {
6061 action_array.Insert(action);
6062 }
6063 }
6064
6065 void RemoveAction(typename actionName)
6066 {
6067 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
6068 ActionBase action = player.GetActionManager().GetAction(actionName);
6069 typename ai = action.GetInputType();
6070 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
6071
6072 if (action_array)
6073 {
6074 action_array.RemoveItem(action);
6075 }
6076 }
6077
6078 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
6079 // Set -1 for params which should stay in default state
6080 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
6081 {
6082 ActionOverrideData overrideData = new ActionOverrideData();
6083 overrideData.m_CommandUID = commandUID;
6084 overrideData.m_CommandUIDProne = commandUIDProne;
6085 overrideData.m_StanceMask = stanceMask;
6086
6087 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
6088 if (!actionMap) // create new map of action > overidables map
6089 {
6090 actionMap = new TActionAnimOverrideMap();
6091 m_ItemActionOverrides.Insert(action, actionMap);
6092 }
6093
6094 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
6095
6096 }
6097
6098 void OnItemInHandsPlayerSwimStart(PlayerBase player);
6099
6100 ScriptedLightBase GetLight();
6101
6102 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
6103 void LoadParticleConfigOnFire(int id)
6104 {
6105 if (!m_OnFireEffect)
6107
6110
6111 string config_to_search = "CfgVehicles";
6112 string muzzle_owner_config;
6113
6114 if (!m_OnFireEffect.Contains(id))
6115 {
6116 if (IsInherited(Weapon))
6117 config_to_search = "CfgWeapons";
6118
6119 muzzle_owner_config = config_to_search + " " + GetType() + " ";
6120
6121 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
6122
6123 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
6124
6125 if (config_OnFire_subclass_count > 0)
6126 {
6127 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
6128
6129 for (int i = 0; i < config_OnFire_subclass_count; i++)
6130 {
6131 string particle_class = "";
6132 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
6133 string config_OnFire_entry = config_OnFire_class + particle_class;
6134 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
6135 WPOF_array.Insert(WPOF);
6136 }
6137
6138
6139 m_OnFireEffect.Insert(id, WPOF_array);
6140 }
6141 }
6142
6143 if (!m_OnBulletCasingEjectEffect.Contains(id))
6144 {
6145 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
6146 muzzle_owner_config = config_to_search + " " + GetType() + " ";
6147
6148 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
6149
6150 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
6151
6152 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
6153 {
6154 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
6155
6156 for (i = 0; i < config_OnBulletCasingEject_count; i++)
6157 {
6158 string particle_class2 = "";
6159 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
6160 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
6161 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
6162 WPOBE_array.Insert(WPOBE);
6163 }
6164
6165
6166 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
6167 }
6168 }
6169 }
6170
6171 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
6173 {
6176
6177 if (!m_OnOverheatingEffect.Contains(id))
6178 {
6179 string config_to_search = "CfgVehicles";
6180
6181 if (IsInherited(Weapon))
6182 config_to_search = "CfgWeapons";
6183
6184 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
6185 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
6186
6187 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
6188 {
6189
6190 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
6191
6193 {
6194 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
6195 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
6196 Error(error);
6197 return;
6198 }
6199
6200 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
6201 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
6202
6203
6204
6205 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
6206 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
6207
6208 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
6209 {
6210 string particle_class = "";
6211 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
6212 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
6213 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
6214
6215 if (entry_type == CT_CLASS)
6216 {
6217 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
6218 WPOOH_array.Insert(WPOF);
6219 }
6220 }
6221
6222
6223 m_OnOverheatingEffect.Insert(id, WPOOH_array);
6224 }
6225 }
6226 }
6227
6228 float GetOverheatingValue()
6229 {
6230 return m_OverheatingShots;
6231 }
6232
6233 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
6234 {
6235 if (m_MaxOverheatingValue > 0)
6236 {
6238
6239 if (!m_CheckOverheating)
6241
6243 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
6244
6245 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6246 }
6247 }
6248
6249 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6250 {
6252 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6253
6255 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6256
6258 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6259
6261 {
6263 }
6264 }
6265
6267 {
6269 }
6270
6271 void OnOverheatingDecay()
6272 {
6273 if (m_MaxOverheatingValue > 0)
6274 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
6275 else
6277
6278 if (m_OverheatingShots <= 0)
6279 {
6282 }
6283 else
6284 {
6285 if (!m_CheckOverheating)
6287
6289 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
6290 }
6291
6292 CheckOverheating(this, "", this);
6293 }
6294
6295 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6296 {
6298 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
6299 }
6300
6301 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6302 {
6304 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
6306 }
6307
6308 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6309 {
6311 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6312 }
6313
6314 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
6315 {
6317 m_OverheatingParticles = new array<ref OverheatingParticle>;
6318
6319 OverheatingParticle OP = new OverheatingParticle();
6320 OP.RegisterParticle(p);
6321 OP.SetOverheatingLimitMin(min_heat_coef);
6322 OP.SetOverheatingLimitMax(max_heat_coef);
6323 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
6324
6325 m_OverheatingParticles.Insert(OP);
6326 }
6327
6328 float GetOverheatingCoef()
6329 {
6330 if (m_MaxOverheatingValue > 0)
6332
6333 return -1;
6334 }
6335
6337 {
6339 {
6340 float overheat_coef = GetOverheatingCoef();
6341 int count = m_OverheatingParticles.Count();
6342
6343 for (int i = count; i > 0; --i)
6344 {
6345 int id = i - 1;
6346 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6347 Particle p = OP.GetParticle();
6348
6349 float overheat_min = OP.GetOverheatingLimitMin();
6350 float overheat_max = OP.GetOverheatingLimitMax();
6351
6352 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
6353 {
6354 if (p)
6355 {
6356 p.Stop();
6357 OP.RegisterParticle(null);
6358 }
6359 }
6360 }
6361 }
6362 }
6363
6365 {
6367 {
6368 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
6369 {
6370 int id = i - 1;
6371 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6372
6373 if (OP)
6374 {
6375 Particle p = OP.GetParticle();
6376
6377 if (p)
6378 {
6379 p.Stop();
6380 }
6381
6382 delete OP;
6383 }
6384 }
6385
6386 m_OverheatingParticles.Clear();
6388 }
6389 }
6390
6392 float GetInfectionChance(int system = 0, Param param = null)
6393 {
6394 return 0.0;
6395 }
6396
6397
6398 float GetDisinfectQuantity(int system = 0, Param param1 = null)
6399 {
6400 return 250;//default value
6401 }
6402
6403 float GetFilterDamageRatio()
6404 {
6405 return 0;
6406 }
6407
6409 bool HasMuzzle()
6410 {
6411 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
6412 return true;
6413
6414 return false;
6415 }
6416
6418 int GetMuzzleID()
6419 {
6420 if (!m_WeaponTypeToID)
6421 m_WeaponTypeToID = new map<string, int>;
6422
6423 if (m_WeaponTypeToID.Contains(GetType()))
6424 {
6425 return m_WeaponTypeToID.Get(GetType());
6426 }
6427 else
6428 {
6429 // Register new weapon ID
6431 }
6432
6434 }
6435
6442 {
6443 return -1;
6444 }
6445
6446
6447
6448 // -------------------------------------------------------------------------
6449 void ~ItemBase()
6450 {
6451 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
6452 {
6453 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
6454 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
6455
6456 if (r_index >= 0)
6457 {
6458 InventoryLocation r_il = new InventoryLocation;
6459 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
6460
6461 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
6462 int r_type = r_il.GetType();
6463 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
6464 {
6465 r_il.GetParent().GetOnReleaseLock().Invoke(this);
6466 }
6467 else if (r_type == InventoryLocationType.ATTACHMENT)
6468 {
6469 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
6470 }
6471
6472 }
6473
6474 player.GetHumanInventory().ClearUserReservedLocation(this);
6475 }
6476
6477 if (m_LockingSound)
6478 SEffectManager.DestroyEffect(m_LockingSound);
6479 }
6480
6481
6482
6483 // -------------------------------------------------------------------------
6484 static int GetDebugActionsMask()
6485 {
6486 return ItemBase.m_DebugActionsMask;
6487 }
6488
6489 static bool HasDebugActionsMask(int mask)
6490 {
6491 return ItemBase.m_DebugActionsMask & mask;
6492 }
6493
6494 static void SetDebugActionsMask(int mask)
6495 {
6496 ItemBase.m_DebugActionsMask = mask;
6497 }
6498
6499 static void AddDebugActionsMask(int mask)
6500 {
6501 ItemBase.m_DebugActionsMask |= mask;
6502 }
6503
6504 static void RemoveDebugActionsMask(int mask)
6505 {
6506 ItemBase.m_DebugActionsMask &= ~mask;
6507 }
6508
6509 static void ToggleDebugActionsMask(int mask)
6510 {
6511 if (HasDebugActionsMask(mask))
6512 {
6514 }
6515 else
6516 {
6517 AddDebugActionsMask(mask);
6518 }
6519 }
6520
6521 // -------------------------------------------------------------------------
6522 void SetCEBasedQuantity()
6523 {
6524 if (GetEconomyProfile())
6525 {
6526 float q_max = GetEconomyProfile().GetQuantityMax();
6527 if (q_max > 0)
6528 {
6529 float q_min = GetEconomyProfile().GetQuantityMin();
6530 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
6531
6532 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
6533 {
6534 ComponentEnergyManager comp = GetCompEM();
6535 if (comp && (comp.GetEnergyMaxPristine() || comp.GetEnergyAtSpawn()))//checking for a potential for energy, we need to check both values, as both are optional, only when both are set to 0, we know the item can't have energy
6536 {
6537 comp.SetEnergy0To1(quantity_randomized);
6538 }
6539 }
6540 else if (HasQuantity())
6541 {
6542 SetQuantityNormalized(quantity_randomized, false);
6543 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
6544 }
6545
6546 }
6547 }
6548 }
6549
6551 void LockToParent()
6552 {
6553 EntityAI parent = GetHierarchyParent();
6554
6555 if (parent)
6556 {
6557 InventoryLocation inventory_location_to_lock = new InventoryLocation;
6558 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
6559 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
6560 }
6561 }
6562
6564 void UnlockFromParent()
6565 {
6566 EntityAI parent = GetHierarchyParent();
6567
6568 if (parent)
6569 {
6570 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
6571 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
6572 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
6573 }
6574 }
6575
6576 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
6577 {
6578 /*
6579 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
6580 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
6581 */
6582 ItemBase item2 = ItemBase.Cast(entity2);
6583
6584 if (g_Game.IsClient())
6585 {
6586 if (ScriptInputUserData.CanStoreInputUserData())
6587 {
6588 ScriptInputUserData ctx = new ScriptInputUserData;
6590 ctx.Write(-1);
6591 ItemBase i1 = this; // @NOTE: workaround for correct serialization
6592 ctx.Write(i1);
6593 ctx.Write(item2);
6594 ctx.Write(use_stack_max);
6595 ctx.Write(-1);
6596 ctx.Send();
6597
6598 if (IsCombineAll(item2, use_stack_max))
6599 {
6600 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
6601 }
6602 }
6603 }
6604 else if (!g_Game.IsMultiplayer())
6605 {
6606 CombineItems(item2, use_stack_max);
6607 }
6608 }
6609
6610 bool IsLiquidPresent()
6611 {
6612 return (GetLiquidType() != 0 && HasQuantity());
6613 }
6614
6615 bool IsLiquidContainer()
6616 {
6617 return m_LiquidContainerMask != 0;
6618 }
6619
6621 {
6622 return m_LiquidContainerMask;
6623 }
6624
6625 bool IsBloodContainer()
6626 {
6627 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
6628 return false;
6629 }
6630
6631 bool IsNVG()
6632 {
6633 return false;
6634 }
6635
6638 bool IsExplosive()
6639 {
6640 return false;
6641 }
6642
6644 {
6645 return "";
6646 }
6647
6649
6650 bool IsLightSource()
6651 {
6652 return false;
6653 }
6654
6656 {
6657 return true;
6658 }
6659
6660 //--- ACTION CONDITIONS
6661 //direction
6662 bool IsFacingPlayer(PlayerBase player, string selection)
6663 {
6664 return true;
6665 }
6666
6667 bool IsPlayerInside(PlayerBase player, string selection)
6668 {
6669 return true;
6670 }
6671
6672 override bool CanObstruct()
6673 {
6674 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
6675 return !player || !IsPlayerInside(player, "");
6676 }
6677
6678 override bool IsBeingPlaced()
6679 {
6680 return m_IsBeingPlaced;
6681 }
6682
6683 void SetIsBeingPlaced(bool is_being_placed)
6684 {
6685 m_IsBeingPlaced = is_being_placed;
6686 if (!is_being_placed)
6688 SetSynchDirty();
6689 }
6690
6691 //server-side
6692 void OnEndPlacement() {}
6693
6694 override bool IsHologram()
6695 {
6696 return m_IsHologram;
6697 }
6698
6699 bool CanBeDigged()
6700 {
6701 return m_CanBeDigged;
6702 }
6703
6705 {
6706 return 1;
6707 }
6708
6709 bool CanMakeGardenplot()
6710 {
6711 return false;
6712 }
6713
6714 void SetIsHologram(bool is_hologram)
6715 {
6716 m_IsHologram = is_hologram;
6717 SetSynchDirty();
6718 }
6719 /*
6720 protected float GetNutritionalEnergy()
6721 {
6722 Edible_Base edible = Edible_Base.Cast(this);
6723 return edible.GetFoodEnergy();
6724 }
6725
6726 protected float GetNutritionalWaterContent()
6727 {
6728 Edible_Base edible = Edible_Base.Cast(this);
6729 return edible.GetFoodWater();
6730 }
6731
6732 protected float GetNutritionalIndex()
6733 {
6734 Edible_Base edible = Edible_Base.Cast(this);
6735 return edible.GetFoodNutritionalIndex();
6736 }
6737
6738 protected float GetNutritionalFullnessIndex()
6739 {
6740 Edible_Base edible = Edible_Base.Cast(this);
6741 return edible.GetFoodTotalVolume();
6742 }
6743
6744 protected float GetNutritionalToxicity()
6745 {
6746 Edible_Base edible = Edible_Base.Cast(this);
6747 return edible.GetFoodToxicity();
6748
6749 }
6750 */
6751
6752
6753 // -------------------------------------------------------------------------
6754 override void OnMovedInsideCargo(EntityAI container)
6755 {
6756 super.OnMovedInsideCargo(container);
6757
6758 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
6759 }
6760
6761 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
6762 {
6763 super.EEItemLocationChanged(oldLoc, newLoc);
6764
6765 PlayerBase newPlayer = null;
6766 PlayerBase oldPlayer = null;
6767
6768 if (newLoc.GetParent())
6769 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
6770
6771 if (oldLoc.GetParent())
6772 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
6773
6774 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
6775 {
6776 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
6777
6778 if (rIndex >= 0)
6779 {
6780 InventoryLocation rIl = new InventoryLocation;
6781 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
6782
6783 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
6784 int rType = rIl.GetType();
6785 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
6786 {
6787 rIl.GetParent().GetOnReleaseLock().Invoke(this);
6788 }
6789 else if (rType == InventoryLocationType.ATTACHMENT)
6790 {
6791 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
6792 }
6793
6794 }
6795 }
6796
6797 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
6798 {
6799 if (newPlayer)
6800 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
6801
6802 if (newPlayer == oldPlayer)
6803 {
6804 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
6805 {
6806 if (oldLoc.GetType() == InventoryLocationType.CARGO)
6807 {
6808 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
6809 {
6810 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
6811 }
6812 }
6813 else
6814 {
6815 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
6816 }
6817 }
6818
6819 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
6820 {
6821 int type = oldLoc.GetType();
6822 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
6823 {
6824 oldLoc.GetParent().GetOnSetLock().Invoke(this);
6825 }
6826 else if (type == InventoryLocationType.ATTACHMENT)
6827 {
6828 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
6829 }
6830 }
6831 if (!m_OldLocation)
6832 {
6833 m_OldLocation = new InventoryLocation;
6834 }
6835 m_OldLocation.Copy(oldLoc);
6836 }
6837 else
6838 {
6839 if (m_OldLocation)
6840 {
6841 m_OldLocation.Reset();
6842 }
6843 }
6844
6845 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
6846 }
6847 else
6848 {
6849 if (newPlayer)
6850 {
6851 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
6852 if (resIndex >= 0)
6853 {
6854 InventoryLocation il = new InventoryLocation;
6855 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
6856 ItemBase it = ItemBase.Cast(il.GetItem());
6857 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
6858 int rel_type = il.GetType();
6859 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
6860 {
6861 il.GetParent().GetOnReleaseLock().Invoke(it);
6862 }
6863 else if (rel_type == InventoryLocationType.ATTACHMENT)
6864 {
6865 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
6866 }
6867 //it.GetOnReleaseLock().Invoke(it);
6868 }
6869 }
6870 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
6871 {
6872 //ThrowPhysically(oldPlayer, vector.Zero);
6873 m_ThrowItemOnDrop = false;
6874 }
6875
6876 if (m_OldLocation)
6877 {
6878 m_OldLocation.Reset();
6879 }
6880 }
6881
6882 if (oldLoc.GetType() == InventoryLocationType.TEMP)
6883 {
6884 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
6885 }
6886
6887 if (newLoc.GetType() == InventoryLocationType.TEMP)
6888 {
6889 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
6890 }
6891 }
6892
6893 override void EOnContact(IEntity other, Contact extra)
6894 {
6896 {
6897 int liquidType = -1;
6898 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
6899 if (impactSpeed > 0.0)
6900 {
6901 m_ImpactSpeed = impactSpeed;
6902 #ifndef SERVER
6903 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
6904 #else
6905 m_WantPlayImpactSound = true;
6906 SetSynchDirty();
6907 #endif
6908 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
6909 }
6910 }
6911
6912 #ifdef SERVER
6913 if (GetCompEM() && GetCompEM().IsPlugged())
6914 {
6915 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
6916 GetCompEM().UnplugThis();
6917 }
6918 #endif
6919 }
6920
6921 void RefreshPhysics();
6922
6923 override void OnCreatePhysics()
6924 {
6926 }
6927
6928 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
6929 {
6930
6931 }
6932 // -------------------------------------------------------------------------
6933 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
6934 {
6935 super.OnItemLocationChanged(old_owner, new_owner);
6936
6937 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
6938 PlayerBase playerNew = PlayerBase.Cast(new_owner);
6939
6940 if (!relatedPlayer && playerNew)
6941 relatedPlayer = playerNew;
6942
6943 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
6944 {
6945 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
6946 if (actionMgr)
6947 {
6948 ActionBase currentAction = actionMgr.GetRunningAction();
6949 if (currentAction)
6950 currentAction.OnItemLocationChanged(this);
6951 }
6952 }
6953
6954 Man ownerPlayerOld = null;
6955 Man ownerPlayerNew = null;
6956
6957 if (old_owner)
6958 {
6959 if (old_owner.IsMan())
6960 {
6961 ownerPlayerOld = Man.Cast(old_owner);
6962 }
6963 else
6964 {
6965 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
6966 }
6967 }
6968 else
6969 {
6970 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
6971 {
6972 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
6973
6974 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
6975 {
6976 GetCompEM().UnplugThis();
6977 }
6978 }
6979 }
6980
6981 if (new_owner)
6982 {
6983 if (new_owner.IsMan())
6984 {
6985 ownerPlayerNew = Man.Cast(new_owner);
6986 }
6987 else
6988 {
6989 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
6990 }
6991 }
6992
6993 if (ownerPlayerOld != ownerPlayerNew)
6994 {
6995 if (ownerPlayerOld)
6996 {
6997 array<EntityAI> subItemsExit = new array<EntityAI>;
6998 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
6999 for (int i = 0; i < subItemsExit.Count(); i++)
7000 {
7001 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
7002 itemExit.OnInventoryExit(ownerPlayerOld);
7003 }
7004 }
7005
7006 if (ownerPlayerNew)
7007 {
7008 array<EntityAI> subItemsEnter = new array<EntityAI>;
7009 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
7010 for (int j = 0; j < subItemsEnter.Count(); j++)
7011 {
7012 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
7013 itemEnter.OnInventoryEnter(ownerPlayerNew);
7014 }
7015 }
7016 }
7017 else if (ownerPlayerNew != null)
7018 {
7019 PlayerBase nplayer;
7020 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
7021 {
7022 array<EntityAI> subItemsUpdate = new array<EntityAI>;
7023 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
7024 for (int k = 0; k < subItemsUpdate.Count(); k++)
7025 {
7026 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
7027 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
7028 }
7029 }
7030 }
7031
7032 if (old_owner)
7033 old_owner.OnChildItemRemoved(this);
7034 if (new_owner)
7035 new_owner.OnChildItemReceived(this);
7036 }
7037
7038 // -------------------------------------------------------------------------------
7039 override void EEDelete(EntityAI parent)
7040 {
7041 super.EEDelete(parent);
7042 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
7043 if (player)
7044 {
7045 OnInventoryExit(player);
7046
7047 if (player.IsAlive())
7048 {
7049 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
7050 if (r_index >= 0)
7051 {
7052 InventoryLocation r_il = new InventoryLocation;
7053 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
7054
7055 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
7056 int r_type = r_il.GetType();
7057 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
7058 {
7059 r_il.GetParent().GetOnReleaseLock().Invoke(this);
7060 }
7061 else if (r_type == InventoryLocationType.ATTACHMENT)
7062 {
7063 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
7064 }
7065
7066 }
7067
7068 player.RemoveQuickBarEntityShortcut(this);
7069 }
7070 }
7071 }
7072 // -------------------------------------------------------------------------------
7073 override void EEKilled(Object killer)
7074 {
7075 super.EEKilled(killer);
7076
7078 if (killer && killer.IsFireplace() && CanExplodeInFire())
7079 {
7080 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
7081 {
7082 if (IsMagazine())
7083 {
7084 if (Magazine.Cast(this).GetAmmoCount() > 0)
7085 {
7086 ExplodeAmmo();
7087 }
7088 }
7089 else
7090 {
7091 Explode(DamageType.EXPLOSION);
7092 }
7093 }
7094 }
7095 }
7096
7097 override void OnWasAttached(EntityAI parent, int slot_id)
7098 {
7099 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
7100
7101 super.OnWasAttached(parent, slot_id);
7102
7103 if (HasQuantity())
7104 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7105
7106 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
7107 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
7108 }
7109
7110 override void OnWasDetached(EntityAI parent, int slot_id)
7111 {
7112 super.OnWasDetached(parent, slot_id);
7113
7114 if (HasQuantity())
7115 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7116
7117 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
7118 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
7119 }
7120
7121 override string ChangeIntoOnAttach(string slot)
7122 {
7123 int idx;
7124 TStringArray inventory_slots = new TStringArray;
7125 TStringArray attach_types = new TStringArray;
7126
7127 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
7128 if (inventory_slots.Count() < 1) //is string
7129 {
7130 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
7131 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
7132 }
7133 else //is array
7134 {
7135 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
7136 }
7137
7138 idx = inventory_slots.Find(slot);
7139 if (idx < 0)
7140 return "";
7141
7142 return attach_types.Get(idx);
7143 }
7144
7145 override string ChangeIntoOnDetach()
7146 {
7147 int idx = -1;
7148 string slot;
7149
7150 TStringArray inventory_slots = new TStringArray;
7151 TStringArray detach_types = new TStringArray;
7152
7153 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
7154 if (inventory_slots.Count() < 1) //is string
7155 {
7156 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
7157 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
7158 }
7159 else //is array
7160 {
7161 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
7162 if (detach_types.Count() < 1)
7163 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
7164 }
7165
7166 for (int i = 0; i < inventory_slots.Count(); i++)
7167 {
7168 slot = inventory_slots.Get(i);
7169 }
7170
7171 if (slot != "")
7172 {
7173 if (detach_types.Count() == 1)
7174 idx = 0;
7175 else
7176 idx = inventory_slots.Find(slot);
7177 }
7178 if (idx < 0)
7179 return "";
7180
7181 return detach_types.Get(idx);
7182 }
7183
7184 void ExplodeAmmo()
7185 {
7186 //timer
7187 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
7188
7189 //min/max time
7190 float min_time = 1;
7191 float max_time = 3;
7192 float delay = Math.RandomFloat(min_time, max_time);
7193
7194 explode_timer.Run(delay, this, "DoAmmoExplosion");
7195 }
7196
7197 void DoAmmoExplosion()
7198 {
7199 Magazine magazine = Magazine.Cast(this);
7200 int pop_sounds_count = 6;
7201 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
7202
7203 //play sound
7204 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
7205 string sound_name = pop_sounds[ sound_idx ];
7206 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
7207
7208 //remove ammo count
7209 magazine.ServerAddAmmoCount(-1);
7210
7211 //if condition then repeat -> ExplodeAmmo
7212 float min_temp_to_explode = 100; //min temperature for item to explode
7213
7214 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
7215 {
7216 ExplodeAmmo();
7217 }
7218 }
7219
7220 // -------------------------------------------------------------------------------
7221 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
7222 {
7223 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
7224
7225 const int CHANCE_DAMAGE_CARGO = 4;
7226 const int CHANCE_DAMAGE_ATTACHMENT = 1;
7227 const int CHANCE_DAMAGE_NOTHING = 2;
7228
7229 if (IsClothing() || IsContainer() || IsItemTent())
7230 {
7231 float dmg = damageResult.GetDamage("","Health") * -0.5;
7232 int chances;
7233 int rnd;
7234
7235 if (GetInventory().GetCargo())
7236 {
7237 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
7238 rnd = Math.RandomInt(0,chances);
7239
7240 if (rnd < CHANCE_DAMAGE_CARGO)
7241 {
7242 DamageItemInCargo(dmg);
7243 }
7244 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
7245 {
7247 }
7248 }
7249 else
7250 {
7251 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
7252 rnd = Math.RandomInt(0,chances);
7253
7254 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
7255 {
7257 }
7258 }
7259 }
7260 }
7261
7262 bool DamageItemInCargo(float damage)
7263 {
7264 CargoBase cargo = GetInventory().GetCargo();
7265 if (cargo)
7266 {
7267 int item_count = cargo.GetItemCount();
7268 if (item_count > 0)
7269 {
7270 int random_pick = Math.RandomInt(0, item_count);
7271 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
7272 if (!item.IsExplosive())
7273 {
7274 item.AddHealth("","",damage);
7275 return true;
7276 }
7277 }
7278 }
7279 return false;
7280 }
7281
7282 bool DamageItemAttachments(float damage)
7283 {
7284 GameInventory inventory = GetInventory();
7285 int attachment_count = inventory.AttachmentCount();
7286 if (attachment_count > 0)
7287 {
7288 int random_pick = Math.RandomInt(0, attachment_count);
7289 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
7290 if (!attachment.IsExplosive())
7291 {
7292 attachment.AddHealth("","",damage);
7293 return true;
7294 }
7295 }
7296 return false;
7297 }
7298
7299 override bool IsSplitable()
7300 {
7301 return m_CanThisBeSplit;
7302 }
7303 //----------------
7304 override bool CanBeSplit()
7305 {
7306 if (IsSplitable() && (GetQuantity() > 1))
7307 return GetInventory().CanRemoveEntity();
7308
7309 return false;
7310 }
7311
7312 protected bool ShouldSplitQuantity(float quantity)
7313 {
7314 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
7315 if (!IsSplitable())
7316 return false;
7317
7318 // nothing to split?
7319 if (GetQuantity() <= 1)
7320 return false;
7321
7322 // check if we should re-use the item instead of creating a new copy?
7323 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
7324 int delta = GetQuantity() - quantity;
7325 if (delta == 0)
7326 return false;
7327
7328 // valid to split
7329 return true;
7330 }
7331
7332 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
7333 {
7334 if (g_Game.IsClient())
7335 {
7336 if (ScriptInputUserData.CanStoreInputUserData())
7337 {
7338 ScriptInputUserData ctx = new ScriptInputUserData;
7340 ctx.Write(1);
7341 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7342 ctx.Write(i1);
7343 ctx.Write(destination_entity);
7344 ctx.Write(true);
7345 ctx.Write(slot_id);
7346 ctx.Send();
7347 }
7348 }
7349 else if (!g_Game.IsMultiplayer())
7350 {
7351 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
7352 }
7353 }
7354
7355 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
7356 {
7357 float split_quantity_new;
7358 ItemBase new_item;
7359 float quantity = GetQuantity();
7360 float stack_max = GetTargetQuantityMax(slot_id);
7361 InventoryLocation loc = new InventoryLocation;
7362
7363 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7364 {
7365 if (stack_max <= GetQuantity())
7366 split_quantity_new = stack_max;
7367 else
7368 split_quantity_new = GetQuantity();
7369
7370 if (ShouldSplitQuantity(split_quantity_new))
7371 {
7372 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7373 if (new_item)
7374 {
7375 new_item.SetResultOfSplit(true);
7376 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7377 AddQuantity(-split_quantity_new, false, true);
7378 new_item.SetQuantity(split_quantity_new, false, true);
7379 }
7380 }
7381 }
7382 else if (destination_entity && slot_id == -1)
7383 {
7384 if (quantity > stack_max)
7385 split_quantity_new = stack_max;
7386 else
7387 split_quantity_new = quantity;
7388
7389 if (ShouldSplitQuantity(split_quantity_new))
7390 {
7391 GameInventory destinationInventory = destination_entity.GetInventory();
7392 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
7393 {
7394 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
7395 new_item = ItemBase.Cast(o);
7396 }
7397
7398 if (new_item)
7399 {
7400 new_item.SetResultOfSplit(true);
7401 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7402 AddQuantity(-split_quantity_new, false, true);
7403 new_item.SetQuantity(split_quantity_new, false, true);
7404 }
7405 }
7406 }
7407 else
7408 {
7409 if (stack_max != 0)
7410 {
7411 if (stack_max < GetQuantity())
7412 {
7413 split_quantity_new = GetQuantity() - stack_max;
7414 }
7415
7416 if (split_quantity_new == 0)
7417 {
7418 if (!g_Game.IsMultiplayer())
7419 player.PhysicalPredictiveDropItem(this);
7420 else
7421 player.ServerDropEntity(this);
7422 return;
7423 }
7424
7425 if (ShouldSplitQuantity(split_quantity_new))
7426 {
7427 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
7428
7429 if (new_item)
7430 {
7431 new_item.SetResultOfSplit(true);
7432 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7433 SetQuantity(split_quantity_new, false, true);
7434 new_item.SetQuantity(stack_max, false, true);
7435 new_item.PlaceOnSurface();
7436 }
7437 }
7438 }
7439 }
7440 }
7441
7442 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
7443 {
7444 float split_quantity_new;
7445 ItemBase new_item;
7446 float quantity = GetQuantity();
7447 float stack_max = GetTargetQuantityMax(slot_id);
7448 InventoryLocation loc = new InventoryLocation;
7449
7450 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7451 {
7452 if (stack_max <= GetQuantity())
7453 split_quantity_new = stack_max;
7454 else
7455 split_quantity_new = GetQuantity();
7456
7457 if (ShouldSplitQuantity(split_quantity_new))
7458 {
7459 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7460 if (new_item)
7461 {
7462 new_item.SetResultOfSplit(true);
7463 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7464 AddQuantity(-split_quantity_new, false, true);
7465 new_item.SetQuantity(split_quantity_new, false, true);
7466 }
7467 }
7468 }
7469 else if (destination_entity && slot_id == -1)
7470 {
7471 if (quantity > stack_max)
7472 split_quantity_new = stack_max;
7473 else
7474 split_quantity_new = quantity;
7475
7476 if (ShouldSplitQuantity(split_quantity_new))
7477 {
7478 GameInventory destinationInventory = destination_entity.GetInventory();
7479 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
7480 {
7481 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
7482 new_item = ItemBase.Cast(o);
7483 }
7484
7485 if (new_item)
7486 {
7487 new_item.SetResultOfSplit(true);
7488 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7489 AddQuantity(-split_quantity_new, false, true);
7490 new_item.SetQuantity(split_quantity_new, false, true);
7491 }
7492 }
7493 }
7494 else
7495 {
7496 if (stack_max != 0)
7497 {
7498 if (stack_max < GetQuantity())
7499 {
7500 split_quantity_new = GetQuantity() - stack_max;
7501 }
7502
7503 if (ShouldSplitQuantity(split_quantity_new))
7504 {
7505 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
7506
7507 if (new_item)
7508 {
7509 new_item.SetResultOfSplit(true);
7510 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7511 SetQuantity(split_quantity_new, false, true);
7512 new_item.SetQuantity(stack_max, false, true);
7513 new_item.PlaceOnSurface();
7514 }
7515 }
7516 }
7517 }
7518 }
7519
7520 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
7521 {
7522 if (g_Game.IsClient())
7523 {
7524 if (ScriptInputUserData.CanStoreInputUserData())
7525 {
7526 ScriptInputUserData ctx = new ScriptInputUserData;
7528 ctx.Write(4);
7529 ItemBase thiz = this; // @NOTE: workaround for correct serialization
7530 ctx.Write(thiz);
7531 dst.WriteToContext(ctx);
7532 ctx.Send();
7533 }
7534 }
7535 else if (!g_Game.IsMultiplayer())
7536 {
7538 }
7539 }
7540
7541 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
7542 {
7543 if (g_Game.IsClient())
7544 {
7545 if (ScriptInputUserData.CanStoreInputUserData())
7546 {
7547 ScriptInputUserData ctx = new ScriptInputUserData;
7549 ctx.Write(2);
7550 ItemBase dummy = this; // @NOTE: workaround for correct serialization
7551 ctx.Write(dummy);
7552 ctx.Write(destination_entity);
7553 ctx.Write(true);
7554 ctx.Write(idx);
7555 ctx.Write(row);
7556 ctx.Write(col);
7557 ctx.Send();
7558 }
7559 }
7560 else if (!g_Game.IsMultiplayer())
7561 {
7562 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
7563 }
7564 }
7565
7566 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
7567 {
7569 }
7570
7571 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
7572 {
7573 float quantity = GetQuantity();
7574 float split_quantity_new;
7575 ItemBase new_item;
7576 if (dst.IsValid())
7577 {
7578 int slot_id = dst.GetSlot();
7579 float stack_max = GetTargetQuantityMax(slot_id);
7580
7581 if (quantity > stack_max)
7582 split_quantity_new = stack_max;
7583 else
7584 split_quantity_new = quantity;
7585
7586 if (ShouldSplitQuantity(split_quantity_new))
7587 {
7588 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
7589
7590 if (new_item)
7591 {
7592 new_item.SetResultOfSplit(true);
7593 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7594 AddQuantity(-split_quantity_new, false, true);
7595 new_item.SetQuantity(split_quantity_new, false, true);
7596 }
7597
7598 return new_item;
7599 }
7600 }
7601
7602 return null;
7603 }
7604
7605 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
7606 {
7607 float quantity = GetQuantity();
7608 float split_quantity_new;
7609 ItemBase new_item;
7610 if (destination_entity)
7611 {
7612 float stackable = GetTargetQuantityMax();
7613 if (quantity > stackable)
7614 split_quantity_new = stackable;
7615 else
7616 split_quantity_new = quantity;
7617
7618 if (ShouldSplitQuantity(split_quantity_new))
7619 {
7620 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
7621 if (new_item)
7622 {
7623 new_item.SetResultOfSplit(true);
7624 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7625 AddQuantity(-split_quantity_new, false, true);
7626 new_item.SetQuantity(split_quantity_new, false, true);
7627 }
7628 }
7629 }
7630 }
7631
7632 void SplitIntoStackMaxHandsClient(PlayerBase player)
7633 {
7634 if (g_Game.IsClient())
7635 {
7636 if (ScriptInputUserData.CanStoreInputUserData())
7637 {
7638 ScriptInputUserData ctx = new ScriptInputUserData;
7640 ctx.Write(3);
7641 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7642 ctx.Write(i1);
7643 ItemBase destination_entity = this;
7644 ctx.Write(destination_entity);
7645 ctx.Write(true);
7646 ctx.Write(0);
7647 ctx.Send();
7648 }
7649 }
7650 else if (!g_Game.IsMultiplayer())
7651 {
7652 SplitIntoStackMaxHands(player);
7653 }
7654 }
7655
7656 void SplitIntoStackMaxHands(PlayerBase player)
7657 {
7658 float quantity = GetQuantity();
7659 float split_quantity_new;
7660 ref ItemBase new_item;
7661 if (player)
7662 {
7663 float stackable = GetTargetQuantityMax();
7664 if (quantity > stackable)
7665 split_quantity_new = stackable;
7666 else
7667 split_quantity_new = quantity;
7668
7669 if (ShouldSplitQuantity(split_quantity_new))
7670 {
7671 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
7672 new_item = ItemBase.Cast(in_hands);
7673 if (new_item)
7674 {
7675 new_item.SetResultOfSplit(true);
7676 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7677 AddQuantity(-split_quantity_new, false, true);
7678 new_item.SetQuantity(split_quantity_new, false, true);
7679 }
7680 }
7681 }
7682 }
7683
7684 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
7685 {
7686 float quantity = GetQuantity();
7687 float split_quantity_new = Math.Floor(quantity * 0.5);
7688
7689 if (!ShouldSplitQuantity(split_quantity_new))
7690 return;
7691
7692 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
7693
7694 if (new_item)
7695 {
7696 if (new_item.GetQuantityMax() < split_quantity_new)
7697 {
7698 split_quantity_new = new_item.GetQuantityMax();
7699 }
7700
7701 new_item.SetResultOfSplit(true);
7702 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7703
7704 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
7705 {
7706 AddQuantity(-1, false, true);
7707 new_item.SetQuantity(1, false, true);
7708 }
7709 else
7710 {
7711 AddQuantity(-split_quantity_new, false, true);
7712 new_item.SetQuantity(split_quantity_new, false, true);
7713 }
7714 }
7715 }
7716
7717 void SplitItem(PlayerBase player)
7718 {
7719 float quantity = GetQuantity();
7720 float split_quantity_new = Math.Floor(quantity / 2);
7721
7722 if (!ShouldSplitQuantity(split_quantity_new))
7723 return;
7724
7725 InventoryLocation invloc = new InventoryLocation;
7726 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
7727
7728 ItemBase new_item;
7729 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
7730
7731 if (new_item)
7732 {
7733 if (new_item.GetQuantityMax() < split_quantity_new)
7734 {
7735 split_quantity_new = new_item.GetQuantityMax();
7736 }
7737 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
7738 {
7739 AddQuantity(-1, false, true);
7740 new_item.SetQuantity(1, false, true);
7741 }
7742 else if (split_quantity_new > 1)
7743 {
7744 AddQuantity(-split_quantity_new, false, true);
7745 new_item.SetQuantity(split_quantity_new, false, true);
7746 }
7747 }
7748 }
7749
7751 void OnQuantityChanged(float delta)
7752 {
7753 SetWeightDirty();
7754 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
7755
7756 if (parent)
7757 parent.OnAttachmentQuantityChangedEx(this, delta);
7758
7759 if (IsLiquidContainer())
7760 {
7761 if (GetQuantityNormalized() <= 0.0)
7762 {
7764 }
7765 else if (GetLiquidType() == LIQUID_NONE)
7766 {
7767 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
7769 }
7770 }
7771 }
7772
7775 {
7776 // insert code here
7777 }
7778
7780 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
7781 {
7783 }
7784
7785 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
7786 {
7787 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
7788
7789 if (g_Game.IsServer())
7790 {
7791 if (newLevel == GameConstants.STATE_RUINED)
7792 {
7794 EntityAI parent = GetHierarchyParent();
7795 if (parent && parent.IsFireplace())
7796 {
7797 CargoBase cargo = GetInventory().GetCargo();
7798 if (cargo)
7799 {
7800 for (int i = 0; i < cargo.GetItemCount(); ++i)
7801 {
7802 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
7803 }
7804 }
7805 }
7806 }
7807
7808 if (IsResultOfSplit())
7809 {
7810 // reset the splitting result flag, return to normal item behavior
7811 SetResultOfSplit(false);
7812 return;
7813 }
7814
7815 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
7816 {
7817 SetCleanness(0);//unclean the item upon damage dealt
7818 }
7819 }
7820 }
7821
7822 // just the split? TODO: verify
7823 override void OnRightClick()
7824 {
7825 super.OnRightClick();
7826
7827 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
7828 {
7829 if (g_Game.IsClient())
7830 {
7831 if (ScriptInputUserData.CanStoreInputUserData())
7832 {
7833 EntityAI root = GetHierarchyRoot();
7834 Man playerOwner = GetHierarchyRootPlayer();
7835 InventoryLocation dst = new InventoryLocation;
7836
7837 // If we have no hierarchy root player and the root is the same as this item the source item is in the vicinity so we want to create the new split item there also
7838 if (!playerOwner && root && root == this)
7839 {
7841 }
7842 else
7843 {
7844 // Check if we can place the new split item in the same parent where the source item is placed in or otherwise drop it in vicinity
7845 GetInventory().GetCurrentInventoryLocation(dst);
7846 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
7847 {
7848 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
7849 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
7850 {
7852 }
7853 else
7854 {
7855 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
7856 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
7857 this shouldnt cause issues within this scope*/
7858 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
7859 {
7861 }
7862 else
7863 {
7864 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
7865 }
7866 }
7867 }
7868 }
7869
7870 ScriptInputUserData ctx = new ScriptInputUserData;
7872 ctx.Write(4);
7873 ItemBase thiz = this; // @NOTE: workaround for correct serialization
7874 ctx.Write(thiz);
7875 dst.WriteToContext(ctx);
7876 ctx.Write(true); // dummy
7877 ctx.Send();
7878 }
7879 }
7880 else if (!g_Game.IsMultiplayer())
7881 {
7882 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
7883 }
7884 }
7885 }
7886
7887 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
7888 {
7889 if (root)
7890 {
7891 vector m4[4];
7892 root.GetTransform(m4);
7893 dst.SetGround(this, m4);
7894 }
7895 else
7896 {
7897 GetInventory().GetCurrentInventoryLocation(dst);
7898 }
7899 }
7900
7901 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
7902 {
7903 //TODO: delete check zero quantity check after fix double posts hands fsm events
7904 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
7905 return false;
7906
7907 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
7908 return false;
7909
7910 //can_this_be_combined = ConfigGetBool("canBeSplit");
7912 return false;
7913
7914
7915 Magazine mag = Magazine.Cast(this);
7916 if (mag)
7917 {
7918 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
7919 return false;
7920
7921 if (stack_max_limit)
7922 {
7923 Magazine other_mag = Magazine.Cast(other_item);
7924 if (other_item)
7925 {
7926 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
7927 return false;
7928 }
7929
7930 }
7931 }
7932 else
7933 {
7934 //TODO: delete check zero quantity check after fix double posts hands fsm events
7935 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
7936 return false;
7937
7938 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
7939 return false;
7940 }
7941
7942 PlayerBase player = null;
7943 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
7944 {
7945 if (player.GetInventory().HasAttachment(this))
7946 return false;
7947
7948 if (player.IsItemsToDelete())
7949 return false;
7950 }
7951
7952 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
7953 return false;
7954
7955 int slotID;
7956 string slotName;
7957 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
7958 return false;
7959
7960 return true;
7961 }
7962
7963 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
7964 {
7965 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
7966 }
7967
7968 bool IsResultOfSplit()
7969 {
7970 return m_IsResultOfSplit;
7971 }
7972
7973 void SetResultOfSplit(bool value)
7974 {
7975 m_IsResultOfSplit = value;
7976 }
7977
7978 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
7979 {
7980 return ComputeQuantityUsedEx(other_item, use_stack_max);
7981 }
7982
7983 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
7984 {
7985 float other_item_quantity = other_item.GetQuantity();
7986 float this_free_space;
7987
7988 float stack_max = GetQuantityMax();
7989
7990 this_free_space = stack_max - GetQuantity();
7991
7992 if (other_item_quantity > this_free_space)
7993 {
7994 return this_free_space;
7995 }
7996 else
7997 {
7998 return other_item_quantity;
7999 }
8000 }
8001
8002 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
8003 {
8004 CombineItems(ItemBase.Cast(entity2),use_stack_max);
8005 }
8006
8007 void CombineItems(ItemBase other_item, bool use_stack_max = true)
8008 {
8009 if (!CanBeCombined(other_item, false))
8010 return;
8011
8012 if (!IsMagazine() && other_item)
8013 {
8014 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
8015 if (quantity_used != 0)
8016 {
8017 float hp1 = GetHealth01("","");
8018 float hp2 = other_item.GetHealth01("","");
8019 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
8020 hpResult = hpResult / (GetQuantity() + quantity_used);
8021
8022 hpResult *= GetMaxHealth();
8023 Math.Round(hpResult);
8024 SetHealth("", "Health", hpResult);
8025
8026 AddQuantity(quantity_used);
8027 other_item.AddQuantity(-quantity_used);
8028 }
8029 }
8030 OnCombine(other_item);
8031 }
8032
8033 void OnCombine(ItemBase other_item)
8034 {
8035 #ifdef SERVER
8036 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
8037 GetHierarchyParent().IncreaseLifetimeUp();
8038 #endif
8039 };
8040
8041 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
8042 {
8043 PlayerBase p = PlayerBase.Cast(player);
8044
8045 array<int> recipesIds = p.m_Recipes;
8046 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
8047 if (moduleRecipesManager)
8048 {
8049 EntityAI itemInHands = player.GetEntityInHands();
8050 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
8051 }
8052
8053 for (int i = 0;i < recipesIds.Count(); i++)
8054 {
8055 int key = recipesIds.Get(i);
8056 string recipeName = moduleRecipesManager.GetRecipeName(key);
8057 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
8058 }
8059 }
8060
8061 // -------------------------------------------------------------------------
8062 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
8063 {
8064 super.GetDebugActions(outputList);
8065
8066 //quantity
8067 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
8068 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
8069 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
8070 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
8071 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8072
8073 //health
8074 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
8075 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
8076 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
8077 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8078 //temperature
8079 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
8080 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
8081 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
8082 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8083
8084 //wet
8085 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
8086 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
8087 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8088
8089 //liquidtype
8090 if (IsLiquidContainer())
8091 {
8092 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
8093 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
8094 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8095 }
8096
8097 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
8098 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8099
8100 // watch
8101 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
8102 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
8103 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8104
8105 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
8106
8107 InventoryLocation loc = new InventoryLocation();
8108 GetInventory().GetCurrentInventoryLocation(loc);
8109 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
8110 {
8111 if (Gizmo_IsSupported())
8112 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
8113 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
8114 }
8115
8116 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8117 }
8118
8119 // -------------------------------------------------------------------------
8120 // -------------------------------------------------------------------------
8121 // -------------------------------------------------------------------------
8122 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
8123 {
8124 super.OnAction(action_id, player, ctx);
8125
8126 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
8127 {
8128 switch (action_id)
8129 {
8130 case EActions.GIZMO_OBJECT:
8131 if (GetGizmoApi())
8132 GetGizmoApi().SelectObject(this);
8133 return true;
8134 case EActions.GIZMO_PHYSICS:
8135 if (GetGizmoApi())
8136 GetGizmoApi().SelectPhysics(GetPhysics());
8137 return true;
8138 }
8139 }
8140
8141 if (g_Game.IsServer())
8142 {
8143 switch (action_id)
8144 {
8145 case EActions.DELETE:
8146 Delete();
8147 return true;
8148 }
8149 }
8150
8151 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
8152 {
8153 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
8154 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
8155 PlayerBase p = PlayerBase.Cast(player);
8156 if (EActions.RECIPES_RANGE_START < 1000)
8157 {
8158 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
8159 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
8160 }
8161 }
8162 #ifndef SERVER
8163 else if (action_id == EActions.WATCH_PLAYER)
8164 {
8165 PluginDeveloper.SetDeveloperItemClientEx(player);
8166 }
8167 #endif
8168 if (g_Game.IsServer())
8169 {
8170 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
8171 {
8172 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
8173 OnDebugButtonPressServer(id + 1);
8174 }
8175
8176 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
8177 {
8178 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
8179 InsertAgent(agent_id,100);
8180 }
8181
8182 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
8183 {
8184 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
8185 RemoveAgent(agent_id2);
8186 }
8187
8188 else if (action_id == EActions.ADD_QUANTITY)
8189 {
8190 if (IsMagazine())
8191 {
8192 Magazine mag = Magazine.Cast(this);
8193 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
8194 }
8195 else
8196 {
8197 AddQuantity(GetQuantityMax() * 0.2);
8198 }
8199
8200 if (m_EM)
8201 {
8202 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
8203 }
8204 //PrintVariables();
8205 }
8206
8207 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
8208 {
8209 if (IsMagazine())
8210 {
8211 Magazine mag2 = Magazine.Cast(this);
8212 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
8213 }
8214 else
8215 {
8216 AddQuantity(- GetQuantityMax() * 0.2);
8217 }
8218 if (m_EM)
8219 {
8220 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
8221 }
8222 //PrintVariables();
8223 }
8224
8225 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
8226 {
8227 SetQuantity(0);
8228
8229 if (m_EM)
8230 {
8231 m_EM.SetEnergy(0);
8232 }
8233 }
8234
8235 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
8236 {
8238
8239 if (m_EM)
8240 {
8241 m_EM.SetEnergy(m_EM.GetEnergyMax());
8242 }
8243 }
8244
8245 else if (action_id == EActions.ADD_HEALTH)
8246 {
8247 AddHealth("","",GetMaxHealth("","Health")/5);
8248 }
8249 else if (action_id == EActions.REMOVE_HEALTH)
8250 {
8251 AddHealth("","",-GetMaxHealth("","Health")/5);
8252 }
8253 else if (action_id == EActions.DESTROY_HEALTH)
8254 {
8255 SetHealth01("","",0);
8256 }
8257 else if (action_id == EActions.WATCH_ITEM)
8258 {
8260 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
8261 #ifdef DEVELOPER
8262 SetDebugDeveloper_item(this);
8263 #endif
8264 }
8265
8266 else if (action_id == EActions.ADD_TEMPERATURE)
8267 {
8268 AddTemperature(20);
8269 //PrintVariables();
8270 }
8271
8272 else if (action_id == EActions.REMOVE_TEMPERATURE)
8273 {
8274 AddTemperature(-20);
8275 //PrintVariables();
8276 }
8277
8278 else if (action_id == EActions.FLIP_FROZEN)
8279 {
8280 SetFrozen(!GetIsFrozen());
8281 //PrintVariables();
8282 }
8283
8284 else if (action_id == EActions.ADD_WETNESS)
8285 {
8286 AddWet(GetWetMax()/5);
8287 //PrintVariables();
8288 }
8289
8290 else if (action_id == EActions.REMOVE_WETNESS)
8291 {
8292 AddWet(-GetWetMax()/5);
8293 //PrintVariables();
8294 }
8295
8296 else if (action_id == EActions.LIQUIDTYPE_UP)
8297 {
8298 int curr_type = GetLiquidType();
8299 SetLiquidType(curr_type * 2);
8300 //AddWet(1);
8301 //PrintVariables();
8302 }
8303
8304 else if (action_id == EActions.LIQUIDTYPE_DOWN)
8305 {
8306 int curr_type2 = GetLiquidType();
8307 SetLiquidType(curr_type2 / 2);
8308 }
8309
8310 else if (action_id == EActions.MAKE_SPECIAL)
8311 {
8312 auto debugParams = DebugSpawnParams.WithPlayer(player);
8313 OnDebugSpawnEx(debugParams);
8314 }
8315
8316 }
8317
8318
8319 return false;
8320 }
8321
8322 // -------------------------------------------------------------------------
8323
8324
8327 void OnActivatedByTripWire();
8328
8330 void OnActivatedByItem(notnull ItemBase item);
8331
8332 //----------------------------------------------------------------
8333 //returns true if item is able to explode when put in fire
8334 bool CanExplodeInFire()
8335 {
8336 return false;
8337 }
8338
8339 //----------------------------------------------------------------
8340 bool CanEat()
8341 {
8342 return true;
8343 }
8344
8345 //----------------------------------------------------------------
8346 override bool IsIgnoredByConstruction()
8347 {
8348 return true;
8349 }
8350
8351 //----------------------------------------------------------------
8352 //has FoodStages in config?
8353 bool HasFoodStage()
8354 {
8355 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
8356 return g_Game.ConfigIsExisting(config_path);
8357 }
8358
8360 FoodStage GetFoodStage()
8361 {
8362 return null;
8363 }
8364
8365 bool CanBeCooked()
8366 {
8367 return false;
8368 }
8369
8370 bool CanBeCookedOnStick()
8371 {
8372 return false;
8373 }
8374
8376 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
8378
8379 //----------------------------------------------------------------
8380 bool CanRepair(ItemBase item_repair_kit)
8381 {
8382 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8383 return module_repairing.CanRepair(this, item_repair_kit);
8384 }
8385
8386 //----------------------------------------------------------------
8387 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
8388 {
8389 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8390 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
8391 }
8392
8393 //----------------------------------------------------------------
8394 int GetItemSize()
8395 {
8396 /*
8397 vector v_size = this.ConfigGetVector("itemSize");
8398 int v_size_x = v_size[0];
8399 int v_size_y = v_size[1];
8400 int size = v_size_x * v_size_y;
8401 return size;
8402 */
8403
8404 return 1;
8405 }
8406
8407 //----------------------------------------------------------------
8408 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
8409 bool CanBeMovedOverride()
8410 {
8411 return m_CanBeMovedOverride;
8412 }
8413
8414 //----------------------------------------------------------------
8415 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
8416 void SetCanBeMovedOverride(bool setting)
8417 {
8418 m_CanBeMovedOverride = setting;
8419 }
8420
8421 //----------------------------------------------------------------
8429 void MessageToOwnerStatus(string text)
8430 {
8431 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8432
8433 if (player)
8434 {
8435 player.MessageStatus(text);
8436 }
8437 }
8438
8439 //----------------------------------------------------------------
8447 void MessageToOwnerAction(string text)
8448 {
8449 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8450
8451 if (player)
8452 {
8453 player.MessageAction(text);
8454 }
8455 }
8456
8457 //----------------------------------------------------------------
8465 void MessageToOwnerFriendly(string text)
8466 {
8467 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8468
8469 if (player)
8470 {
8471 player.MessageFriendly(text);
8472 }
8473 }
8474
8475 //----------------------------------------------------------------
8483 void MessageToOwnerImportant(string text)
8484 {
8485 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8486
8487 if (player)
8488 {
8489 player.MessageImportant(text);
8490 }
8491 }
8492
8493 override bool IsItemBase()
8494 {
8495 return true;
8496 }
8497
8498 // Checks if item is of questioned kind
8499 override bool KindOf(string tag)
8500 {
8501 bool found = false;
8502 string item_name = this.GetType();
8503 ref TStringArray item_tag_array = new TStringArray;
8504 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
8505
8506 int array_size = item_tag_array.Count();
8507 for (int i = 0; i < array_size; i++)
8508 {
8509 if (item_tag_array.Get(i) == tag)
8510 {
8511 found = true;
8512 break;
8513 }
8514 }
8515 return found;
8516 }
8517
8518
8519 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
8520 {
8521 //Debug.Log("OnRPC called");
8522 super.OnRPC(sender, rpc_type,ctx);
8523
8524 //Play soundset for attachment locking (ActionLockAttachment.c)
8525 switch (rpc_type)
8526 {
8527 #ifndef SERVER
8528 case ERPCs.RPC_SOUND_LOCK_ATTACH:
8529 Param2<bool, string> p = new Param2<bool, string>(false, "");
8530
8531 if (!ctx.Read(p))
8532 return;
8533
8534 bool play = p.param1;
8535 string soundSet = p.param2;
8536
8537 if (play)
8538 {
8539 if (m_LockingSound)
8540 {
8542 {
8543 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
8544 }
8545 }
8546 else
8547 {
8548 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
8549 }
8550 }
8551 else
8552 {
8553 SEffectManager.DestroyEffect(m_LockingSound);
8554 }
8555
8556 break;
8557 #endif
8558
8559 }
8560
8561 if (GetWrittenNoteData())
8562 {
8563 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
8564 }
8565 }
8566
8567 //-----------------------------
8568 // VARIABLE MANIPULATION SYSTEM
8569 //-----------------------------
8570 int NameToID(string name)
8571 {
8572 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
8573 return plugin.GetID(name);
8574 }
8575
8576 string IDToName(int id)
8577 {
8578 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
8579 return plugin.GetName(id);
8580 }
8581
8583 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
8584 {
8585 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
8586 //read the flags
8587 int varFlags;
8588 if (!ctx.Read(varFlags))
8589 return;
8590
8591 if (varFlags & ItemVariableFlags.FLOAT)
8592 {
8593 ReadVarsFromCTX(ctx);
8594 }
8595 }
8596
8597 override void SerializeNumericalVars(array<float> floats_out)
8598 {
8599 //some variables handled on EntityAI level already!
8600 super.SerializeNumericalVars(floats_out);
8601
8602 // the order of serialization must be the same as the order of de-serialization
8603 //--------------------------------------------
8604 if (IsVariableSet(VARIABLE_QUANTITY))
8605 {
8606 floats_out.Insert(m_VarQuantity);
8607 }
8608 //--------------------------------------------
8609 if (IsVariableSet(VARIABLE_WET))
8610 {
8611 floats_out.Insert(m_VarWet);
8612 }
8613 //--------------------------------------------
8614 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
8615 {
8616 floats_out.Insert(m_VarLiquidType);
8617 }
8618 //--------------------------------------------
8619 if (IsVariableSet(VARIABLE_COLOR))
8620 {
8621 floats_out.Insert(m_ColorComponentR);
8622 floats_out.Insert(m_ColorComponentG);
8623 floats_out.Insert(m_ColorComponentB);
8624 floats_out.Insert(m_ColorComponentA);
8625 }
8626 //--------------------------------------------
8627 if (IsVariableSet(VARIABLE_CLEANNESS))
8628 {
8629 floats_out.Insert(m_Cleanness);
8630 }
8631 }
8632
8633 override void DeSerializeNumericalVars(array<float> floats)
8634 {
8635 //some variables handled on EntityAI level already!
8636 super.DeSerializeNumericalVars(floats);
8637
8638 // the order of serialization must be the same as the order of de-serialization
8639 int index = 0;
8640 int mask = Math.Round(floats.Get(index));
8641
8642 index++;
8643 //--------------------------------------------
8644 if (mask & VARIABLE_QUANTITY)
8645 {
8646 if (m_IsStoreLoad)
8647 {
8648 SetStoreLoadedQuantity(floats.Get(index));
8649 }
8650 else
8651 {
8652 float quantity = floats.Get(index);
8653 SetQuantity(quantity, true, false, false, false);
8654 }
8655 index++;
8656 }
8657 //--------------------------------------------
8658 if (mask & VARIABLE_WET)
8659 {
8660 float wet = floats.Get(index);
8661 SetWet(wet);
8662 index++;
8663 }
8664 //--------------------------------------------
8665 if (mask & VARIABLE_LIQUIDTYPE)
8666 {
8667 int liquidtype = Math.Round(floats.Get(index));
8668 SetLiquidType(liquidtype);
8669 index++;
8670 }
8671 //--------------------------------------------
8672 if (mask & VARIABLE_COLOR)
8673 {
8674 m_ColorComponentR = Math.Round(floats.Get(index));
8675 index++;
8676 m_ColorComponentG = Math.Round(floats.Get(index));
8677 index++;
8678 m_ColorComponentB = Math.Round(floats.Get(index));
8679 index++;
8680 m_ColorComponentA = Math.Round(floats.Get(index));
8681 index++;
8682 }
8683 //--------------------------------------------
8684 if (mask & VARIABLE_CLEANNESS)
8685 {
8686 int cleanness = Math.Round(floats.Get(index));
8687 SetCleanness(cleanness);
8688 index++;
8689 }
8690 }
8691
8692 override void WriteVarsToCTX(ParamsWriteContext ctx)
8693 {
8694 super.WriteVarsToCTX(ctx);
8695
8696 //--------------------------------------------
8697 if (IsVariableSet(VARIABLE_QUANTITY))
8698 {
8699 ctx.Write(GetQuantity());
8700 }
8701 //--------------------------------------------
8702 if (IsVariableSet(VARIABLE_WET))
8703 {
8704 ctx.Write(GetWet());
8705 }
8706 //--------------------------------------------
8707 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
8708 {
8709 ctx.Write(GetLiquidType());
8710 }
8711 //--------------------------------------------
8712 if (IsVariableSet(VARIABLE_COLOR))
8713 {
8714 int r,g,b,a;
8715 GetColor(r,g,b,a);
8716 ctx.Write(r);
8717 ctx.Write(g);
8718 ctx.Write(b);
8719 ctx.Write(a);
8720 }
8721 //--------------------------------------------
8722 if (IsVariableSet(VARIABLE_CLEANNESS))
8723 {
8724 ctx.Write(GetCleanness());
8725 }
8726 }
8727
8728 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
8729 {
8730 if (!super.ReadVarsFromCTX(ctx,version))
8731 return false;
8732
8733 int intValue;
8734 float value;
8735
8736 if (version < 140)
8737 {
8738 if (!ctx.Read(intValue))
8739 return false;
8740
8741 m_VariablesMask = intValue;
8742 }
8743
8744 if (m_VariablesMask & VARIABLE_QUANTITY)
8745 {
8746 if (!ctx.Read(value))
8747 return false;
8748
8749 if (IsStoreLoad())
8750 {
8752 }
8753 else
8754 {
8755 SetQuantity(value, true, false, false, false);
8756 }
8757 }
8758 //--------------------------------------------
8759 if (version < 140)
8760 {
8761 if (m_VariablesMask & VARIABLE_TEMPERATURE)
8762 {
8763 if (!ctx.Read(value))
8764 return false;
8765 SetTemperatureDirect(value);
8766 }
8767 }
8768 //--------------------------------------------
8769 if (m_VariablesMask & VARIABLE_WET)
8770 {
8771 if (!ctx.Read(value))
8772 return false;
8773 SetWet(value);
8774 }
8775 //--------------------------------------------
8776 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
8777 {
8778 if (!ctx.Read(intValue))
8779 return false;
8780 SetLiquidType(intValue);
8781 }
8782 //--------------------------------------------
8783 if (m_VariablesMask & VARIABLE_COLOR)
8784 {
8785 int r,g,b,a;
8786 if (!ctx.Read(r))
8787 return false;
8788 if (!ctx.Read(g))
8789 return false;
8790 if (!ctx.Read(b))
8791 return false;
8792 if (!ctx.Read(a))
8793 return false;
8794
8795 SetColor(r,g,b,a);
8796 }
8797 //--------------------------------------------
8798 if (m_VariablesMask & VARIABLE_CLEANNESS)
8799 {
8800 if (!ctx.Read(intValue))
8801 return false;
8802 SetCleanness(intValue);
8803 }
8804 //--------------------------------------------
8805 if (version >= 138 && version < 140)
8806 {
8807 if (m_VariablesMask & VARIABLE_TEMPERATURE)
8808 {
8809 if (!ctx.Read(intValue))
8810 return false;
8811 SetFrozen(intValue);
8812 }
8813 }
8814
8815 return true;
8816 }
8817
8818 //----------------------------------------------------------------
8819 override bool OnStoreLoad(ParamsReadContext ctx, int version)
8820 {
8821 m_IsStoreLoad = true;
8823 {
8824 m_FixDamageSystemInit = true;
8825 }
8826
8827 if (!super.OnStoreLoad(ctx, version))
8828 {
8829 m_IsStoreLoad = false;
8830 return false;
8831 }
8832
8833 if (version >= 114)
8834 {
8835 bool hasQuickBarIndexSaved;
8836
8837 if (!ctx.Read(hasQuickBarIndexSaved))
8838 {
8839 m_IsStoreLoad = false;
8840 return false;
8841 }
8842
8843 if (hasQuickBarIndexSaved)
8844 {
8845 int itmQBIndex;
8846
8847 //Load quickbar item bind
8848 if (!ctx.Read(itmQBIndex))
8849 {
8850 m_IsStoreLoad = false;
8851 return false;
8852 }
8853
8854 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
8855 if (itmQBIndex != -1 && parentPlayer)
8856 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
8857 }
8858 }
8859 else
8860 {
8861 // Backup of how it used to be
8862 PlayerBase player;
8863 int itemQBIndex;
8864 if (version == int.MAX)
8865 {
8866 if (!ctx.Read(itemQBIndex))
8867 {
8868 m_IsStoreLoad = false;
8869 return false;
8870 }
8871 }
8872 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
8873 {
8874 //Load quickbar item bind
8875 if (!ctx.Read(itemQBIndex))
8876 {
8877 m_IsStoreLoad = false;
8878 return false;
8879 }
8880 if (itemQBIndex != -1 && player)
8881 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
8882 }
8883 }
8884
8885 if (version < 140)
8886 {
8887 // variable management system
8888 if (!LoadVariables(ctx, version))
8889 {
8890 m_IsStoreLoad = false;
8891 return false;
8892 }
8893 }
8894
8895 //agent trasmission system
8896 if (!LoadAgents(ctx, version))
8897 {
8898 m_IsStoreLoad = false;
8899 return false;
8900 }
8901 if (version >= 132)
8902 {
8903 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
8904 if (raib)
8905 {
8906 if (!raib.OnStoreLoad(ctx,version))
8907 {
8908 m_IsStoreLoad = false;
8909 return false;
8910 }
8911 }
8912 }
8913
8914 m_IsStoreLoad = false;
8915 return true;
8916 }
8917
8918 //----------------------------------------------------------------
8919
8920 override void OnStoreSave(ParamsWriteContext ctx)
8921 {
8922 super.OnStoreSave(ctx);
8923
8924 PlayerBase player;
8925 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
8926 {
8927 ctx.Write(true); // Keep track of if we should actually read this in or not
8928 //Save quickbar item bind
8929 int itemQBIndex = -1;
8930 itemQBIndex = player.FindQuickBarEntityIndex(this);
8931 ctx.Write(itemQBIndex);
8932 }
8933 else
8934 {
8935 ctx.Write(false); // Keep track of if we should actually read this in or not
8936 }
8937
8938 SaveAgents(ctx);//agent trasmission system
8939
8940 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
8941 if (raib)
8942 {
8943 raib.OnStoreSave(ctx);
8944 }
8945 }
8946 //----------------------------------------------------------------
8947
8948 override void AfterStoreLoad()
8949 {
8950 super.AfterStoreLoad();
8951
8953 {
8955 }
8956
8957 if (GetStoreLoadedQuantity() != float.LOWEST)
8958 {
8960 SetStoreLoadedQuantity(float.LOWEST);//IMPORTANT to do this !! we use 'm_StoreLoadedQuantity' inside SetQuantity to distinguish between initial quantity setting and the consequent(normal gameplay) calls
8961 }
8962 }
8963
8964 override void EEOnAfterLoad()
8965 {
8966 super.EEOnAfterLoad();
8967
8969 {
8970 m_FixDamageSystemInit = false;
8971 }
8972
8975 }
8976
8977 bool CanBeDisinfected()
8978 {
8979 return false;
8980 }
8981
8982
8983 //----------------------------------------------------------------
8984 override void OnVariablesSynchronized()
8985 {
8986 if (m_Initialized)
8987 {
8988 #ifdef PLATFORM_CONSOLE
8989 //bruteforce it is
8990 if (IsSplitable())
8991 {
8992 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
8993 if (menu)
8994 {
8995 menu.Refresh();
8996 }
8997 }
8998 #endif
8999 }
9000
9002 {
9003 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9004 m_WantPlayImpactSound = false;
9005 }
9006
9008 {
9009 SetWeightDirty();
9011 }
9012 if (m_VarWet != m_VarWetPrev)
9013 {
9016 }
9017
9018 if (m_SoundSyncPlay != 0)
9019 {
9022
9023 m_SoundSyncPlay = 0;
9024 m_SoundSyncSlotID = -1;
9025 }
9026 if (m_SoundSyncStop != 0)
9027 {
9029 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
9030 m_SoundSyncStop = 0;
9031 }
9032
9033 super.OnVariablesSynchronized();
9034 }
9035
9036 //------------------------- Quantity
9037 //----------------------------------------------------------------
9039 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
9040 {
9041 if (!IsServerCheck(allow_client))
9042 return false;
9043
9044 if (!HasQuantity())
9045 return false;
9046
9047 float min = GetQuantityMin();
9048 float max = GetQuantityMax();
9049
9050 if (value <= (min + 0.001))
9051 value = min;
9052
9053 if (value == min)
9054 {
9055 if (destroy_config)
9056 {
9057 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
9058 if (dstr)
9059 {
9060 m_VarQuantity = Math.Clamp(value, min, max);
9061 this.Delete();
9062 return true;
9063 }
9064 }
9065 else if (destroy_forced)
9066 {
9067 m_VarQuantity = Math.Clamp(value, min, max);
9068 this.Delete();
9069 return true;
9070 }
9071 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
9072 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
9073 }
9074
9075 float delta = m_VarQuantity;
9076 m_VarQuantity = Math.Clamp(value, min, max);
9077
9078 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
9079 {
9080 EntityAI parent = GetHierarchyRoot();
9081 InventoryLocation iLoc = new InventoryLocation();
9082 GetInventory().GetCurrentInventoryLocation(iLoc);
9083 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
9084 {
9085 int iLocSlot = iLoc.GetSlot();
9086 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
9087 {
9088 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
9089 }
9090 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
9091 {
9092 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
9093 }
9094 }
9095 }
9096
9097 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
9098 {
9099 delta = m_VarQuantity - delta;
9100
9101 if (delta)
9102 OnQuantityChanged(delta);
9103 }
9104
9105 SetVariableMask(VARIABLE_QUANTITY);
9106
9107 return false;
9108 }
9109
9110 //----------------------------------------------------------------
9112 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
9113 {
9114 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
9115 }
9116 //----------------------------------------------------------------
9117 void SetQuantityMax()
9118 {
9119 float max = GetQuantityMax();
9120 SetQuantity(max);
9121 }
9122
9123 override void SetQuantityToMinimum()
9124 {
9125 float min = GetQuantityMin();
9126 SetQuantity(min);
9127 }
9128 //----------------------------------------------------------------
9130 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
9131 {
9132 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
9133 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
9134 SetQuantity(result, destroy_config, destroy_forced);
9135 }
9136
9137 //----------------------------------------------------------------
9139 override float GetQuantityNormalized()
9140 {
9141 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
9142 }
9143
9145 {
9146 return GetQuantityNormalized();
9147 }
9148
9149 /*void SetAmmoNormalized(float value)
9150 {
9151 float value_clamped = Math.Clamp(value, 0, 1);
9152 Magazine this_mag = Magazine.Cast(this);
9153 int max_rounds = this_mag.GetAmmoMax();
9154 int result = value * max_rounds;//can the rounded if higher precision is required
9155 this_mag.SetAmmoCount(result);
9156 }*/
9157 //----------------------------------------------------------------
9158 override int GetQuantityMax()
9159 {
9160 int slot = -1;
9161 GameInventory inventory = GetInventory();
9162 if (inventory)
9163 {
9164 InventoryLocation il = new InventoryLocation;
9165 inventory.GetCurrentInventoryLocation(il);
9166 slot = il.GetSlot();
9167 }
9168
9169 return GetTargetQuantityMax(slot);
9170 }
9171
9172 override int GetTargetQuantityMax(int attSlotID = -1)
9173 {
9174 float quantity_max = 0;
9175
9176 if (IsSplitable()) //only stackable/splitable items can check for stack size
9177 {
9178 if (attSlotID != -1)
9179 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
9180
9181 if (quantity_max <= 0)
9182 quantity_max = m_VarStackMax;
9183 }
9184
9185 if (quantity_max <= 0)
9186 quantity_max = m_VarQuantityMax;
9187
9188 return quantity_max;
9189 }
9190 //----------------------------------------------------------------
9191 override int GetQuantityMin()
9192 {
9193 return m_VarQuantityMin;
9194 }
9195 //----------------------------------------------------------------
9196 int GetQuantityInit()
9197 {
9198 return m_VarQuantityInit;
9199 }
9200
9201 //----------------------------------------------------------------
9202 override bool HasQuantity()
9203 {
9204 return !(GetQuantityMax() - GetQuantityMin() == 0);
9205 }
9206
9207 override float GetQuantity()
9208 {
9209 return m_VarQuantity;
9210 }
9211
9212 bool IsFullQuantity()
9213 {
9214 return GetQuantity() >= GetQuantityMax();
9215 }
9216
9217 //Calculates weight of single item without attachments and cargo
9218 override float GetSingleInventoryItemWeightEx()
9219 {
9220 //this needs to be first stored inside local variables, when returned directly during inside return call, the result is completely different due to enforce script bug
9221 float weightEx = GetWeightEx();//overall weight of the item
9222 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
9223 return weightEx - special;
9224 }
9225
9226 // Obsolete, use GetSingleInventoryItemWeightEx() instead
9228 {
9230 }
9231
9232 override protected float GetWeightSpecialized(bool forceRecalc = false)
9233 {
9234 if (IsSplitable()) //quantity determines size of the stack
9235 {
9236 #ifdef DEVELOPER
9237 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9238 {
9239 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
9240 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
9241 }
9242 #endif
9243
9244 return GetQuantity() * GetConfigWeightModified();
9245 }
9246 else if (HasEnergyManager())// items with energy manager
9247 {
9248 #ifdef DEVELOPER
9249 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9250 {
9251 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
9252 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
9253 }
9254 #endif
9255 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
9256 }
9257 else//everything else
9258 {
9259 #ifdef DEVELOPER
9260 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9261 {
9262 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
9263 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
9264 }
9265 #endif
9266 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
9267 }
9268 }
9269
9271 int GetNumberOfItems()
9272 {
9273 int item_count = 0;
9274 ItemBase item;
9275
9276 GameInventory inventory = GetInventory();
9277 CargoBase cargo = inventory.GetCargo();
9278 if (cargo != NULL)
9279 {
9280 item_count = cargo.GetItemCount();
9281 }
9282
9283 int nAttachments = inventory.AttachmentCount();
9284 for (int i = 0; i < nAttachments; ++i)
9285 {
9286 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
9287 if (item)
9288 item_count += item.GetNumberOfItems();
9289 }
9290 return item_count;
9291 }
9292
9294 float GetUnitWeight(bool include_wetness = true)
9295 {
9296 float weight = 0;
9297 float wetness = 1;
9298 if (include_wetness)
9299 wetness += GetWet();
9300 if (IsSplitable()) //quantity determines size of the stack
9301 {
9302 weight = wetness * m_ConfigWeight;
9303 }
9304 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
9305 {
9306 weight = 1;
9307 }
9308 return weight;
9309 }
9310
9311 //-----------------------------------------------------------------
9312
9313 override void ClearInventory()
9314 {
9315 GameInventory inventory = GetInventory();
9316 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
9317 {
9318 array<EntityAI> items = new array<EntityAI>;
9319 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
9320 for (int i = 0; i < items.Count(); ++i)
9321 {
9322 ItemBase item = ItemBase.Cast(items.Get(i));
9323 if (item)
9324 {
9325 g_Game.ObjectDelete(item);
9326 }
9327 }
9328 }
9329 }
9330
9331 //------------------------- Energy
9332
9333 //----------------------------------------------------------------
9334 float GetEnergy()
9335 {
9336 float energy = 0;
9337 if (HasEnergyManager())
9338 {
9339 energy = GetCompEM().GetEnergy();
9340 }
9341 return energy;
9342 }
9343
9344
9345 override void OnEnergyConsumed()
9346 {
9347 super.OnEnergyConsumed();
9348
9350 }
9351
9352 override void OnEnergyAdded()
9353 {
9354 super.OnEnergyAdded();
9355
9357 }
9358
9359 // Converts energy (from Energy Manager) to quantity, if enabled.
9361 {
9362 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
9363 {
9364 if (HasQuantity())
9365 {
9366 float energy_0to1 = GetCompEM().GetEnergy0To1();
9367 SetQuantityNormalized(energy_0to1);
9368 }
9369 }
9370 }
9371
9372 //----------------------------------------------------------------
9373 float GetHeatIsolationInit()
9374 {
9375 return ConfigGetFloat("heatIsolation");
9376 }
9377
9378 float GetHeatIsolation()
9379 {
9380 return m_HeatIsolation;
9381 }
9382
9383 float GetDryingIncrement(string pIncrementName)
9384 {
9385 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
9386 if (g_Game.ConfigIsExisting(paramPath))
9387 return g_Game.ConfigGetFloat(paramPath);
9388
9389 return 0.0;
9390 }
9391
9392 float GetSoakingIncrement(string pIncrementName)
9393 {
9394 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
9395 if (g_Game.ConfigIsExisting(paramPath))
9396 return g_Game.ConfigGetFloat(paramPath);
9397
9398 return 0.0;
9399 }
9400 //----------------------------------------------------------------
9401 override void SetWet(float value, bool allow_client = false)
9402 {
9403 if (!IsServerCheck(allow_client))
9404 return;
9405
9406 float min = GetWetMin();
9407 float max = GetWetMax();
9408
9409 float previousValue = m_VarWet;
9410
9411 m_VarWet = Math.Clamp(value, min, max);
9412
9413 if (previousValue != m_VarWet)
9414 {
9415 SetVariableMask(VARIABLE_WET);
9416 OnWetChanged(m_VarWet, previousValue);
9417 }
9418 }
9419 //----------------------------------------------------------------
9420 override void AddWet(float value)
9421 {
9422 SetWet(GetWet() + value);
9423 }
9424 //----------------------------------------------------------------
9425 override void SetWetMax()
9426 {
9428 }
9429 //----------------------------------------------------------------
9430 override float GetWet()
9431 {
9432 return m_VarWet;
9433 }
9434 //----------------------------------------------------------------
9435 override float GetWetMax()
9436 {
9437 return m_VarWetMax;
9438 }
9439 //----------------------------------------------------------------
9440 override float GetWetMin()
9441 {
9442 return m_VarWetMin;
9443 }
9444 //----------------------------------------------------------------
9445 override float GetWetInit()
9446 {
9447 return m_VarWetInit;
9448 }
9449 //----------------------------------------------------------------
9450 override void OnWetChanged(float newVal, float oldVal)
9451 {
9452 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
9453 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
9454 if (newLevel != oldLevel)
9455 {
9456 OnWetLevelChanged(newLevel,oldLevel);
9457 }
9458 }
9459
9460 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
9461 {
9462 SetWeightDirty();
9463 }
9464
9465 override EWetnessLevel GetWetLevel()
9466 {
9467 return GetWetLevelInternal(m_VarWet);
9468 }
9469
9470 //----------------------------------------------------------------
9471
9472 override void SetStoreLoad(bool value)
9473 {
9474 m_IsStoreLoad = value;
9475 }
9476
9477 override bool IsStoreLoad()
9478 {
9479 return m_IsStoreLoad;
9480 }
9481
9482 override void SetStoreLoadedQuantity(float value)
9483 {
9484 m_StoreLoadedQuantity = value;
9485 }
9486
9487 override float GetStoreLoadedQuantity()
9488 {
9489 return m_StoreLoadedQuantity;
9490 }
9491
9492 //----------------------------------------------------------------
9493
9494 float GetItemModelLength()
9495 {
9496 if (ConfigIsExisting("itemModelLength"))
9497 {
9498 return ConfigGetFloat("itemModelLength");
9499 }
9500 return 0;
9501 }
9502
9503 float GetItemAttachOffset()
9504 {
9505 if (ConfigIsExisting("itemAttachOffset"))
9506 {
9507 return ConfigGetFloat("itemAttachOffset");
9508 }
9509 return 0;
9510 }
9511
9512 override void SetCleanness(int value, bool allow_client = false)
9513 {
9514 if (!IsServerCheck(allow_client))
9515 return;
9516
9517 int previousValue = m_Cleanness;
9518
9519 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
9520
9521 if (previousValue != m_Cleanness)
9522 SetVariableMask(VARIABLE_CLEANNESS);
9523 }
9524
9525 override int GetCleanness()
9526 {
9527 return m_Cleanness;
9528 }
9529
9531 {
9532 return true;
9533 }
9534
9535 //----------------------------------------------------------------
9536 // ATTACHMENT LOCKING
9537 // Getters relevant to generic ActionLockAttachment
9538 int GetLockType()
9539 {
9540 return m_LockType;
9541 }
9542
9543 string GetLockSoundSet()
9544 {
9545 return m_LockSoundSet;
9546 }
9547
9548 //----------------------------------------------------------------
9549 //------------------------- Color
9550 // sets items color variable given color components
9551 override void SetColor(int r, int g, int b, int a)
9552 {
9557 SetVariableMask(VARIABLE_COLOR);
9558 }
9560 override void GetColor(out int r,out int g,out int b,out int a)
9561 {
9566 }
9567
9568 bool IsColorSet()
9569 {
9570 return IsVariableSet(VARIABLE_COLOR);
9571 }
9572
9574 string GetColorString()
9575 {
9576 int r,g,b,a;
9577 GetColor(r,g,b,a);
9578 r = r/255;
9579 g = g/255;
9580 b = b/255;
9581 a = a/255;
9582 return MiscGameplayFunctions.GetColorString(r, g, b, a);
9583 }
9584 //----------------------------------------------------------------
9585 //------------------------- LiquidType
9586
9587 override void SetLiquidType(int value, bool allow_client = false)
9588 {
9589 if (!IsServerCheck(allow_client))
9590 return;
9591
9592 int old = m_VarLiquidType;
9593 m_VarLiquidType = value;
9594 OnLiquidTypeChanged(old,value);
9595 SetVariableMask(VARIABLE_LIQUIDTYPE);
9596 }
9597
9598 int GetLiquidTypeInit()
9599 {
9600 return ConfigGetInt("varLiquidTypeInit");
9601 }
9602
9603 override int GetLiquidType()
9604 {
9605 return m_VarLiquidType;
9606 }
9607
9608 protected void OnLiquidTypeChanged(int oldType, int newType)
9609 {
9610 if (newType == LIQUID_NONE && GetIsFrozen())
9611 SetFrozen(false);
9612 }
9613
9615 void UpdateQuickbarShortcutVisibility(PlayerBase player)
9616 {
9617 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
9618 }
9619
9620 // -------------------------------------------------------------------------
9622 void OnInventoryEnter(Man player)
9623 {
9624 PlayerBase nplayer;
9625 if (PlayerBase.CastTo(nplayer, player))
9626 {
9627 m_CanPlayImpactSound = true;
9628 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
9629 }
9630 }
9631
9632 // -------------------------------------------------------------------------
9634 void OnInventoryExit(Man player)
9635 {
9636 PlayerBase nplayer;
9637 if (PlayerBase.CastTo(nplayer,player))
9638 {
9639 nplayer.SetEnableQuickBarEntityShortcut(this, false);
9640 }
9641
9642 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
9643
9644 if (HasEnergyManager())
9645 {
9646 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
9647 }
9648 }
9649
9650 // ADVANCED PLACEMENT EVENTS
9651 override void OnPlacementStarted(Man player)
9652 {
9653 super.OnPlacementStarted(player);
9654
9655 SetTakeable(false);
9656 }
9657
9658 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
9659 {
9660 if (m_AdminLog)
9661 {
9662 m_AdminLog.OnPlacementComplete(player, this);
9663 }
9664
9665 super.OnPlacementComplete(player, position, orientation);
9666 }
9667
9668 //-----------------------------
9669 // AGENT SYSTEM
9670 //-----------------------------
9671 //--------------------------------------------------------------------------
9672 bool ContainsAgent(int agent_id)
9673 {
9674 if (agent_id & m_AttachedAgents)
9675 {
9676 return true;
9677 }
9678 else
9679 {
9680 return false;
9681 }
9682 }
9683
9684 //--------------------------------------------------------------------------
9685 override void RemoveAgent(int agent_id)
9686 {
9687 if (ContainsAgent(agent_id))
9688 {
9689 m_AttachedAgents = ~agent_id & m_AttachedAgents;
9690 }
9691 }
9692
9693 //--------------------------------------------------------------------------
9694 override void RemoveAllAgents()
9695 {
9696 m_AttachedAgents = 0;
9697 }
9698 //--------------------------------------------------------------------------
9699 override void RemoveAllAgentsExcept(int agent_to_keep)
9700 {
9701 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
9702 }
9703 // -------------------------------------------------------------------------
9704 override void InsertAgent(int agent, float count = 1)
9705 {
9706 if (count < 1)
9707 return;
9708 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
9710 }
9711
9713 void TransferAgents(int agents)
9714 {
9716 }
9717
9718 // -------------------------------------------------------------------------
9719 override int GetAgents()
9720 {
9721 return m_AttachedAgents;
9722 }
9723 //----------------------------------------------------------------------
9724
9725 /*int GetContaminationType()
9726 {
9727 int contamination_type;
9728
9729 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
9730 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
9731 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
9732 const int DIRTY_MASK = eAgents.WOUND_AGENT;
9733
9734 Edible_Base edible = Edible_Base.Cast(this);
9735 int agents = GetAgents();
9736 if (edible)
9737 {
9738 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
9739 if (profile)
9740 {
9741 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
9742 }
9743 }
9744 if (agents & CONTAMINATED_MASK)
9745 {
9746 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
9747 }
9748 if (agents & POISONED_MASK)
9749 {
9750 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
9751 }
9752 if (agents & NERVE_GAS_MASK)
9753 {
9754 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
9755 }
9756 if (agents & DIRTY_MASK)
9757 {
9758 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
9759 }
9760
9761 return agents;
9762 }*/
9763
9764 // -------------------------------------------------------------------------
9765 bool LoadAgents(ParamsReadContext ctx, int version)
9766 {
9767 if (!ctx.Read(m_AttachedAgents))
9768 return false;
9769 return true;
9770 }
9771 // -------------------------------------------------------------------------
9773 {
9774
9776 }
9777 // -------------------------------------------------------------------------
9778
9780 override void CheckForRoofLimited(float timeTresholdMS = 3000)
9781 {
9782 super.CheckForRoofLimited(timeTresholdMS);
9783
9784 float time = g_Game.GetTime();
9785 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
9786 {
9787 m_PreviousRoofTestTime = time;
9788 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
9789 }
9790 }
9791
9792 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
9793 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
9794 {
9795 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
9796 {
9797 return 0;
9798 }
9799
9800 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
9801 {
9802 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
9803 if (filter)
9804 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
9805 else
9806 return 0;//otherwise return 0 when no filter attached
9807 }
9808
9809 string subclassPath, entryName;
9810
9811 switch (type)
9812 {
9813 case DEF_BIOLOGICAL:
9814 entryName = "biological";
9815 break;
9816 case DEF_CHEMICAL:
9817 entryName = "chemical";
9818 break;
9819 default:
9820 entryName = "biological";
9821 break;
9822 }
9823
9824 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
9825
9826 return g_Game.ConfigGetFloat(subclassPath + entryName);
9827 }
9828
9829
9830
9832 override void EEOnCECreate()
9833 {
9834 if (!IsMagazine())
9836
9838 }
9839
9840
9841 //-------------------------
9842 // OPEN/CLOSE USER ACTIONS
9843 //-------------------------
9845 void Open();
9846 void Close();
9847 bool IsOpen()
9848 {
9849 return true;
9850 }
9851
9852 override bool CanDisplayCargo()
9853 {
9854 return IsOpen();
9855 }
9856
9857
9858 // ------------------------------------------------------------
9859 // CONDITIONS
9860 // ------------------------------------------------------------
9861 override bool CanPutInCargo(EntityAI parent)
9862 {
9863 if (parent)
9864 {
9865 if (parent.IsInherited(DayZInfected))
9866 return true;
9867
9868 if (!parent.IsRuined())
9869 return true;
9870 }
9871
9872 return true;
9873 }
9874
9875 override bool CanPutAsAttachment(EntityAI parent)
9876 {
9877 if (!super.CanPutAsAttachment(parent))
9878 {
9879 return false;
9880 }
9881
9882 if (!IsRuined() && !parent.IsRuined())
9883 {
9884 return true;
9885 }
9886
9887 return false;
9888 }
9889
9890 override bool CanReceiveItemIntoCargo(EntityAI item)
9891 {
9892 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9893 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9894 // return false;
9895
9896 return super.CanReceiveItemIntoCargo(item);
9897 }
9898
9899 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
9900 {
9901 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9902 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9903 // return false;
9904
9905 GameInventory attachmentInv = attachment.GetInventory();
9906 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
9907 {
9908 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
9909 return false;
9910 }
9911
9912 InventoryLocation loc = new InventoryLocation();
9913 attachment.GetInventory().GetCurrentInventoryLocation(loc);
9914 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
9915 return false;
9916
9917 return super.CanReceiveAttachment(attachment, slotId);
9918 }
9919
9920 override bool CanReleaseAttachment(EntityAI attachment)
9921 {
9922 if (!super.CanReleaseAttachment(attachment))
9923 return false;
9924
9925 return GetInventory().AreChildrenAccessible();
9926 }
9927
9928 /*override bool CanLoadAttachment(EntityAI attachment)
9929 {
9930 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9931 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9932 // return false;
9933
9934 GameInventory attachmentInv = attachment.GetInventory();
9935 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
9936 {
9937 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
9938 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
9939
9940 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
9941 return false;
9942 }
9943
9944 return super.CanLoadAttachment(attachment);
9945 }*/
9946
9947 // Plays muzzle flash particle effects
9948 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9949 {
9950 int id = muzzle_owner.GetMuzzleID();
9951 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
9952
9953 if (WPOF_array)
9954 {
9955 for (int i = 0; i < WPOF_array.Count(); i++)
9956 {
9957 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
9958
9959 if (WPOF)
9960 {
9961 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
9962 }
9963 }
9964 }
9965 }
9966
9967 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
9968 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9969 {
9970 int id = muzzle_owner.GetMuzzleID();
9971 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
9972
9973 if (WPOBE_array)
9974 {
9975 for (int i = 0; i < WPOBE_array.Count(); i++)
9976 {
9977 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
9978
9979 if (WPOBE)
9980 {
9981 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
9982 }
9983 }
9984 }
9985 }
9986
9987 // Plays all weapon overheating particles
9988 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9989 {
9990 int id = muzzle_owner.GetMuzzleID();
9991 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
9992
9993 if (WPOOH_array)
9994 {
9995 for (int i = 0; i < WPOOH_array.Count(); i++)
9996 {
9997 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
9998
9999 if (WPOOH)
10000 {
10001 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
10002 }
10003 }
10004 }
10005 }
10006
10007 // Updates all weapon overheating particles
10008 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10009 {
10010 int id = muzzle_owner.GetMuzzleID();
10011 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10012
10013 if (WPOOH_array)
10014 {
10015 for (int i = 0; i < WPOOH_array.Count(); i++)
10016 {
10017 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10018
10019 if (WPOOH)
10020 {
10021 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10022 }
10023 }
10024 }
10025 }
10026
10027 // Stops overheating particles
10028 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10029 {
10030 int id = muzzle_owner.GetMuzzleID();
10031 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10032
10033 if (WPOOH_array)
10034 {
10035 for (int i = 0; i < WPOOH_array.Count(); i++)
10036 {
10037 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10038
10039 if (WPOOH)
10040 {
10041 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10042 }
10043 }
10044 }
10045 }
10046
10047 //----------------------------------------------------------------
10048 //Item Behaviour - unified approach
10049 override bool IsHeavyBehaviour()
10050 {
10051 if (m_ItemBehaviour == 0)
10052 {
10053 return true;
10054 }
10055
10056 return false;
10057 }
10058
10059 override bool IsOneHandedBehaviour()
10060 {
10061 if (m_ItemBehaviour == 1)
10062 {
10063 return true;
10064 }
10065
10066 return false;
10067 }
10068
10069 override bool IsTwoHandedBehaviour()
10070 {
10071 if (m_ItemBehaviour == 2)
10072 {
10073 return true;
10074 }
10075
10076 return false;
10077 }
10078
10079 bool IsDeployable()
10080 {
10081 return false;
10082 }
10083
10085 float GetDeployTime()
10086 {
10087 return UATimeSpent.DEFAULT_DEPLOY;
10088 }
10089
10090
10091 //----------------------------------------------------------------
10092 // Item Targeting (User Actions)
10093 override void SetTakeable(bool pState)
10094 {
10095 m_IsTakeable = pState;
10096 SetSynchDirty();
10097 }
10098
10099 override bool IsTakeable()
10100 {
10101 return m_IsTakeable;
10102 }
10103
10104 // For cases where we want to show object widget which cant be taken to hands
10106 {
10107 return false;
10108 }
10109
10111 protected void PreLoadSoundAttachmentType()
10112 {
10113 string att_type = "None";
10114
10115 if (ConfigIsExisting("soundAttType"))
10116 {
10117 att_type = ConfigGetString("soundAttType");
10118 }
10119
10120 m_SoundAttType = att_type;
10121 }
10122
10123 override string GetAttachmentSoundType()
10124 {
10125 return m_SoundAttType;
10126 }
10127
10128 //----------------------------------------------------------------
10129 //SOUNDS - ItemSoundHandler
10130 //----------------------------------------------------------------
10131
10132 string GetPlaceSoundset(); // played when deploy starts
10133 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
10134 string GetDeploySoundset(); // played when deploy sucessfully finishes
10135 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
10136 string GetFoldSoundset(); // played when fold sucessfully finishes
10137
10139 {
10140 if (!m_ItemSoundHandler)
10142
10143 return m_ItemSoundHandler;
10144 }
10145
10146 // override to initialize sounds
10147 protected void InitItemSounds()
10148 {
10149 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
10150 return;
10151
10153
10154 if (GetPlaceSoundset() != string.Empty)
10155 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
10156
10157 if (GetDeploySoundset() != string.Empty)
10158 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
10159
10160 SoundParameters params = new SoundParameters();
10161 params.m_Loop = true;
10162 if (GetLoopDeploySoundset() != string.Empty)
10163 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
10164 }
10165
10166 // Start sound using ItemSoundHandler
10167 void StartItemSoundServer(int id, int slotId)
10168 {
10169 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
10170 {
10171 m_SoundSyncSlotID = slotId;
10172 m_SoundSyncPlay = id;
10173
10174 SetSynchDirty();
10175
10176 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
10177 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
10178 }
10179 }
10180
10181 void StartItemSoundServer(int id)
10182 {
10183 StartItemSoundServer(id, InventorySlots.INVALID);
10184 }
10185
10186 // Stop sound using ItemSoundHandler
10187 void StopItemSoundServer(int id)
10188 {
10189 if (!g_Game.IsServer())
10190 return;
10191
10192 m_SoundSyncStop = id;
10193 SetSynchDirty();
10194
10195 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
10196 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
10197 }
10198
10199 protected void ClearStartItemSoundServer()
10200 {
10201 m_SoundSyncPlay = 0;
10202 m_SoundSyncSlotID = InventorySlots.INVALID;
10203 }
10204
10205 protected void ClearStopItemSoundServer()
10206 {
10207 m_SoundSyncStop = 0;
10208 }
10209
10210 void OnApply(PlayerBase player);
10211
10213 {
10214 return 1.0;
10215 };
10216 //returns applicable selection
10217 array<string> GetHeadHidingSelection()
10218 {
10220 }
10221
10223 {
10225 }
10226
10227 WrittenNoteData GetWrittenNoteData() {};
10228
10230 {
10231 SetDynamicPhysicsLifeTime(0.01);
10232 m_ItemBeingDroppedPhys = false;
10233 }
10234
10236 {
10237 array<string> zone_names = new array<string>;
10238 GetDamageZones(zone_names);
10239 for (int i = 0; i < zone_names.Count(); i++)
10240 {
10241 SetHealthMax(zone_names.Get(i),"Health");
10242 }
10243 SetHealthMax("","Health");
10244 }
10245
10247 void SetZoneDamageCEInit()
10248 {
10249 float global_health = GetHealth01("","Health");
10250 array<string> zones = new array<string>;
10251 GetDamageZones(zones);
10252 //set damage of all zones to match global health level
10253 for (int i = 0; i < zones.Count(); i++)
10254 {
10255 SetHealth01(zones.Get(i),"Health",global_health);
10256 }
10257 }
10258
10260 bool IsCoverFaceForShave(string slot_name)
10261 {
10262 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
10263 }
10264
10265 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10266 {
10267 if (!hasRootAsPlayer)
10268 {
10269 if (refParentIB)
10270 {
10271 // parent is wet
10272 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
10273 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
10274 // parent has liquid inside
10275 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
10276 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
10277 // drying
10278 else if (m_VarWet > m_VarWetMin)
10279 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
10280 }
10281 else
10282 {
10283 // drying on ground or inside non-itembase (car, ...)
10284 if (m_VarWet > m_VarWetMin)
10285 AddWet(-1 * delta * GetDryingIncrement("ground"));
10286 }
10287 }
10288 }
10289
10290 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10291 {
10293 {
10294 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
10295 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
10296 {
10297 float heatPermCoef = 1.0;
10298 EntityAI ent = this;
10299 while (ent)
10300 {
10301 heatPermCoef *= ent.GetHeatPermeabilityCoef();
10302 ent = ent.GetHierarchyParent();
10303 }
10304
10305 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
10306 }
10307 }
10308 }
10309
10310 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
10311 {
10312 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
10313 EntityAI parent = GetHierarchyParent();
10314 if (!parent)
10315 {
10316 hasParent = false;
10317 hasRootAsPlayer = false;
10318 }
10319 else
10320 {
10321 hasParent = true;
10322 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
10323 refParentIB = ItemBase.Cast(parent);
10324 }
10325 }
10326
10327 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
10328 {
10329 // this is stub, implemented on Edible_Base
10330 }
10331
10332 bool CanDecay()
10333 {
10334 // return true used on selected food clases so they can decay
10335 return false;
10336 }
10337
10338 protected bool CanProcessDecay()
10339 {
10340 // this is stub, implemented on Edible_Base class
10341 // used to determine whether it is still necessary for the food to decay
10342 return false;
10343 }
10344
10345 protected bool CanHaveWetness()
10346 {
10347 // return true used on selected items that have a wetness effect
10348 return false;
10349 }
10350
10352 bool CanBeConsumed(ConsumeConditionData data = null)
10353 {
10354 return !GetIsFrozen() && IsOpen();
10355 }
10356
10357 override void ProcessVariables()
10358 {
10359 bool hasParent = false, hasRootAsPlayer = false;
10360 ItemBase refParentIB;
10361
10362 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
10363 bool foodDecay = g_Game.IsFoodDecayEnabled();
10364
10365 if (wwtu || foodDecay)
10366 {
10367 bool processWetness = wwtu && CanHaveWetness();
10368 bool processTemperature = wwtu && CanHaveTemperature();
10369 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
10370
10371 if (processWetness || processTemperature || processDecay)
10372 {
10373 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
10374
10375 if (processWetness)
10376 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10377
10378 if (processTemperature)
10379 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10380
10381 if (processDecay)
10382 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
10383 }
10384 }
10385 }
10386
10389 {
10390 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
10391 }
10392
10393 override float GetTemperatureFreezeThreshold()
10394 {
10396 return Liquid.GetFreezeThreshold(GetLiquidType());
10397
10398 return super.GetTemperatureFreezeThreshold();
10399 }
10400
10401 override float GetTemperatureThawThreshold()
10402 {
10404 return Liquid.GetThawThreshold(GetLiquidType());
10405
10406 return super.GetTemperatureThawThreshold();
10407 }
10408
10409 override float GetItemOverheatThreshold()
10410 {
10412 return Liquid.GetBoilThreshold(GetLiquidType());
10413
10414 return super.GetItemOverheatThreshold();
10415 }
10416
10417 override float GetTemperatureFreezeTime()
10418 {
10419 if (HasQuantity())
10420 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
10421
10422 return super.GetTemperatureFreezeTime();
10423 }
10424
10425 override float GetTemperatureThawTime()
10426 {
10427 if (HasQuantity())
10428 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
10429
10430 return super.GetTemperatureThawTime();
10431 }
10432
10434 void AffectLiquidContainerOnFill(int liquid_type, float amount);
10436 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
10437
10438 bool IsCargoException4x3(EntityAI item)
10439 {
10440 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
10441 }
10442
10444 {
10445 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
10446 }
10447
10449 void AddLightSourceItem(ItemBase lightsource)
10450 {
10451 m_LightSourceItem = lightsource;
10452 }
10453
10455 {
10456 m_LightSourceItem = null;
10457 }
10458
10460 {
10461 return m_LightSourceItem;
10462 }
10463
10465 array<int> GetValidFinishers()
10466 {
10467 return null;
10468 }
10469
10471 bool GetActionWidgetOverride(out typename name)
10472 {
10473 return false;
10474 }
10475
10476 bool PairWithDevice(notnull ItemBase otherDevice)
10477 {
10478 if (g_Game.IsServer())
10479 {
10480 ItemBase explosive = otherDevice;
10482 if (!trg)
10483 {
10484 trg = RemoteDetonatorTrigger.Cast(otherDevice);
10485 explosive = this;
10486 }
10487
10488 explosive.PairRemote(trg);
10489 trg.SetControlledDevice(explosive);
10490
10491 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
10492 trg.SetPersistentPairID(persistentID);
10493 explosive.SetPersistentPairID(persistentID);
10494
10495 return true;
10496 }
10497 return false;
10498 }
10499
10501 float GetBaitEffectivity()
10502 {
10503 float ret = 1.0;
10504 if (HasQuantity())
10505 ret *= GetQuantityNormalized();
10506 ret *= GetHealth01();
10507
10508 return ret;
10509 }
10510
10511 #ifdef DEVELOPER
10512 override void SetDebugItem()
10513 {
10514 super.SetDebugItem();
10515 _itemBase = this;
10516 }
10517
10518 override string GetDebugText()
10519 {
10520 string text = super.GetDebugText();
10521
10522 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
10523 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
10524
10525 return text;
10526 }
10527 #endif
10528
10529 bool CanBeUsedForSuicide()
10530 {
10531 return true;
10532 }
10533
10535 //DEPRECATED BELOW
10537 // Backwards compatibility
10538 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10539 {
10540 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
10541 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
10542 }
10543
10544 // replaced by ItemSoundHandler
10545 protected EffectSound m_SoundDeployFinish;
10546 protected EffectSound m_SoundPlace;
10547 protected EffectSound m_DeployLoopSoundEx;
10548 protected EffectSound m_SoundDeploy;
10549 bool m_IsPlaceSound;
10550 bool m_IsDeploySound;
10552
10553 string GetDeployFinishSoundset();
10554 void PlayDeploySound();
10555 void PlayDeployFinishSound();
10556 void PlayPlaceSound();
10557 void PlayDeployLoopSoundEx();
10558 void StopDeployLoopSoundEx();
10559 void SoundSynchRemoteReset();
10560 void SoundSynchRemote();
10561 bool UsesGlobalDeploy(){return false;}
10562 bool CanPlayDeployLoopSound(){return false;}
10564 bool IsPlaceSound(){return m_IsPlaceSound;}
10565 bool IsDeploySound(){return m_IsDeploySound;}
10566 void SetIsPlaceSound(bool is_place_sound);
10567 void SetIsDeploySound(bool is_deploy_sound);
10568
10569 [Obsolete("Use ItemSoundHandler instead")]
10571 void PlayAttachSound(string slot_type)
10572 {
10573 if (!g_Game.IsDedicatedServer())
10574 {
10575 if (ConfigIsExisting("attachSoundSet"))
10576 {
10577 string cfg_path = "";
10578 string soundset = "";
10579 string type_name = GetType();
10580
10581 TStringArray cfg_soundset_array = new TStringArray;
10582 TStringArray cfg_slot_array = new TStringArray;
10583 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
10584 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
10585
10586 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
10587 {
10588 for (int i = 0; i < cfg_soundset_array.Count(); i++)
10589 {
10590 if (cfg_slot_array[i] == slot_type)
10591 {
10592 soundset = cfg_soundset_array[i];
10593 break;
10594 }
10595 }
10596 }
10597
10598 if (soundset != "")
10599 {
10600 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
10601 sound.SetAutodestroy(true);
10602 }
10603 }
10604 }
10605 }
10606
10607 void PlayDetachSound(string slot_type) {}
10608}
10609
10610EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
10611{
10612 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
10613 if (entity)
10614 {
10615 bool is_item = entity.IsInherited(ItemBase);
10616 if (is_item && full_quantity)
10617 {
10618 ItemBase item = ItemBase.Cast(entity);
10619 item.SetQuantity(item.GetQuantityInit());
10620 }
10621 }
10622 else
10623 {
10624 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
10625 return NULL;
10626 }
10627 return entity;
10628}
10629
10630void SetupSpawnedItem(ItemBase item, float health, float quantity)
10631{
10632 if (item)
10633 {
10634 if (health > 0)
10635 item.SetHealth("", "", health);
10636
10637 if (item.CanHaveTemperature())
10638 {
10639 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
10640 if (item.CanFreeze())
10641 item.SetFrozen(false);
10642 }
10643
10644 if (item.HasEnergyManager())
10645 {
10646 if (quantity >= 0)
10647 {
10648 item.GetCompEM().SetEnergy0To1(quantity);
10649 }
10650 else
10651 {
10652 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
10653 }
10654 }
10655 else if (item.IsMagazine())
10656 {
10657 Magazine mag = Magazine.Cast(item);
10658 if (quantity >= 0)
10659 {
10660 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
10661 }
10662 else
10663 {
10664 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
10665 }
10666
10667 }
10668 else
10669 {
10670 if (quantity >= 0)
10671 {
10672 item.SetQuantityNormalized(quantity, false);
10673 }
10674 else
10675 {
10676 item.SetQuantity(Math.AbsFloat(quantity));
10677 }
10678
10679 }
10680 }
10681}
10682
10683#ifdef DEVELOPER
10684ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
10685#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Param3 TSelectableActionInfo
EWetnessLevel
Определения 3_Game/DayZ/Entities/EntityAI.c:2
bool SetAttachSoundEvent()
void InventoryItemType()
bool SetDetachSoundEvent()
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
const int INPUT_UDT_ITEM_MANIPULATION
class LogManager EntityAI
eBleedingSourceType GetType()
ItemSuppressor SuppressorBase
void ActionDropItem()
Определения ActionDropItem.c:34
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Определения ActionManagerClient.c:1
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void RemoveAction(typename actionName)
Определения AdvancedCommunication.c:252
TInputActionMap m_InputActionMap
Определения AdvancedCommunication.c:137
bool m_ActionsInitialize
Определения AdvancedCommunication.c:138
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Определения AdvancedCommunication.c:202
void InitializeActions()
Определения AdvancedCommunication.c:190
string Debug()
Определения CachedEquipmentStorageBase.c:29
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:36
const int RF_DEFAULT
Определения CentralEconomy.c:65
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
Open
Implementations only.
override void EEOnCECreate()
Определения ContaminatedArea_Dynamic.c:42
map
Определения ControlsXboxNew.c:4
CookingMethodType
Определения Cooking.c:2
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
DayZGame g_Game
Определения DayZGame.c:3942
DayZGame GetDayZGame()
Определения DayZGame.c:3944
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
PluginAdminLog m_AdminLog
Определения EmoteManager.c:159
const int MIN
Определения EnConvert.c:28
const int MAX
Определения EnConvert.c:27
float GetTemperature()
Определения Environment.c:500
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool IsPrepareToDelete()
Определения FireplaceBase.c:643
override bool CanHaveTemperature()
Определения FireplaceBase.c:561
class GP5GasMask extends MaskBase ItemBase
proto GizmoApi GetGizmoApi()
Empty
Определения Hand_States.c:14
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool DamageItemInCargo(float damage)
Определения ItemBase.c:6453
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5680
bool HidesSelectionBySlot()
Определения ItemBase.c:9413
float m_VarWetMin
Определения ItemBase.c:4937
void SplitItem(PlayerBase player)
Определения ItemBase.c:6908
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9634
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8895
override float GetQuantityNormalized()
Gets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8330
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5685
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:9038
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6875
override bool IsHeavyBehaviour()
Определения ItemBase.c:9240
override void SetWetMax()
Определения ItemBase.c:8616
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9451
void ClearStartItemSoundServer()
Определения ItemBase.c:9390
float m_VarWet
Определения ItemBase.c:4934
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9481
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:3
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8890
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4997
bool CanBeMovedOverride()
Определения ItemBase.c:7600
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8592
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4983
void StartItemSoundServer(int id, int slotId)
Определения ItemBase.c:9358
override void ProcessVariables()
Определения ItemBase.c:9548
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:5011
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8423
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8956
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8806
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5271
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:5009
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9584
bool m_IsSoundSynchRemote
Определения ItemBase.c:9742
float m_OverheatingShots
Определения ItemBase.c:5004
void StopItemSoundServer(int id)
Определения ItemBase.c:9378
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5700
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5424
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9608
ref array< int > m_CompatibleLocks
Определения ItemBase.c:5021
bool CanBeCooked()
Определения ItemBase.c:7556
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5767
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:5035
bool m_RecipesInitialized
Определения ItemBase.c:4919
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6546
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9592
override void OnEnergyConsumed()
Определения ItemBase.c:8536
void RefreshAudioVisualsOnClient(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
cooking-related effect methods
Определения Bottle_Base.c:158
int GetNumberOfItems()
Returns the number of items in cargo, otherwise returns 0(non-cargo objects). Recursive.
Определения ItemBase.c:8462
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8656
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8418
ref TIntArray m_InteractActions
Определения ItemBase.c:4985
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7620
float m_VarQuantity
Определения ItemBase.c:4925
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9753
override float GetWetMax()
Определения ItemBase.c:8626
bool CanBeUsedForSuicide()
Определения ItemBase.c:9720
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7193
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5905
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7774
void DoAmmoExplosion()
Определения ItemBase.c:6388
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4996
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6732
int GetItemSize()
Определения ItemBase.c:7585
bool m_CanBeMovedOverride
Определения ItemBase.c:4962
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6312
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5492
bool CanDecay()
Определения ItemBase.c:9523
ScriptedLightBase GetLight()
string GetPlaceSoundset()
bool AddQuantity(float value, bool destroy_config=true, bool destroy_forced=false)
add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Определения ItemBase.c:8303
void SetQuantityMax()
Определения ItemBase.c:8308
override float GetQuantity()
Определения ItemBase.c:8398
int m_ColorComponentR
Определения ItemBase.c:4974
int m_ShotsToStartOverheating
Определения ItemBase.c:5006
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8641
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5499
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9139
void OnOverheatingDecay()
Определения ItemBase.c:5462
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8574
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4940
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5600
bool UsesGlobalDeploy()
Определения ItemBase.c:9752
int m_ItemBehaviour
Определения ItemBase.c:4955
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:9111
float m_HeatIsolation
Определения ItemBase.c:4950
float m_VarWetInit
Определения ItemBase.c:4936
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5945
void SetCEBasedQuantity()
Определения ItemBase.c:5713
bool m_CanPlayImpactSound
Определения ItemBase.c:4946
override string GetAttachmentSoundType()
Определения ItemBase.c:9314
float GetOverheatingCoef()
Определения ItemBase.c:5519
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9408
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9762
override bool IsStoreLoad()
Определения ItemBase.c:8668
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7169
bool IsLightSource()
Определения ItemBase.c:5841
bool m_HasQuantityBar
Определения ItemBase.c:4968
void SetResultOfSplit(bool value)
Определения ItemBase.c:7164
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6796
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6965
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5527
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8583
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9219
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8678
int m_LockType
Определения ItemBase.c:5022
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:5027
bool m_CanBeDigged
Определения ItemBase.c:4969
float m_ItemAttachOffset
Определения ItemBase.c:4952
float GetItemModelLength()
Определения ItemBase.c:8685
bool m_ThrowItemOnDrop
Определения ItemBase.c:4960
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7919
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8971
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8569
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7198
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9579
bool CanHaveWetness()
Определения ItemBase.c:9536
int m_CleannessMin
Определения ItemBase.c:4942
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8904
string IDToName(int id)
Определения ItemBase.c:7767
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9543
float GetHeatIsolationInit()
Определения ItemBase.c:8564
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7607
override bool HasQuantity()
Определения ItemBase.c:8393
float m_VarWetPrev
Определения ItemBase.c:4935
int m_SoundSyncStop
Определения ItemBase.c:5029
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9629
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4984
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5609
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5294
int m_VarLiquidType
Определения ItemBase.c:4954
int m_QuickBarBonus
Определения ItemBase.c:4956
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9302
override float GetWetInit()
Определения ItemBase.c:8636
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4948
int m_SoundSyncPlay
Определения ItemBase.c:5028
int m_MaxOverheatingValue
Определения ItemBase.c:5007
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4931
bool m_IsTakeable
Определения ItemBase.c:4959
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:6503
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4999
string GetLockSoundSet()
Определения ItemBase.c:8734
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8765
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9656
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6971
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4911
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9329
override int GetQuantityMin()
Определения ItemBase.c:8382
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6711
override int GetQuickBarBonus()
Определения ItemBase.c:5179
override void SetTakeable(bool pState)
Определения ItemBase.c:9284
float m_OverheatingDecayInterval
Определения ItemBase.c:5008
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6523
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9501
bool CanProcessDecay()
Определения ItemBase.c:9529
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5690
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9645
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7571
bool can_this_be_combined
Определения ItemBase.c:4964
EffectSound m_SoundDeploy
Определения ItemBase.c:9739
int m_SoundSyncSlotID
Определения ItemBase.c:5030
int m_Count
Определения ItemBase.c:4930
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9692
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9276
override bool IsSplitable()
Определения ItemBase.c:6490
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6473
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7883
void ConvertEnergyToQuantity()
Определения ItemBase.c:8551
override void RemoveAllAgents()
Определения ItemBase.c:8885
override void SetQuantityToMinimum()
Определения ItemBase.c:8314
bool m_WantPlayImpactSound
Определения ItemBase.c:4945
override float GetTemperatureThawTime()
Определения ItemBase.c:9616
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4998
int m_ColorComponentG
Определения ItemBase.c:4975
float m_StoreLoadedQuantity
Определения ItemBase.c:4932
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7638
int m_ColorComponentA
Определения ItemBase.c:4977
int m_VarQuantityInit
Определения ItemBase.c:4927
float GetFilterDamageRatio()
Определения ItemBase.c:5594
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8778
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6942
void OnApply(PlayerBase player)
override void SetQuantityNormalized(float value, bool destroy_config=true, bool destroy_forced=false)
Sets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8321
bool m_HideSelectionsBySlot
Определения ItemBase.c:5012
bool IsOverheatingEffectActive()
Определения ItemBase.c:5457
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5874
int GetLiquidContainerMask()
Определения ItemBase.c:5811
void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
Определения ItemBase.c:7078
ref Timer m_CheckOverheating
Определения ItemBase.c:5005
void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
Определения ItemBase.c:5505
float GetEnergy()
Определения ItemBase.c:8525
bool CanBeDigged()
Определения ItemBase.c:5890
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9662
bool IsNVG()
Определения ItemBase.c:5822
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8485
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9438
bool m_IsDeploySound
Определения ItemBase.c:9741
bool CanEat()
Определения ItemBase.c:7531
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9179
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9250
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9640
bool IsLiquidContainer()
Определения ItemBase.c:5806
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7551
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8409
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8963
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8363
int m_CleannessInit
Определения ItemBase.c:4941
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5589
override int GetAgents()
Определения ItemBase.c:8910
int m_VarQuantityMax
Определения ItemBase.c:4929
override bool IsHologram()
Определения ItemBase.c:5885
float GetItemAttachOffset()
Определения ItemBase.c:8694
bool IsPlaceSound()
Определения ItemBase.c:9755
static int GetDebugActionsMask()
Определения ItemBase.c:5675
override int GetLiquidType()
Определения ItemBase.c:8794
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9518
override bool IsItemBase()
Определения ItemBase.c:7684
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9260
void ExplodeAmmo()
Определения ItemBase.c:6375
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:7154
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8984
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9159
override void OnEnergyAdded()
Определения ItemBase.c:8543
void AffectLiquidContainerOnFill(int liquid_type, float amount)
from enviro source
void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature)
from other liquid container source
string GetExplosiveTriggerSlotName()
Определения ItemBase.c:5834
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9738
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7824
void StopItemDynamicPhysics()
Определения ItemBase.c:9420
bool HasFoodStage()
Определения ItemBase.c:7544
override void SetStoreLoad(bool value)
Определения ItemBase.c:8663
float GetOverheatingValue()
Определения ItemBase.c:5419
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8863
override void AddWet(float value)
Определения ItemBase.c:8611
bool IsLiquidPresent()
Определения ItemBase.c:5801
bool IsFullQuantity()
Определения ItemBase.c:8403
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:6084
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6847
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6823
int m_CleannessMax
Определения ItemBase.c:4943
float m_VarStackMax
Определения ItemBase.c:4931
ref Timer m_PhysDropTimer
Определения ItemBase.c:5018
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7656
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8673
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4972
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5440
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5755
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7578
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8799
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5486
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8721
bool m_IsOverheatingEffectActive
Определения ItemBase.c:5003
int m_LiquidContainerMask
Определения ItemBase.c:4953
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9456
override int GetCleanness()
Определения ItemBase.c:8716
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9667
bool IsDeploySound()
Определения ItemBase.c:9756
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5695
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9199
int m_VarQuantityMin
Определения ItemBase.c:4928
void PerformDamageSystemReinit()
Определения ItemBase.c:9426
override void ClearInventory()
Определения ItemBase.c:8504
static int m_LastRegisteredWeaponID
Определения ItemBase.c:5000
ItemBase GetLightSourceItem()
Определения ItemBase.c:9650
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7674
override float GetItemOverheatThreshold()
Определения ItemBase.c:9600
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4965
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7788
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6762
float m_ItemModelLength
Определения ItemBase.c:4951
bool m_IsHologram
Определения ItemBase.c:4958
static int m_DebugActionsMask
Определения ItemBase.c:4918
void KillAllOverheatingParticles()
Определения ItemBase.c:5555
bool CanBeCookedOnStick()
Определения ItemBase.c:7561
override int GetQuantityMax()
Определения ItemBase.c:8349
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7232
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8759
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8876
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4961
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:9066
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9798
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4912
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9729
override bool IsBeingPlaced()
Определения ItemBase.c:5869
int GetQuantityInit()
Определения ItemBase.c:8387
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7174
bool IsResultOfSplit()
Определения ItemBase.c:7159
bool m_FixDamageSystemInit
Определения ItemBase.c:4963
float m_ImpactSpeed
Определения ItemBase.c:4947
bool m_IsStoreLoad
Определения ItemBase.c:4966
int GetLiquidTypeInit()
Определения ItemBase.c:8789
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4981
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5742
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6633
int m_AttachedAgents
Определения ItemBase.c:4989
string m_LockSoundSet
Определения ItemBase.c:5024
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5363
float m_VarQuantityPrev
Определения ItemBase.c:4926
bool IsSoundSynchRemote()
Определения ItemBase.c:9754
bool m_CanShowQuantity
Определения ItemBase.c:4967
override void OnRightClick()
Определения ItemBase.c:7014
int m_ColorComponentB
Определения ItemBase.c:4976
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4914
bool IsActionTargetVisible()
Определения ItemBase.c:9296
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:6119
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6412
bool m_IsBeingPlaced
Определения ItemBase.c:4957
int NameToID(string name)
Определения ItemBase.c:7761
void ~ItemBase()
Определения ItemBase.c:5640
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8651
void ClearStopItemSoundServer()
Определения ItemBase.c:9396
override string ChangeIntoOnDetach()
Определения ItemBase.c:6336
float m_VarWetMax
Определения ItemBase.c:4938
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6757
int GetLockType()
Определения ItemBase.c:8729
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9736
override float GetWet()
Определения ItemBase.c:8621
EffectSound m_SoundPlace
Определения ItemBase.c:9737
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8335
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8703
bool m_IsPlaceSound
Определения ItemBase.c:9740
override float GetWetMin()
Определения ItemBase.c:8631
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:5032
override bool KindOf(string tag)
Определения ItemBase.c:7690
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
string Type
Определения JsonDataContaminatedArea.c:11
EffectSound m_LockingSound
Определения Land_Underground_Entrance.c:336
string GetDebugText()
Определения ModifierBase.c:71
@ LOWEST
Определения PPEConstants.c:54
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:325
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Определения RemoteDetonator.c:272
void RemoteDetonatorTrigger()
Определения RemoteDetonator.c:233
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Определения RemoteDetonator.c:305
int particle_id
Определения SmokeSimulation.c:28
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
override void Explode(int damageType, string ammoType="")
Определения Trap_LandMine.c:220
bool m_Initialized
Определения UiHintPanel.c:317
int GetID()
Определения ActionBase.c:1335
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:974
GetInputType()
Определения ActionBase.c:221
int m_StanceMask
Определения ActionBase.c:25
int m_CommandUIDProne
Определения ActionBase.c:24
int m_CommandUID
Определения ActionBase.c:23
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
float GetEnergyAtSpawn()
Определения ComponentEnergyManager.c:1325
void SetEnergy0To1(float energy01)
Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value be...
Определения ComponentEnergyManager.c:550
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Определения ComponentEnergyManager.c:1320
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:603
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
Определения EffectSound.c:274
override bool IsMan()
Определения 3_Game/DayZ/Entities/Man.c:48
proto native EntityAI GetAttachmentFromIndex(int index)
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
proto native int AttachmentCount()
Returns count of attachments attached to this item.
proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
proto void SelectObject(Object object)
proto void SelectPhysics(Physics physics)
Определения ItemBase.c:21
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetCol()
returns column of cargo if current type is Cargo / ProxyCargo
proto native int GetRow()
returns row of cargo if current type is Cargo / ProxyCargo
bool WriteToContext(ParamsWriteContext ctx)
Определения InventoryLocation.c:507
proto native int GetType()
returns type of InventoryLocation
proto native int GetIdx()
returns index of cargo if current type is Cargo / ProxyCargo
proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
sets current inventory location type to Cargo with coordinates (idx, row, col)
proto native bool GetFlip()
returns flip status of cargo
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:30
override bool CanDisplayCargo()
Определения TentBase.c:91
override void OnInventoryEnter(Man player)
Определения BarbedWire.c:203
override string GetFoldSoundset()
Определения BaseBuildingBase.c:108
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:7
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:934
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения GardenBase.c:199
override void OnWasDetached(EntityAI parent, int slot_id)
override void EEOnAfterLoad()
Определения GardenBase.c:242
override void EEDelete(EntityAI parent)
Определения BaseBuildingBase.c:68
override bool CanBeRepairedByCrafting()
Определения TentBase.c:86
override void OnPlacementStarted(Man player)
Определения BatteryCharger.c:376
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Определения BarbedWire.c:357
override bool IsElectricAppliance()
Определения BatteryCharger.c:43
override bool IsItemTent()
Определения TentBase.c:81
override string GetLoopFoldSoundset()
Определения BaseBuildingBase.c:113
override bool CanMakeGardenplot()
Определения FieldShovel.c:3
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения PowerGenerator.c:397
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения HandcuffsLocked.c:12
override WrittenNoteData GetWrittenNoteData()
Определения Paper.c:30
override int GetDamageSystemVersionChange()
Определения BaseBuildingBase.c:1238
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
override void InitItemVariables()
Определения Matchbox.c:3
override void SetActionAnimOverrides()
Определения PickAxe.c:28
override void OnCreatePhysics()
Определения BaseBuildingBase.c:489
override string GetDeploySoundset()
Определения BarbedWire.c:392
override float GetBandagingEffectivity()
Определения BandageDressing.c:49
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения PowerGenerator.c:409
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения BaseBuildingBase.c:496
override void OnStoreSave(ParamsWriteContext ctx)
Определения GardenBase.c:266
override void AfterStoreLoad()
Определения BarbedWire.c:155
override int GetOnDigWormsAmount()
Определения FieldShovel.c:27
override bool IsSelfAdjustingTemperature()
Определения PortableGasStove.c:287
override bool IsPlayerInside(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1037
override void OnVariablesSynchronized()
Определения GardenBase.c:97
override void RefreshPhysics()
Определения BatteryCharger.c:359
override bool CanObstruct()
Определения BaseBuildingBase.c:84
override void OnWasAttached(EntityAI parent, int slot_id)
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения BaseBuildingBase.c:982
override bool CanPutInCargo(EntityAI parent)
Определения GardenBase.c:331
override string GetLoopDeploySoundset()
Определения BarbedWire.c:397
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Определения BarbedWire.c:372
override void OnInventoryExit(Man player)
Определения BatteryCharger.c:341
override bool IsTakeable()
Определения BaseBuildingBase.c:1008
override bool IsIgnoredByConstruction()
Определения BaseBuildingBase.c:1170
override void InitItemSounds()
Определения BaseBuildingBase.c:94
override void EEKilled(Object killer)
Определения HandcuffsLocked.c:70
override void OnCombine(ItemBase other_item)
Определения BandageDressing.c:71
override bool CanExplodeInFire()
Определения LargeGasCannister.c:3
override bool IsFacingPlayer(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1032
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Определения Rag.c:61
override bool IsBloodContainer()
Определения BloodContainerBase.c:10
override bool CanBeSplit()
Определения Rag.c:34
override bool IsDeployable()
Определения BaseBuildingBase.c:365
override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения ToolBase.c:24
override bool CanBeDisinfected()
Определения BandageDressing.c:54
override float GetInfectionChance(int system=0, Param param=null)
Определения BandageDressing.c:59
override void OnEndPlacement()
Определения KitBase.c:65
Определения ItemBase.c:14
Определения EnMath.c:7
float GetOverheatingLimitMax()
Определения WeaponParticles.c:417
void SetOverheatingLimitMax(float max)
Определения WeaponParticles.c:407
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
Определения WeaponParticles.c:422
float GetOverheatingLimitMin()
Определения WeaponParticles.c:412
Particle GetParticle()
Определения WeaponParticles.c:397
void SetOverheatingLimitMin(float min)
Определения WeaponParticles.c:402
void RegisterParticle(Particle p)
Определения WeaponParticles.c:392
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Определения Particle.c:266
void SetControlledDevice(EntityAI pDevice)
Определения RemoteDetonator.c:140
bool OnStoreLoad(ParamsReadContext ctx, int version)
void OnStoreSave(ParamsWriteContext ctx)
proto native void Send()
proto bool Write(void value_out)
proto bool Read(void value_in)
bool m_Loop
Определения ItemSoundHandler.c:5
override void Stop()
Определения DayZPlayerImplement.c:40
proto native float GetDamage(string zoneName, string healthType)
override void Refresh()
Определения ChatInputMenu.c:70
void SetCalcDetails(string details)
Определения 3_Game/DayZ/tools/Debug.c:916
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения WrittenNoteData.c:13
const float LOWEST
Определения EnConvert.c:113
Serializer ParamsReadContext
Определения gameplay.c:15
class LOD Object
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Определения gameplay.c:6
Serializer ParamsWriteContext
Определения gameplay.c:16
const int DEF_BIOLOGICAL
Определения 3_Game/DayZ/constants.c:515
const int DEF_CHEMICAL
Определения 3_Game/DayZ/constants.c:516
const int COMP_TYPE_ENERGY_MANAGER
Определения Component.c:9
ErrorExSeverity
Определения EnDebug.c:62
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
enum ShapeType ErrorEx
proto native void SetColor(int color)
array< string > TStringArray
Определения EnScript.c:712
array< int > TIntArray
Определения EnScript.c:714
void Obsolete(string msg="")
Определения EnScript.c:371
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/DayZ/constants.c:811
const int VARIABLE_LIQUIDTYPE
Определения 3_Game/DayZ/constants.c:635
const int VARIABLE_CLEANNESS
Определения 3_Game/DayZ/constants.c:638
const int VARIABLE_COLOR
Определения 3_Game/DayZ/constants.c:637
const int VARIABLE_TEMPERATURE
Определения 3_Game/DayZ/constants.c:633
const int VARIABLE_QUANTITY
Определения 3_Game/DayZ/constants.c:631
const int VARIABLE_WET
Определения 3_Game/DayZ/constants.c:634
const int LIQUID_NONE
Определения 3_Game/DayZ/constants.c:532
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения 3_Game/DayZ/constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения 3_Game/DayZ/constants.c:456
const int SAT_DEBUG_ACTION
Определения 3_Game/DayZ/constants.c:457
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
const int CALL_CATEGORY_GAMEPLAY
Определения 3_Game/DayZ/tools/tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/DayZ/tools/tools.c:8
proto native int GetColor()