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

◆ OnCreatePhysics()

override void SpawnItemOnLocation::OnCreatePhysics ( )
private

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

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