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

◆ GetOnDigWormsAmount()

int SpawnItemOnLocation::GetOnDigWormsAmount ( )
private

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

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