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

◆ ~ItemBase()

void SpawnItemOnLocation::~ItemBase ( )
private

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

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