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

◆ OnItemAttachmentSlotChanged()

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

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

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

Используется в Entity::EEItemLocationChanged().