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

◆ IsBeingPlaced()

override bool SpawnItemOnLocation::IsBeingPlaced ( )
private

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

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

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