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

◆ SetIsBeingPlaced()

void SpawnItemOnLocation::SetIsBeingPlaced ( bool is_being_placed)
private

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

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