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

◆ IsBeingPlaced()

override bool SpawnItemOnLocation::IsBeingPlaced ( )
private

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

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

Используется в OnInventoryExit(), ItemBase::OnItemLocationChanged() и FireplaceBase::OnVariablesSynchronized().