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

◆ GetOverheatingCoef()

float SpawnItemOnLocation::GetOverheatingCoef ( )
private

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

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

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