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

◆ EEItemLocationChanged()

override void SpawnItemOnLocation::EEItemLocationChanged ( notnull InventoryLocation oldLoc,
notnull InventoryLocation newLoc )
private

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

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