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

◆ CanBeRepairedByCrafting()

bool SpawnItemOnLocation::CanBeRepairedByCrafting ( )
private

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

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