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

◆ OnItemLocationChanged()

override void SpawnItemOnLocation::OnItemLocationChanged ( EntityAI old_owner,
EntityAI new_owner )
private

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

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

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