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

◆ GetDamageSystemVersionChange()

override int GetDamageSystemVersionChange ( )
private

Re-sets DamageSystem changes.

Возвращает
storage version on which the config changes occured (default -1, to be overriden!)
Заметки
Significant changes to DamageSystem in item configs have to be re-set by increasing the storage version and overriding this method. Default return is -1 (does nothing).

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

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