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

◆ CanBeDigged()

bool SpawnItemOnLocation::CanBeDigged ( )
private

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

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