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

◆ EEKilled()

override void SpawnItemOnLocation::EEKilled ( Object killer)
private

item is able to explode in fire

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

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