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

◆ IsHologram()

override bool SpawnItemOnLocation::IsHologram ( )
private

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

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

Используется в ItemBase::AssembleKit(), IEntity::CanBeActionTarget(), Entity::CanPutAsAttachment(), Entity::CanPutInCargo(), Entity::CanPutIntoHands(), KitBase::DisassembleKit(), ItemBase::EOnInit(), ItemBase::Pack(), RefreshFireplaceVisuals() и ItemBase::UpdateAllSelections().