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

◆ AfterStoreLoad()

override void SpawnItemOnLocation::AfterStoreLoad ( )
protected

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

8065{
8066 override bool CanPutAsAttachment(EntityAI parent)
8067 {
8068 return true;
8069 }
8070};
8071
8072//const bool QUANTITY_DEBUG_REMOVE_ME = false;
8073
8074class ItemBase extends InventoryItem
8075{
8079
8081
8082 static int m_DebugActionsMask;
8084 // ============================================
8085 // Variable Manipulation System
8086 // ============================================
8087 // Quantity
8088
8089 float m_VarQuantity;
8090 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
8092 int m_VarQuantityMin;
8093 int m_VarQuantityMax;
8094 int m_Count;
8095 float m_VarStackMax;
8096 float m_StoreLoadedQuantity = float.LOWEST;
8097 // Wet
8098 float m_VarWet;
8099 float m_VarWetPrev;//for client to know wetness changed during synchronization
8100 float m_VarWetInit;
8101 float m_VarWetMin;
8102 float m_VarWetMax;
8103 // Cleanness
8104 int m_Cleanness;
8105 int m_CleannessInit;
8106 int m_CleannessMin;
8107 int m_CleannessMax;
8108 // impact sounds
8110 bool m_CanPlayImpactSound = true;
8111 float m_ImpactSpeed;
8113 //
8114 float m_HeatIsolation;
8115 float m_ItemModelLength;
8116 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
8118 int m_VarLiquidType;
8119 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
8120 int m_QuickBarBonus;
8121 bool m_IsBeingPlaced;
8122 bool m_IsHologram;
8123 bool m_IsTakeable;
8124 bool m_ThrowItemOnDrop;
8127 bool m_FixDamageSystemInit = false; //can be changed on storage version check
8128 bool can_this_be_combined; //Check if item can be combined
8129 bool m_CanThisBeSplit; //Check if item can be split
8130 bool m_IsStoreLoad = false;
8131 bool m_CanShowQuantity;
8132 bool m_HasQuantityBar;
8133 protected bool m_CanBeDigged;
8134 protected bool m_IsResultOfSplit
8135
8136 string m_SoundAttType;
8137 // items color variables
8142 //-------------------------------------------------------
8143
8144 // light source managing
8146
8150
8151 //==============================================
8152 // agent system
8153 private int m_AttachedAgents;
8154
8156 void TransferModifiers(PlayerBase reciever);
8157
8158
8159 // Weapons & suppressors particle effects
8164 static int m_LastRegisteredWeaponID = 0;
8165
8166 // Overheating effects
8168 float m_OverheatingShots;
8169 ref Timer m_CheckOverheating;
8170 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
8171 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
8172 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
8173 ref array <ref OverheatingParticle> m_OverheatingParticles;
8174
8176 protected bool m_HideSelectionsBySlot;
8177
8178 // Admin Log
8179 PluginAdminLog m_AdminLog;
8180
8181 // misc
8182 ref Timer m_PhysDropTimer;
8183
8184 // Attachment Locking variables
8185 ref array<int> m_CompatibleLocks;
8186 protected int m_LockType;
8187 protected ref EffectSound m_LockingSound;
8188 protected string m_LockSoundSet;
8189
8190 // ItemSoundHandler
8191 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
8192 protected int m_SoundSyncPlay; // id for sound to play
8193 protected int m_SoundSyncStop; // id for sound to stop
8195
8196 //temperature
8197 private float m_TemperaturePerQuantityWeight;
8198
8199 // -------------------------------------------------------------------------
8200 void ItemBase()
8201 {
8202 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
8206
8207 if (!GetGame().IsDedicatedServer())
8208 {
8209 if (HasMuzzle())
8210 {
8212
8214 {
8216 }
8217 }
8218
8220 m_ActionsInitialize = false;
8221 }
8222
8223 m_OldLocation = null;
8224
8225 if (GetGame().IsServer())
8226 {
8227 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
8228 }
8229
8230 if (ConfigIsExisting("headSelectionsToHide"))
8231 {
8233 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
8234 }
8235
8236 m_HideSelectionsBySlot = false;
8237 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
8238 {
8239 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
8240 }
8241
8242 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
8243
8244 m_IsResultOfSplit = false;
8245
8247 }
8248
8249 override void InitItemVariables()
8250 {
8251 super.InitItemVariables();
8252
8253 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
8254 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
8255 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
8256 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
8257 m_VarStackMax = ConfigGetFloat("varStackMax");
8258 m_Count = ConfigGetInt("count");
8259
8260 m_CanShowQuantity = ConfigGetBool("quantityShow");
8261 m_HasQuantityBar = ConfigGetBool("quantityBar");
8262
8263 m_CleannessInit = ConfigGetInt("varCleannessInit");
8265 m_CleannessMin = ConfigGetInt("varCleannessMin");
8266 m_CleannessMax = ConfigGetInt("varCleannessMax");
8267
8268 m_WantPlayImpactSound = false;
8269 m_ImpactSpeed = 0.0;
8270
8271 m_VarWetInit = ConfigGetFloat("varWetInit");
8273 m_VarWetMin = ConfigGetFloat("varWetMin");
8274 m_VarWetMax = ConfigGetFloat("varWetMax");
8275
8276 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
8277 if (IsLiquidContainer() && GetQuantity() != 0)
8279 m_IsBeingPlaced = false;
8280 m_IsHologram = false;
8281 m_IsTakeable = true;
8282 m_CanBeMovedOverride = false;
8286 m_CanBeDigged = ConfigGetBool("canBeDigged");
8287
8288 m_CompatibleLocks = new array<int>();
8289 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
8290 m_LockType = ConfigGetInt("lockType");
8291
8292 //Define if item can be split and set ability to be combined accordingly
8293 m_CanThisBeSplit = false;
8294 can_this_be_combined = false;
8295 if (ConfigIsExisting("canBeSplit"))
8296 {
8297 can_this_be_combined = ConfigGetBool("canBeSplit");
8299 }
8300
8301 m_ItemBehaviour = -1;
8302 if (ConfigIsExisting("itemBehaviour"))
8303 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
8304
8305 //RegisterNetSyncVariableInt("m_VariablesMask");
8306 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8307 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
8308 RegisterNetSyncVariableInt("m_VarLiquidType");
8309 RegisterNetSyncVariableInt("m_Cleanness",0,1);
8310
8311 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
8312 RegisterNetSyncVariableFloat("m_ImpactSpeed");
8313 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
8314
8315 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
8316 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
8317 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
8318 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
8319
8320 RegisterNetSyncVariableBool("m_IsBeingPlaced");
8321 RegisterNetSyncVariableBool("m_IsTakeable");
8322 RegisterNetSyncVariableBool("m_IsHologram");
8323
8324 InitItemSounds();
8326 {
8327 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
8328 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
8329 }
8330
8331 m_LockSoundSet = ConfigGetString("lockSoundSet");
8332
8334 if (ConfigIsExisting("temperaturePerQuantityWeight"))
8335 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
8336
8337 }
8338
8339 override int GetQuickBarBonus()
8340 {
8341 return m_QuickBarBonus;
8342 }
8343
8344 void InitializeActions()
8345 {
8347 if (!m_InputActionMap)
8348 {
8350 m_InputActionMap = iam;
8351 SetActions();
8353 }
8354 }
8355
8356 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
8357 {
8359 {
8360 m_ActionsInitialize = true;
8362 }
8363
8364 actions = m_InputActionMap.Get(action_input_type);
8365 }
8366
8367 void SetActions()
8368 {
8369 AddAction(ActionTakeItem);
8370 AddAction(ActionTakeItemToHands);
8371 AddAction(ActionWorldCraft);
8373 AddAction(ActionAttachWithSwitch);
8374 }
8375
8376 void SetActionAnimOverrides(); // Override action animation for specific item
8377
8378 void AddAction(typename actionName)
8379 {
8380 ActionBase action = ActionManagerBase.GetAction(actionName);
8381
8382 if (!action)
8383 {
8384 Debug.LogError("Action " + actionName + " dosn't exist!");
8385 return;
8386 }
8387
8388 typename ai = action.GetInputType();
8389 if (!ai)
8390 {
8391 m_ActionsInitialize = false;
8392 return;
8393 }
8394
8395 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8396 if (!action_array)
8397 {
8398 action_array = new array<ActionBase_Basic>;
8399 m_InputActionMap.Insert(ai, action_array);
8400 }
8401 if (LogManager.IsActionLogEnable())
8402 {
8403 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
8404 }
8405
8406 if (action_array.Find(action) != -1)
8407 {
8408 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
8409 }
8410 else
8411 {
8412 action_array.Insert(action);
8413 }
8414 }
8415
8416 void RemoveAction(typename actionName)
8417 {
8418 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
8419 ActionBase action = player.GetActionManager().GetAction(actionName);
8420 typename ai = action.GetInputType();
8421 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8422
8423 if (action_array)
8424 {
8425 action_array.RemoveItem(action);
8426 }
8427 }
8428
8429 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
8430 // Set -1 for params which should stay in default state
8431 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
8432 {
8433 ActionOverrideData overrideData = new ActionOverrideData();
8434 overrideData.m_CommandUID = commandUID;
8435 overrideData.m_CommandUIDProne = commandUIDProne;
8436 overrideData.m_StanceMask = stanceMask;
8437
8438 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
8439 if (!actionMap) // create new map of action > overidables map
8440 {
8441 actionMap = new TActionAnimOverrideMap();
8442 m_ItemActionOverrides.Insert(action, actionMap);
8443 }
8444
8445 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
8446
8447 }
8448
8449 void OnItemInHandsPlayerSwimStart(PlayerBase player);
8450
8451 ScriptedLightBase GetLight();
8452
8453 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
8454 void LoadParticleConfigOnFire(int id)
8455 {
8456 if (!m_OnFireEffect)
8458
8461
8462 string config_to_search = "CfgVehicles";
8463 string muzzle_owner_config;
8464
8465 if (!m_OnFireEffect.Contains(id))
8466 {
8467 if (IsInherited(Weapon))
8468 config_to_search = "CfgWeapons";
8469
8470 muzzle_owner_config = config_to_search + " " + GetType() + " ";
8471
8472 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
8473
8474 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
8475
8476 if (config_OnFire_subclass_count > 0)
8477 {
8478 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
8479
8480 for (int i = 0; i < config_OnFire_subclass_count; i++)
8481 {
8482 string particle_class = "";
8483 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
8484 string config_OnFire_entry = config_OnFire_class + particle_class;
8485 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
8486 WPOF_array.Insert(WPOF);
8487 }
8488
8489
8490 m_OnFireEffect.Insert(id, WPOF_array);
8491 }
8492 }
8493
8494 if (!m_OnBulletCasingEjectEffect.Contains(id))
8495 {
8496 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
8497 muzzle_owner_config = config_to_search + " " + GetType() + " ";
8498
8499 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
8500
8501 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
8502
8503 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
8504 {
8505 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
8506
8507 for (i = 0; i < config_OnBulletCasingEject_count; i++)
8508 {
8509 string particle_class2 = "";
8510 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
8511 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
8512 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
8513 WPOBE_array.Insert(WPOBE);
8514 }
8515
8516
8517 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
8518 }
8519 }
8520 }
8521
8522 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
8524 {
8527
8528 if (!m_OnOverheatingEffect.Contains(id))
8529 {
8530 string config_to_search = "CfgVehicles";
8531
8532 if (IsInherited(Weapon))
8533 config_to_search = "CfgWeapons";
8534
8535 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
8536 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
8537
8538 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
8539 {
8540
8541 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
8542
8544 {
8545 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
8546 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
8547 Error(error);
8548 return;
8549 }
8550
8551 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
8552 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
8553
8554
8555
8556 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
8557 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
8558
8559 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
8560 {
8561 string particle_class = "";
8562 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
8563 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
8564 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
8565
8566 if (entry_type == CT_CLASS)
8567 {
8568 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
8569 WPOOH_array.Insert(WPOF);
8570 }
8571 }
8572
8573
8574 m_OnOverheatingEffect.Insert(id, WPOOH_array);
8575 }
8576 }
8577 }
8578
8579 float GetOverheatingValue()
8580 {
8581 return m_OverheatingShots;
8582 }
8583
8584 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
8585 {
8586 if (m_MaxOverheatingValue > 0)
8587 {
8589
8590 if (!m_CheckOverheating)
8592
8594 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8595
8596 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8597 }
8598 }
8599
8600 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8601 {
8603 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8604
8606 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8607
8609 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8610
8612 {
8614 }
8615 }
8616
8618 {
8620 }
8621
8622 void OnOverheatingDecay()
8623 {
8624 if (m_MaxOverheatingValue > 0)
8625 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
8626 else
8628
8629 if (m_OverheatingShots <= 0)
8630 {
8633 }
8634 else
8635 {
8636 if (!m_CheckOverheating)
8638
8640 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8641 }
8642
8643 CheckOverheating(this, "", this);
8644 }
8645
8646 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8647 {
8649 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8650 }
8651
8652 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8653 {
8655 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8657 }
8658
8659 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8660 {
8662 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8663 }
8664
8665 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
8666 {
8668 m_OverheatingParticles = new array<ref OverheatingParticle>;
8669
8670 OverheatingParticle OP = new OverheatingParticle();
8671 OP.RegisterParticle(p);
8672 OP.SetOverheatingLimitMin(min_heat_coef);
8673 OP.SetOverheatingLimitMax(max_heat_coef);
8674 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
8675
8676 m_OverheatingParticles.Insert(OP);
8677 }
8678
8679 float GetOverheatingCoef()
8680 {
8681 if (m_MaxOverheatingValue > 0)
8683
8684 return -1;
8685 }
8686
8688 {
8690 {
8691 float overheat_coef = GetOverheatingCoef();
8692 int count = m_OverheatingParticles.Count();
8693
8694 for (int i = count; i > 0; --i)
8695 {
8696 int id = i - 1;
8697 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8698 Particle p = OP.GetParticle();
8699
8700 float overheat_min = OP.GetOverheatingLimitMin();
8701 float overheat_max = OP.GetOverheatingLimitMax();
8702
8703 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
8704 {
8705 if (p)
8706 {
8707 p.Stop();
8708 OP.RegisterParticle(null);
8709 }
8710 }
8711 }
8712 }
8713 }
8714
8716 {
8718 {
8719 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
8720 {
8721 int id = i - 1;
8722 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8723
8724 if (OP)
8725 {
8726 Particle p = OP.GetParticle();
8727
8728 if (p)
8729 {
8730 p.Stop();
8731 }
8732
8733 delete OP;
8734 }
8735 }
8736
8737 m_OverheatingParticles.Clear();
8739 }
8740 }
8741
8743 float GetInfectionChance(int system = 0, Param param = null)
8744 {
8745 return 0.0;
8746 }
8747
8748
8749 float GetDisinfectQuantity(int system = 0, Param param1 = null)
8750 {
8751 return 250;//default value
8752 }
8753
8754 float GetFilterDamageRatio()
8755 {
8756 return 0;
8757 }
8758
8760 bool HasMuzzle()
8761 {
8762 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
8763 return true;
8764
8765 return false;
8766 }
8767
8769 int GetMuzzleID()
8770 {
8771 if (!m_WeaponTypeToID)
8773
8774 if (m_WeaponTypeToID.Contains(GetType()))
8775 {
8776 return m_WeaponTypeToID.Get(GetType());
8777 }
8778 else
8779 {
8780 // Register new weapon ID
8782 }
8783
8785 }
8786
8793 {
8794 return -1;
8795 }
8796
8797
8798
8799 // -------------------------------------------------------------------------
8800 void ~ItemBase()
8801 {
8802 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
8803 {
8804 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
8805 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
8806
8807 if (r_index >= 0)
8808 {
8809 InventoryLocation r_il = new InventoryLocation;
8810 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8811
8812 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8813 int r_type = r_il.GetType();
8814 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8815 {
8816 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8817 }
8818 else if (r_type == InventoryLocationType.ATTACHMENT)
8819 {
8820 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8821 }
8822
8823 }
8824
8825 player.GetHumanInventory().ClearUserReservedLocation(this);
8826 }
8827
8828 if (m_LockingSound)
8829 SEffectManager.DestroyEffect(m_LockingSound);
8830 }
8831
8832
8833
8834 // -------------------------------------------------------------------------
8835 static int GetDebugActionsMask()
8836 {
8837 return ItemBase.m_DebugActionsMask;
8838 }
8839
8840 static bool HasDebugActionsMask(int mask)
8841 {
8842 return ItemBase.m_DebugActionsMask & mask;
8843 }
8844
8845 static void SetDebugActionsMask(int mask)
8846 {
8847 ItemBase.m_DebugActionsMask = mask;
8848 }
8849
8850 static void AddDebugActionsMask(int mask)
8851 {
8852 ItemBase.m_DebugActionsMask |= mask;
8853 }
8854
8855 static void RemoveDebugActionsMask(int mask)
8856 {
8857 ItemBase.m_DebugActionsMask &= ~mask;
8858 }
8859
8860 static void ToggleDebugActionsMask(int mask)
8861 {
8862 if (HasDebugActionsMask(mask))
8863 {
8865 }
8866 else
8867 {
8868 AddDebugActionsMask(mask);
8869 }
8870 }
8871
8872 // -------------------------------------------------------------------------
8873 void SetCEBasedQuantity()
8874 {
8875 if (GetEconomyProfile())
8876 {
8877 float q_max = GetEconomyProfile().GetQuantityMax();
8878 if (q_max > 0)
8879 {
8880 float q_min = GetEconomyProfile().GetQuantityMin();
8881 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
8882
8883 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
8884 {
8885 ComponentEnergyManager comp = GetCompEM();
8886 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
8887 {
8888 comp.SetEnergy0To1(quantity_randomized);
8889 }
8890 }
8891 else if (HasQuantity())
8892 {
8893 SetQuantityNormalized(quantity_randomized, false);
8894 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
8895 }
8896
8897 }
8898 }
8899 }
8900
8902 void LockToParent()
8903 {
8904 EntityAI parent = GetHierarchyParent();
8905
8906 if (parent)
8907 {
8908 InventoryLocation inventory_location_to_lock = new InventoryLocation;
8909 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
8910 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
8911 }
8912 }
8913
8915 void UnlockFromParent()
8916 {
8917 EntityAI parent = GetHierarchyParent();
8918
8919 if (parent)
8920 {
8921 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
8922 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
8923 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
8924 }
8925 }
8926
8927 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
8928 {
8929 /*
8930 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
8931 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
8932 */
8933 ItemBase item2 = ItemBase.Cast(entity2);
8934
8935 if (GetGame().IsClient())
8936 {
8937 if (ScriptInputUserData.CanStoreInputUserData())
8938 {
8939 ScriptInputUserData ctx = new ScriptInputUserData;
8941 ctx.Write(-1);
8942 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8943 ctx.Write(i1);
8944 ctx.Write(item2);
8945 ctx.Write(use_stack_max);
8946 ctx.Write(-1);
8947 ctx.Send();
8948
8949 if (IsCombineAll(item2, use_stack_max))
8950 {
8951 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
8952 }
8953 }
8954 }
8955 else if (!GetGame().IsMultiplayer())
8956 {
8957 CombineItems(item2, use_stack_max);
8958 }
8959 }
8960
8961 bool IsLiquidPresent()
8962 {
8963 return (GetLiquidType() != 0 && HasQuantity());
8964 }
8965
8966 bool IsLiquidContainer()
8967 {
8968 return m_LiquidContainerMask != 0;
8969 }
8970
8972 {
8973 return m_LiquidContainerMask;
8974 }
8975
8976 bool IsBloodContainer()
8977 {
8978 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
8979 return false;
8980 }
8981
8982 bool IsNVG()
8983 {
8984 return false;
8985 }
8986
8989 bool IsExplosive()
8990 {
8991 return false;
8992 }
8993
8995 {
8996 return "";
8997 }
8998
9000
9001 bool IsLightSource()
9002 {
9003 return false;
9004 }
9005
9007 {
9008 return true;
9009 }
9010
9011 //--- ACTION CONDITIONS
9012 //direction
9013 bool IsFacingPlayer(PlayerBase player, string selection)
9014 {
9015 return true;
9016 }
9017
9018 bool IsPlayerInside(PlayerBase player, string selection)
9019 {
9020 return true;
9021 }
9022
9023 override bool CanObstruct()
9024 {
9025 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9026 return !player || !IsPlayerInside(player, "");
9027 }
9028
9029 override bool IsBeingPlaced()
9030 {
9031 return m_IsBeingPlaced;
9032 }
9033
9034 void SetIsBeingPlaced(bool is_being_placed)
9035 {
9036 m_IsBeingPlaced = is_being_placed;
9037 if (!is_being_placed)
9039 SetSynchDirty();
9040 }
9041
9042 //server-side
9043 void OnEndPlacement() {}
9044
9045 override bool IsHologram()
9046 {
9047 return m_IsHologram;
9048 }
9049
9050 bool CanBeDigged()
9051 {
9052 return m_CanBeDigged;
9053 }
9054
9056 {
9057 return 1;
9058 }
9059
9060 bool CanMakeGardenplot()
9061 {
9062 return false;
9063 }
9064
9065 void SetIsHologram(bool is_hologram)
9066 {
9067 m_IsHologram = is_hologram;
9068 SetSynchDirty();
9069 }
9070 /*
9071 protected float GetNutritionalEnergy()
9072 {
9073 Edible_Base edible = Edible_Base.Cast(this);
9074 return edible.GetFoodEnergy();
9075 }
9076
9077 protected float GetNutritionalWaterContent()
9078 {
9079 Edible_Base edible = Edible_Base.Cast(this);
9080 return edible.GetFoodWater();
9081 }
9082
9083 protected float GetNutritionalIndex()
9084 {
9085 Edible_Base edible = Edible_Base.Cast(this);
9086 return edible.GetFoodNutritionalIndex();
9087 }
9088
9089 protected float GetNutritionalFullnessIndex()
9090 {
9091 Edible_Base edible = Edible_Base.Cast(this);
9092 return edible.GetFoodTotalVolume();
9093 }
9094
9095 protected float GetNutritionalToxicity()
9096 {
9097 Edible_Base edible = Edible_Base.Cast(this);
9098 return edible.GetFoodToxicity();
9099
9100 }
9101 */
9102
9103
9104 // -------------------------------------------------------------------------
9105 override void OnMovedInsideCargo(EntityAI container)
9106 {
9107 super.OnMovedInsideCargo(container);
9108
9109 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9110 }
9111
9112 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9113 {
9114 super.EEItemLocationChanged(oldLoc,newLoc);
9115
9116 PlayerBase new_player = null;
9117 PlayerBase old_player = null;
9118
9119 if (newLoc.GetParent())
9120 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
9121
9122 if (oldLoc.GetParent())
9123 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
9124
9125 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
9126 {
9127 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
9128
9129 if (r_index >= 0)
9130 {
9131 InventoryLocation r_il = new InventoryLocation;
9132 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9133
9134 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9135 int r_type = r_il.GetType();
9136 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9137 {
9138 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9139 }
9140 else if (r_type == InventoryLocationType.ATTACHMENT)
9141 {
9142 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9143 }
9144
9145 }
9146 }
9147
9148 if (newLoc.GetType() == InventoryLocationType.HANDS)
9149 {
9150 if (new_player)
9151 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
9152
9153 if (new_player == old_player)
9154 {
9155
9156 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
9157 {
9158 if (oldLoc.GetType() == InventoryLocationType.CARGO)
9159 {
9160 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
9161 {
9162 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9163 }
9164 }
9165 else
9166 {
9167 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9168 }
9169 }
9170
9171 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
9172 {
9173 int type = oldLoc.GetType();
9174 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
9175 {
9176 oldLoc.GetParent().GetOnSetLock().Invoke(this);
9177 }
9178 else if (type == InventoryLocationType.ATTACHMENT)
9179 {
9180 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
9181 }
9182 }
9183 if (!m_OldLocation)
9184 {
9185 m_OldLocation = new InventoryLocation;
9186 }
9187 m_OldLocation.Copy(oldLoc);
9188 }
9189 else
9190 {
9191 if (m_OldLocation)
9192 {
9193 m_OldLocation.Reset();
9194 }
9195 }
9196
9198 }
9199 else
9200 {
9201 if (new_player)
9202 {
9203 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
9204 if (res_index >= 0)
9205 {
9206 InventoryLocation il = new InventoryLocation;
9207 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
9208 ItemBase it = ItemBase.Cast(il.GetItem());
9209 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
9210 int rel_type = il.GetType();
9211 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
9212 {
9213 il.GetParent().GetOnReleaseLock().Invoke(it);
9214 }
9215 else if (rel_type == InventoryLocationType.ATTACHMENT)
9216 {
9217 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
9218 }
9219 //it.GetOnReleaseLock().Invoke(it);
9220 }
9221 }
9222 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
9223 {
9224 //ThrowPhysically(old_player, vector.Zero);
9225 m_ThrowItemOnDrop = false;
9226 }
9227
9228 if (m_OldLocation)
9229 {
9230 m_OldLocation.Reset();
9231 }
9232 }
9233 }
9234
9235 override void EOnContact(IEntity other, Contact extra)
9236 {
9238 {
9239 int liquidType = -1;
9240 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
9241 if (impactSpeed > 0.0)
9242 {
9243 m_ImpactSpeed = impactSpeed;
9244 #ifndef SERVER
9245 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9246 #else
9247 m_WantPlayImpactSound = true;
9248 SetSynchDirty();
9249 #endif
9250 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
9251 }
9252 }
9253
9254 #ifdef SERVER
9255 if (GetCompEM() && GetCompEM().IsPlugged())
9256 {
9257 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
9258 GetCompEM().UnplugThis();
9259 }
9260 #endif
9261 }
9262
9263 void RefreshPhysics();
9264
9265 override void OnCreatePhysics()
9266 {
9268 }
9269
9270 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9271 {
9272
9273 }
9274 // -------------------------------------------------------------------------
9275 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
9276 {
9277 super.OnItemLocationChanged(old_owner, new_owner);
9278
9279 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
9280 PlayerBase playerNew = PlayerBase.Cast(new_owner);
9281
9282 if (!relatedPlayer && playerNew)
9283 relatedPlayer = playerNew;
9284
9285 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
9286 {
9287 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
9288 if (actionMgr)
9289 {
9290 ActionBase currentAction = actionMgr.GetRunningAction();
9291 if (currentAction)
9292 currentAction.OnItemLocationChanged(this);
9293 }
9294 }
9295
9296 Man ownerPlayerOld = null;
9297 Man ownerPlayerNew = null;
9298
9299 if (old_owner)
9300 {
9301 if (old_owner.IsMan())
9302 {
9303 ownerPlayerOld = Man.Cast(old_owner);
9304 }
9305 else
9306 {
9307 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
9308 }
9309 }
9310 else
9311 {
9312 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
9313 {
9314 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
9315
9316 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
9317 {
9318 GetCompEM().UnplugThis();
9319 }
9320 }
9321 }
9322
9323 if (new_owner)
9324 {
9325 if (new_owner.IsMan())
9326 {
9327 ownerPlayerNew = Man.Cast(new_owner);
9328 }
9329 else
9330 {
9331 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
9332 }
9333 }
9334
9335 if (ownerPlayerOld != ownerPlayerNew)
9336 {
9337 if (ownerPlayerOld)
9338 {
9339 array<EntityAI> subItemsExit = new array<EntityAI>;
9340 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
9341 for (int i = 0; i < subItemsExit.Count(); i++)
9342 {
9343 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
9344 itemExit.OnInventoryExit(ownerPlayerOld);
9345 }
9346 }
9347
9348 if (ownerPlayerNew)
9349 {
9350 array<EntityAI> subItemsEnter = new array<EntityAI>;
9351 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
9352 for (int j = 0; j < subItemsEnter.Count(); j++)
9353 {
9354 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
9355 itemEnter.OnInventoryEnter(ownerPlayerNew);
9356 }
9357 }
9358 }
9359 else if (ownerPlayerNew != null)
9360 {
9361 PlayerBase nplayer;
9362 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
9363 {
9364 array<EntityAI> subItemsUpdate = new array<EntityAI>;
9365 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
9366 for (int k = 0; k < subItemsUpdate.Count(); k++)
9367 {
9368 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
9369 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
9370 }
9371 }
9372 }
9373
9374 if (old_owner)
9375 old_owner.OnChildItemRemoved(this);
9376 if (new_owner)
9377 new_owner.OnChildItemReceived(this);
9378 }
9379
9380 // -------------------------------------------------------------------------------
9381 override void EEDelete(EntityAI parent)
9382 {
9383 super.EEDelete(parent);
9384 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
9385 if (player)
9386 {
9387 OnInventoryExit(player);
9388
9389 if (player.IsAlive())
9390 {
9391 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9392 if (r_index >= 0)
9393 {
9394 InventoryLocation r_il = new InventoryLocation;
9395 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9396
9397 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9398 int r_type = r_il.GetType();
9399 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9400 {
9401 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9402 }
9403 else if (r_type == InventoryLocationType.ATTACHMENT)
9404 {
9405 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9406 }
9407
9408 }
9409
9410 player.RemoveQuickBarEntityShortcut(this);
9411 }
9412 }
9413 }
9414 // -------------------------------------------------------------------------------
9415 override void EEKilled(Object killer)
9416 {
9417 super.EEKilled(killer);
9418
9420 if (killer && killer.IsFireplace() && CanExplodeInFire())
9421 {
9422 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
9423 {
9424 if (IsMagazine())
9425 {
9426 if (Magazine.Cast(this).GetAmmoCount() > 0)
9427 {
9428 ExplodeAmmo();
9429 }
9430 }
9431 else
9432 {
9433 Explode(DamageType.EXPLOSION);
9434 }
9435 }
9436 }
9437 }
9438
9439 override void OnWasAttached(EntityAI parent, int slot_id)
9440 {
9441 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9442
9443 super.OnWasAttached(parent, slot_id);
9444
9445 if (HasQuantity())
9446 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9447
9448 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
9449 }
9450
9451 override void OnWasDetached(EntityAI parent, int slot_id)
9452 {
9453 super.OnWasDetached(parent, slot_id);
9454
9455 if (HasQuantity())
9456 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9457 }
9458
9459 override string ChangeIntoOnAttach(string slot)
9460 {
9461 int idx;
9462 TStringArray inventory_slots = new TStringArray;
9463 TStringArray attach_types = new TStringArray;
9464
9465 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
9466 if (inventory_slots.Count() < 1) //is string
9467 {
9468 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
9469 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
9470 }
9471 else //is array
9472 {
9473 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
9474 }
9475
9476 idx = inventory_slots.Find(slot);
9477 if (idx < 0)
9478 return "";
9479
9480 return attach_types.Get(idx);
9481 }
9482
9483 override string ChangeIntoOnDetach()
9484 {
9485 int idx = -1;
9486 string slot;
9487
9488 TStringArray inventory_slots = new TStringArray;
9489 TStringArray detach_types = new TStringArray;
9490
9491 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
9492 if (inventory_slots.Count() < 1) //is string
9493 {
9494 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
9495 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
9496 }
9497 else //is array
9498 {
9499 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
9500 if (detach_types.Count() < 1)
9501 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
9502 }
9503
9504 for (int i = 0; i < inventory_slots.Count(); i++)
9505 {
9506 slot = inventory_slots.Get(i);
9507 }
9508
9509 if (slot != "")
9510 {
9511 if (detach_types.Count() == 1)
9512 idx = 0;
9513 else
9514 idx = inventory_slots.Find(slot);
9515 }
9516 if (idx < 0)
9517 return "";
9518
9519 return detach_types.Get(idx);
9520 }
9521
9522 void ExplodeAmmo()
9523 {
9524 //timer
9525 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
9526
9527 //min/max time
9528 float min_time = 1;
9529 float max_time = 3;
9530 float delay = Math.RandomFloat(min_time, max_time);
9531
9532 explode_timer.Run(delay, this, "DoAmmoExplosion");
9533 }
9534
9535 void DoAmmoExplosion()
9536 {
9537 Magazine magazine = Magazine.Cast(this);
9538 int pop_sounds_count = 6;
9539 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
9540
9541 //play sound
9542 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
9543 string sound_name = pop_sounds[ sound_idx ];
9544 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
9545
9546 //remove ammo count
9547 magazine.ServerAddAmmoCount(-1);
9548
9549 //if condition then repeat -> ExplodeAmmo
9550 float min_temp_to_explode = 100; //min temperature for item to explode
9551
9552 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
9553 {
9554 ExplodeAmmo();
9555 }
9556 }
9557
9558 // -------------------------------------------------------------------------------
9559 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
9560 {
9561 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
9562
9563 const int CHANCE_DAMAGE_CARGO = 4;
9564 const int CHANCE_DAMAGE_ATTACHMENT = 1;
9565 const int CHANCE_DAMAGE_NOTHING = 2;
9566
9567 if (IsClothing() || IsContainer() || IsItemTent())
9568 {
9569 float dmg = damageResult.GetDamage("","Health") * -0.5;
9570 int chances;
9571 int rnd;
9572
9573 if (GetInventory().GetCargo())
9574 {
9575 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9576 rnd = Math.RandomInt(0,chances);
9577
9578 if (rnd < CHANCE_DAMAGE_CARGO)
9579 {
9580 DamageItemInCargo(dmg);
9581 }
9582 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
9583 {
9585 }
9586 }
9587 else
9588 {
9589 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9590 rnd = Math.RandomInt(0,chances);
9591
9592 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
9593 {
9595 }
9596 }
9597 }
9598 }
9599
9600 bool DamageItemInCargo(float damage)
9601 {
9602 if (GetInventory().GetCargo())
9603 {
9604 int item_count = GetInventory().GetCargo().GetItemCount();
9605 if (item_count > 0)
9606 {
9607 int random_pick = Math.RandomInt(0, item_count);
9608 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
9609 if (!item.IsExplosive())
9610 {
9611 item.AddHealth("","",damage);
9612 return true;
9613 }
9614 }
9615 }
9616 return false;
9617 }
9618
9619 bool DamageItemAttachments(float damage)
9620 {
9621 int attachment_count = GetInventory().AttachmentCount();
9622 if (attachment_count > 0)
9623 {
9624 int random_pick = Math.RandomInt(0, attachment_count);
9625 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
9626 if (!attachment.IsExplosive())
9627 {
9628 attachment.AddHealth("","",damage);
9629 return true;
9630 }
9631 }
9632 return false;
9633 }
9634
9635 override bool IsSplitable()
9636 {
9637 return m_CanThisBeSplit;
9638 }
9639 //----------------
9640 override bool CanBeSplit()
9641 {
9642 if (IsSplitable() && (GetQuantity() > 1))
9643 return GetInventory().CanRemoveEntity();
9644
9645 return false;
9646 }
9647
9648 protected bool ShouldSplitQuantity(float quantity)
9649 {
9650 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
9651 if (!IsSplitable())
9652 return false;
9653
9654 // nothing to split?
9655 if (GetQuantity() <= 1)
9656 return false;
9657
9658 // check if we should re-use the item instead of creating a new copy?
9659 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
9660 int delta = GetQuantity() - quantity;
9661 if (delta == 0)
9662 return false;
9663
9664 // valid to split
9665 return true;
9666 }
9667
9668 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
9669 {
9670 if (GetGame().IsClient())
9671 {
9672 if (ScriptInputUserData.CanStoreInputUserData())
9673 {
9674 ScriptInputUserData ctx = new ScriptInputUserData;
9676 ctx.Write(1);
9677 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9678 ctx.Write(i1);
9679 ctx.Write(destination_entity);
9680 ctx.Write(true);
9681 ctx.Write(slot_id);
9682 ctx.Send();
9683 }
9684 }
9685 else if (!GetGame().IsMultiplayer())
9686 {
9687 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
9688 }
9689 }
9690
9691 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
9692 {
9693 float split_quantity_new;
9694 ItemBase new_item;
9695 float quantity = GetQuantity();
9696 float stack_max = GetTargetQuantityMax(slot_id);
9697 InventoryLocation loc = new InventoryLocation;
9698
9699 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9700 {
9701 if (stack_max <= GetQuantity())
9702 split_quantity_new = stack_max;
9703 else
9704 split_quantity_new = GetQuantity();
9705
9706 if (ShouldSplitQuantity(split_quantity_new))
9707 {
9708 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9709 if (new_item)
9710 {
9711 new_item.SetResultOfSplit(true);
9712 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9713 AddQuantity(-split_quantity_new, false, true);
9714 new_item.SetQuantity(split_quantity_new, false, true);
9715 }
9716 }
9717 }
9718 else if (destination_entity && slot_id == -1)
9719 {
9720 if (quantity > stack_max)
9721 split_quantity_new = stack_max;
9722 else
9723 split_quantity_new = quantity;
9724
9725 if (ShouldSplitQuantity(split_quantity_new))
9726 {
9727 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
9728 {
9729 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
9730 new_item = ItemBase.Cast(o);
9731 }
9732
9733 if (new_item)
9734 {
9735 new_item.SetResultOfSplit(true);
9736 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9737 AddQuantity(-split_quantity_new, false, true);
9738 new_item.SetQuantity(split_quantity_new, false, true);
9739 }
9740 }
9741 }
9742 else
9743 {
9744 if (stack_max != 0)
9745 {
9746 if (stack_max < GetQuantity())
9747 {
9748 split_quantity_new = GetQuantity() - stack_max;
9749 }
9750
9751 if (split_quantity_new == 0)
9752 {
9753 if (!GetGame().IsMultiplayer())
9754 player.PhysicalPredictiveDropItem(this);
9755 else
9756 player.ServerDropEntity(this);
9757 return;
9758 }
9759
9760 if (ShouldSplitQuantity(split_quantity_new))
9761 {
9762 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
9763
9764 if (new_item)
9765 {
9766 new_item.SetResultOfSplit(true);
9767 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9768 SetQuantity(split_quantity_new, false, true);
9769 new_item.SetQuantity(stack_max, false, true);
9770 new_item.PlaceOnSurface();
9771 }
9772 }
9773 }
9774 }
9775 }
9776
9777 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
9778 {
9779 float split_quantity_new;
9780 ItemBase new_item;
9781 float quantity = GetQuantity();
9782 float stack_max = GetTargetQuantityMax(slot_id);
9783 InventoryLocation loc = new InventoryLocation;
9784
9785 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9786 {
9787 if (stack_max <= GetQuantity())
9788 split_quantity_new = stack_max;
9789 else
9790 split_quantity_new = GetQuantity();
9791
9792 if (ShouldSplitQuantity(split_quantity_new))
9793 {
9794 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9795 if (new_item)
9796 {
9797 new_item.SetResultOfSplit(true);
9798 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9799 AddQuantity(-split_quantity_new, false, true);
9800 new_item.SetQuantity(split_quantity_new, false, true);
9801 }
9802 }
9803 }
9804 else if (destination_entity && slot_id == -1)
9805 {
9806 if (quantity > stack_max)
9807 split_quantity_new = stack_max;
9808 else
9809 split_quantity_new = quantity;
9810
9811 if (ShouldSplitQuantity(split_quantity_new))
9812 {
9813 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
9814 {
9815 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
9816 new_item = ItemBase.Cast(o);
9817 }
9818
9819 if (new_item)
9820 {
9821 new_item.SetResultOfSplit(true);
9822 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9823 AddQuantity(-split_quantity_new, false, true);
9824 new_item.SetQuantity(split_quantity_new, false, true);
9825 }
9826 }
9827 }
9828 else
9829 {
9830 if (stack_max != 0)
9831 {
9832 if (stack_max < GetQuantity())
9833 {
9834 split_quantity_new = GetQuantity() - stack_max;
9835 }
9836
9837 if (ShouldSplitQuantity(split_quantity_new))
9838 {
9839 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
9840
9841 if (new_item)
9842 {
9843 new_item.SetResultOfSplit(true);
9844 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9845 SetQuantity(split_quantity_new, false, true);
9846 new_item.SetQuantity(stack_max, false, true);
9847 new_item.PlaceOnSurface();
9848 }
9849 }
9850 }
9851 }
9852 }
9853
9854 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
9855 {
9856 if (GetGame().IsClient())
9857 {
9858 if (ScriptInputUserData.CanStoreInputUserData())
9859 {
9860 ScriptInputUserData ctx = new ScriptInputUserData;
9862 ctx.Write(4);
9863 ItemBase thiz = this; // @NOTE: workaround for correct serialization
9864 ctx.Write(thiz);
9865 dst.WriteToContext(ctx);
9866 ctx.Send();
9867 }
9868 }
9869 else if (!GetGame().IsMultiplayer())
9870 {
9872 }
9873 }
9874
9875 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
9876 {
9877 if (GetGame().IsClient())
9878 {
9879 if (ScriptInputUserData.CanStoreInputUserData())
9880 {
9881 ScriptInputUserData ctx = new ScriptInputUserData;
9883 ctx.Write(2);
9884 ItemBase dummy = this; // @NOTE: workaround for correct serialization
9885 ctx.Write(dummy);
9886 ctx.Write(destination_entity);
9887 ctx.Write(true);
9888 ctx.Write(idx);
9889 ctx.Write(row);
9890 ctx.Write(col);
9891 ctx.Send();
9892 }
9893 }
9894 else if (!GetGame().IsMultiplayer())
9895 {
9896 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
9897 }
9898 }
9899
9900 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
9901 {
9903 }
9904
9905 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
9906 {
9907 float quantity = GetQuantity();
9908 float split_quantity_new;
9909 ItemBase new_item;
9910 if (dst.IsValid())
9911 {
9912 int slot_id = dst.GetSlot();
9913 float stack_max = GetTargetQuantityMax(slot_id);
9914
9915 if (quantity > stack_max)
9916 split_quantity_new = stack_max;
9917 else
9918 split_quantity_new = quantity;
9919
9920 if (ShouldSplitQuantity(split_quantity_new))
9921 {
9922 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
9923
9924 if (new_item)
9925 {
9926 new_item.SetResultOfSplit(true);
9927 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9928 AddQuantity(-split_quantity_new, false, true);
9929 new_item.SetQuantity(split_quantity_new, false, true);
9930 }
9931
9932 return new_item;
9933 }
9934 }
9935
9936 return null;
9937 }
9938
9939 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
9940 {
9941 float quantity = GetQuantity();
9942 float split_quantity_new;
9943 ItemBase new_item;
9944 if (destination_entity)
9945 {
9946 float stackable = GetTargetQuantityMax();
9947 if (quantity > stackable)
9948 split_quantity_new = stackable;
9949 else
9950 split_quantity_new = quantity;
9951
9952 if (ShouldSplitQuantity(split_quantity_new))
9953 {
9954 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
9955 if (new_item)
9956 {
9957 new_item.SetResultOfSplit(true);
9958 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9959 AddQuantity(-split_quantity_new, false, true);
9960 new_item.SetQuantity(split_quantity_new, false, true);
9961 }
9962 }
9963 }
9964 }
9965
9966 void SplitIntoStackMaxHandsClient(PlayerBase player)
9967 {
9968 if (GetGame().IsClient())
9969 {
9970 if (ScriptInputUserData.CanStoreInputUserData())
9971 {
9972 ScriptInputUserData ctx = new ScriptInputUserData;
9974 ctx.Write(3);
9975 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9976 ctx.Write(i1);
9977 ItemBase destination_entity = this;
9978 ctx.Write(destination_entity);
9979 ctx.Write(true);
9980 ctx.Write(0);
9981 ctx.Send();
9982 }
9983 }
9984 else if (!GetGame().IsMultiplayer())
9985 {
9986 SplitIntoStackMaxHands(player);
9987 }
9988 }
9989
9990 void SplitIntoStackMaxHands(PlayerBase player)
9991 {
9992 float quantity = GetQuantity();
9993 float split_quantity_new;
9994 ref ItemBase new_item;
9995 if (player)
9996 {
9997 float stackable = GetTargetQuantityMax();
9998 if (quantity > stackable)
9999 split_quantity_new = stackable;
10000 else
10001 split_quantity_new = quantity;
10002
10003 if (ShouldSplitQuantity(split_quantity_new))
10004 {
10005 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
10006 new_item = ItemBase.Cast(in_hands);
10007 if (new_item)
10008 {
10009 new_item.SetResultOfSplit(true);
10010 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10011 AddQuantity(-split_quantity_new, false, true);
10012 new_item.SetQuantity(split_quantity_new, false, true);
10013 }
10014 }
10015 }
10016 }
10017
10018 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
10019 {
10020 float quantity = GetQuantity();
10021 float split_quantity_new = Math.Floor(quantity * 0.5);
10022
10023 if (!ShouldSplitQuantity(split_quantity_new))
10024 return;
10025
10026 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10027
10028 if (new_item)
10029 {
10030 if (new_item.GetQuantityMax() < split_quantity_new)
10031 {
10032 split_quantity_new = new_item.GetQuantityMax();
10033 }
10034
10035 new_item.SetResultOfSplit(true);
10036 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10037
10038 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10039 {
10040 AddQuantity(-1, false, true);
10041 new_item.SetQuantity(1, false, true);
10042 }
10043 else
10044 {
10045 AddQuantity(-split_quantity_new, false, true);
10046 new_item.SetQuantity(split_quantity_new, false, true);
10047 }
10048 }
10049 }
10050
10051 void SplitItem(PlayerBase player)
10052 {
10053 float quantity = GetQuantity();
10054 float split_quantity_new = Math.Floor(quantity / 2);
10055
10056 if (!ShouldSplitQuantity(split_quantity_new))
10057 return;
10058
10059 InventoryLocation invloc = new InventoryLocation;
10060 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
10061
10062 ItemBase new_item;
10063 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
10064
10065 if (new_item)
10066 {
10067 if (new_item.GetQuantityMax() < split_quantity_new)
10068 {
10069 split_quantity_new = new_item.GetQuantityMax();
10070 }
10071 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10072 {
10073 AddQuantity(-1, false, true);
10074 new_item.SetQuantity(1, false, true);
10075 }
10076 else if (split_quantity_new > 1)
10077 {
10078 AddQuantity(-split_quantity_new, false, true);
10079 new_item.SetQuantity(split_quantity_new, false, true);
10080 }
10081 }
10082 }
10083
10085 void OnQuantityChanged(float delta)
10086 {
10087 SetWeightDirty();
10088 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
10089
10090 if (parent)
10091 parent.OnAttachmentQuantityChangedEx(this, delta);
10092
10093 if (IsLiquidContainer())
10094 {
10095 if (GetQuantityNormalized() <= 0.0)
10096 {
10098 }
10099 else if (GetLiquidType() == LIQUID_NONE)
10100 {
10101 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
10103 }
10104 }
10105
10106 }
10107
10110 {
10111 // insert code here
10112 }
10113
10115 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
10116 {
10118 }
10119
10120 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
10121 {
10122 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
10123
10124 if (GetGame().IsServer())
10125 {
10126 if (newLevel == GameConstants.STATE_RUINED)
10127 {
10129 EntityAI parent = GetHierarchyParent();
10130 if (parent && parent.IsFireplace())
10131 {
10132 CargoBase cargo = GetInventory().GetCargo();
10133 if (cargo)
10134 {
10135 for (int i = 0; i < cargo.GetItemCount(); ++i)
10136 {
10137 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
10138 }
10139 }
10140 }
10141 }
10142
10143 if (IsResultOfSplit())
10144 {
10145 // reset the splitting result flag, return to normal item behavior
10146 SetResultOfSplit(false);
10147 return;
10148 }
10149
10150 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
10151 {
10152 SetCleanness(0);//unclean the item upon damage dealt
10153 }
10154 }
10155 }
10156
10157 // just the split? TODO: verify
10158 override void OnRightClick()
10159 {
10160 super.OnRightClick();
10161
10162 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
10163 {
10164 if (GetGame().IsClient())
10165 {
10166 if (ScriptInputUserData.CanStoreInputUserData())
10167 {
10168 EntityAI root = GetHierarchyRoot();
10169 Man playerOwner = GetHierarchyRootPlayer();
10170 InventoryLocation dst = new InventoryLocation;
10171
10172 // 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
10173 if (!playerOwner && root && root == this)
10174 {
10176 }
10177 else
10178 {
10179 // 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
10180 GetInventory().GetCurrentInventoryLocation(dst);
10181 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
10182 {
10183 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
10184 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
10185 {
10187 }
10188 else
10189 {
10190 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
10191 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
10192 this shouldnt cause issues within this scope*/
10193 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
10194 {
10196 }
10197 else
10198 {
10199 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
10200 }
10201 }
10202 }
10203 }
10204
10205 ScriptInputUserData ctx = new ScriptInputUserData;
10207 ctx.Write(4);
10208 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10209 ctx.Write(thiz);
10210 dst.WriteToContext(ctx);
10211 ctx.Write(true); // dummy
10212 ctx.Send();
10213 }
10214 }
10215 else if (!GetGame().IsMultiplayer())
10216 {
10217 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
10218 }
10219 }
10220 }
10221
10222 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
10223 {
10224 if (root)
10225 {
10226 vector m4[4];
10227 root.GetTransform(m4);
10228 dst.SetGround(this, m4);
10229 }
10230 else
10231 {
10232 GetInventory().GetCurrentInventoryLocation(dst);
10233 }
10234 }
10235
10236 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
10237 {
10238 //TODO: delete check zero quantity check after fix double posts hands fsm events
10239 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
10240 return false;
10241
10242 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
10243 return false;
10244
10245 //can_this_be_combined = ConfigGetBool("canBeSplit");
10247 return false;
10248
10249
10250 Magazine mag = Magazine.Cast(this);
10251 if (mag)
10252 {
10253 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
10254 return false;
10255
10256 if (stack_max_limit)
10257 {
10258 Magazine other_mag = Magazine.Cast(other_item);
10259 if (other_item)
10260 {
10261 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
10262 return false;
10263 }
10264
10265 }
10266 }
10267 else
10268 {
10269 //TODO: delete check zero quantity check after fix double posts hands fsm events
10270 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
10271 return false;
10272
10273 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
10274 return false;
10275 }
10276
10277 PlayerBase player = null;
10278 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
10279 {
10280 if (player.GetInventory().HasAttachment(this))
10281 return false;
10282
10283 if (player.IsItemsToDelete())
10284 return false;
10285 }
10286
10287 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
10288 return false;
10289
10290 int slotID;
10291 string slotName;
10292 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
10293 return false;
10294
10295 return true;
10296 }
10297
10298 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
10299 {
10300 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
10301 }
10302
10303 bool IsResultOfSplit()
10304 {
10305 return m_IsResultOfSplit;
10306 }
10307
10308 void SetResultOfSplit(bool value)
10309 {
10310 m_IsResultOfSplit = value;
10311 }
10312
10313 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
10314 {
10315 return ComputeQuantityUsedEx(other_item, use_stack_max);
10316 }
10317
10318 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
10319 {
10320 float other_item_quantity = other_item.GetQuantity();
10321 float this_free_space;
10322
10323 float stack_max = GetQuantityMax();
10324
10325 this_free_space = stack_max - GetQuantity();
10326
10327 if (other_item_quantity > this_free_space)
10328 {
10329 return this_free_space;
10330 }
10331 else
10332 {
10333 return other_item_quantity;
10334 }
10335 }
10336
10337 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
10338 {
10339 CombineItems(ItemBase.Cast(entity2),use_stack_max);
10340 }
10341
10342 void CombineItems(ItemBase other_item, bool use_stack_max = true)
10343 {
10344 if (!CanBeCombined(other_item, false))
10345 return;
10346
10347 if (!IsMagazine() && other_item)
10348 {
10349 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
10350 if (quantity_used != 0)
10351 {
10352 float hp1 = GetHealth01("","");
10353 float hp2 = other_item.GetHealth01("","");
10354 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
10355 hpResult = hpResult / (GetQuantity() + quantity_used);
10356
10357 hpResult *= GetMaxHealth();
10358 Math.Round(hpResult);
10359 SetHealth("", "Health", hpResult);
10360
10361 AddQuantity(quantity_used);
10362 other_item.AddQuantity(-quantity_used);
10363 }
10364 }
10365 OnCombine(other_item);
10366 }
10367
10368 void OnCombine(ItemBase other_item)
10369 {
10370 #ifdef SERVER
10371 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
10372 GetHierarchyParent().IncreaseLifetimeUp();
10373 #endif
10374 };
10375
10376 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
10377 {
10378 PlayerBase p = PlayerBase.Cast(player);
10379
10380 array<int> recipesIds = p.m_Recipes;
10381 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
10382 if (moduleRecipesManager)
10383 {
10384 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
10385 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
10386 }
10387
10388 for (int i = 0;i < recipesIds.Count(); i++)
10389 {
10390 int key = recipesIds.Get(i);
10391 string recipeName = moduleRecipesManager.GetRecipeName(key);
10392 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
10393 }
10394 }
10395
10396 // -------------------------------------------------------------------------
10397 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
10398 {
10399 super.GetDebugActions(outputList);
10400
10401 //quantity
10402 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
10403 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
10404 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
10405 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
10406 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10407
10408 //health
10409 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
10410 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
10411 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
10412 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10413 //temperature
10414 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
10415 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
10416 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
10417 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10418
10419 //wet
10420 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
10421 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
10422 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10423
10424 //liquidtype
10425 if (IsLiquidContainer())
10426 {
10427 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
10428 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
10429 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10430 }
10431
10432 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
10433 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10434
10435 // watch
10436 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
10437 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
10438 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10439
10440 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
10441
10442 InventoryLocation loc = new InventoryLocation();
10443 GetInventory().GetCurrentInventoryLocation(loc);
10444 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
10445 {
10446 if (Gizmo_IsSupported())
10447 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
10448 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
10449 }
10450
10451 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10452 }
10453
10454 // -------------------------------------------------------------------------
10455 // -------------------------------------------------------------------------
10456 // -------------------------------------------------------------------------
10457 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
10458 {
10459 super.OnAction(action_id, player, ctx);
10460
10461 if (GetGame().IsClient() || !GetGame().IsMultiplayer())
10462 {
10463 switch (action_id)
10464 {
10465 case EActions.GIZMO_OBJECT:
10466 GetGame().GizmoSelectObject(this);
10467 return true;
10468 case EActions.GIZMO_PHYSICS:
10469 GetGame().GizmoSelectPhysics(GetPhysics());
10470 return true;
10471 }
10472 }
10473
10474 if (GetGame().IsServer())
10475 {
10476 switch (action_id)
10477 {
10478 case EActions.DELETE:
10479 Delete();
10480 return true;
10481 }
10482 }
10483
10484 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
10485 {
10486 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
10487 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
10488 PlayerBase p = PlayerBase.Cast(player);
10489 if (EActions.RECIPES_RANGE_START < 1000)
10490 {
10491 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
10492 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
10493 }
10494 }
10495 #ifndef SERVER
10496 else if (action_id == EActions.WATCH_PLAYER)
10497 {
10498 PluginDeveloper.SetDeveloperItemClientEx(player);
10499 }
10500 #endif
10501 if (GetGame().IsServer())
10502 {
10503 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
10504 {
10505 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
10506 OnDebugButtonPressServer(id + 1);
10507 }
10508
10509 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
10510 {
10511 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
10512 InsertAgent(agent_id,100);
10513 }
10514
10515 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
10516 {
10517 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
10518 RemoveAgent(agent_id2);
10519 }
10520
10521 else if (action_id == EActions.ADD_QUANTITY)
10522 {
10523 if (IsMagazine())
10524 {
10525 Magazine mag = Magazine.Cast(this);
10526 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
10527 }
10528 else
10529 {
10530 AddQuantity(GetQuantityMax() * 0.2);
10531 }
10532
10533 if (m_EM)
10534 {
10535 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
10536 }
10537 //PrintVariables();
10538 }
10539
10540 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
10541 {
10542 if (IsMagazine())
10543 {
10544 Magazine mag2 = Magazine.Cast(this);
10545 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
10546 }
10547 else
10548 {
10549 AddQuantity(- GetQuantityMax() * 0.2);
10550 }
10551 if (m_EM)
10552 {
10553 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
10554 }
10555 //PrintVariables();
10556 }
10557
10558 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
10559 {
10560 SetQuantity(0);
10561
10562 if (m_EM)
10563 {
10564 m_EM.SetEnergy(0);
10565 }
10566 }
10567
10568 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
10569 {
10571
10572 if (m_EM)
10573 {
10574 m_EM.SetEnergy(m_EM.GetEnergyMax());
10575 }
10576 }
10577
10578 else if (action_id == EActions.ADD_HEALTH)
10579 {
10580 AddHealth("","",GetMaxHealth("","Health")/5);
10581 }
10582 else if (action_id == EActions.REMOVE_HEALTH)
10583 {
10584 AddHealth("","",-GetMaxHealth("","Health")/5);
10585 }
10586 else if (action_id == EActions.DESTROY_HEALTH)
10587 {
10588 SetHealth01("","",0);
10589 }
10590 else if (action_id == EActions.WATCH_ITEM)
10591 {
10593 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
10594 #ifdef DEVELOPER
10595 SetDebugDeveloper_item(this);
10596 #endif
10597 }
10598
10599 else if (action_id == EActions.ADD_TEMPERATURE)
10600 {
10601 AddTemperature(20);
10602 //PrintVariables();
10603 }
10604
10605 else if (action_id == EActions.REMOVE_TEMPERATURE)
10606 {
10607 AddTemperature(-20);
10608 //PrintVariables();
10609 }
10610
10611 else if (action_id == EActions.FLIP_FROZEN)
10612 {
10613 SetFrozen(!GetIsFrozen());
10614 //PrintVariables();
10615 }
10616
10617 else if (action_id == EActions.ADD_WETNESS)
10618 {
10619 AddWet(GetWetMax()/5);
10620 //PrintVariables();
10621 }
10622
10623 else if (action_id == EActions.REMOVE_WETNESS)
10624 {
10625 AddWet(-GetWetMax()/5);
10626 //PrintVariables();
10627 }
10628
10629 else if (action_id == EActions.LIQUIDTYPE_UP)
10630 {
10631 int curr_type = GetLiquidType();
10632 SetLiquidType(curr_type * 2);
10633 //AddWet(1);
10634 //PrintVariables();
10635 }
10636
10637 else if (action_id == EActions.LIQUIDTYPE_DOWN)
10638 {
10639 int curr_type2 = GetLiquidType();
10640 SetLiquidType(curr_type2 / 2);
10641 }
10642
10643 else if (action_id == EActions.MAKE_SPECIAL)
10644 {
10645 auto debugParams = DebugSpawnParams.WithPlayer(player);
10646 OnDebugSpawnEx(debugParams);
10647 }
10648
10649 }
10650
10651
10652 return false;
10653 }
10654
10655 // -------------------------------------------------------------------------
10656
10657
10660 void OnActivatedByTripWire();
10661
10663 void OnActivatedByItem(notnull ItemBase item);
10664
10665 //----------------------------------------------------------------
10666 //returns true if item is able to explode when put in fire
10667 bool CanExplodeInFire()
10668 {
10669 return false;
10670 }
10671
10672 //----------------------------------------------------------------
10673 bool CanEat()
10674 {
10675 return true;
10676 }
10677
10678 //----------------------------------------------------------------
10679 override bool IsIgnoredByConstruction()
10680 {
10681 return true;
10682 }
10683
10684 //----------------------------------------------------------------
10685 //has FoodStages in config?
10686 bool HasFoodStage()
10687 {
10688 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
10689 return GetGame().ConfigIsExisting(config_path);
10690 }
10691
10693 FoodStage GetFoodStage()
10694 {
10695 return null;
10696 }
10697
10698 bool CanBeCooked()
10699 {
10700 return false;
10701 }
10702
10703 bool CanBeCookedOnStick()
10704 {
10705 return false;
10706 }
10707
10709 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
10711
10712 //----------------------------------------------------------------
10713 bool CanRepair(ItemBase item_repair_kit)
10714 {
10715 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10716 return module_repairing.CanRepair(this, item_repair_kit);
10717 }
10718
10719 //----------------------------------------------------------------
10720 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
10721 {
10722 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10723 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
10724 }
10725
10726 //----------------------------------------------------------------
10727 int GetItemSize()
10728 {
10729 /*
10730 vector v_size = this.ConfigGetVector("itemSize");
10731 int v_size_x = v_size[0];
10732 int v_size_y = v_size[1];
10733 int size = v_size_x * v_size_y;
10734 return size;
10735 */
10736
10737 return 1;
10738 }
10739
10740 //----------------------------------------------------------------
10741 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
10742 bool CanBeMovedOverride()
10743 {
10744 return m_CanBeMovedOverride;
10745 }
10746
10747 //----------------------------------------------------------------
10748 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
10749 void SetCanBeMovedOverride(bool setting)
10750 {
10751 m_CanBeMovedOverride = setting;
10752 }
10753
10754 //----------------------------------------------------------------
10762 void MessageToOwnerStatus(string text)
10763 {
10764 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10765
10766 if (player)
10767 {
10768 player.MessageStatus(text);
10769 }
10770 }
10771
10772 //----------------------------------------------------------------
10780 void MessageToOwnerAction(string text)
10781 {
10782 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10783
10784 if (player)
10785 {
10786 player.MessageAction(text);
10787 }
10788 }
10789
10790 //----------------------------------------------------------------
10798 void MessageToOwnerFriendly(string text)
10799 {
10800 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10801
10802 if (player)
10803 {
10804 player.MessageFriendly(text);
10805 }
10806 }
10807
10808 //----------------------------------------------------------------
10816 void MessageToOwnerImportant(string text)
10817 {
10818 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10819
10820 if (player)
10821 {
10822 player.MessageImportant(text);
10823 }
10824 }
10825
10826 override bool IsItemBase()
10827 {
10828 return true;
10829 }
10830
10831 // Checks if item is of questioned kind
10832 override bool KindOf(string tag)
10833 {
10834 bool found = false;
10835 string item_name = this.GetType();
10836 ref TStringArray item_tag_array = new TStringArray;
10837 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
10838
10839 int array_size = item_tag_array.Count();
10840 for (int i = 0; i < array_size; i++)
10841 {
10842 if (item_tag_array.Get(i) == tag)
10843 {
10844 found = true;
10845 break;
10846 }
10847 }
10848 return found;
10849 }
10850
10851
10852 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
10853 {
10854 //Debug.Log("OnRPC called");
10855 super.OnRPC(sender, rpc_type,ctx);
10856
10857 //Play soundset for attachment locking (ActionLockAttachment.c)
10858 switch (rpc_type)
10859 {
10860 #ifndef SERVER
10861 case ERPCs.RPC_SOUND_LOCK_ATTACH:
10862 Param2<bool, string> p = new Param2<bool, string>(false, "");
10863
10864 if (!ctx.Read(p))
10865 return;
10866
10867 bool play = p.param1;
10868 string soundSet = p.param2;
10869
10870 if (play)
10871 {
10872 if (m_LockingSound)
10873 {
10875 {
10876 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
10877 }
10878 }
10879 else
10880 {
10881 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
10882 }
10883 }
10884 else
10885 {
10886 SEffectManager.DestroyEffect(m_LockingSound);
10887 }
10888
10889 break;
10890 #endif
10891
10892 }
10893
10894 if (GetWrittenNoteData())
10895 {
10896 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
10897 }
10898 }
10899
10900 //-----------------------------
10901 // VARIABLE MANIPULATION SYSTEM
10902 //-----------------------------
10903 int NameToID(string name)
10904 {
10905 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
10906 return plugin.GetID(name);
10907 }
10908
10909 string IDToName(int id)
10910 {
10911 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
10912 return plugin.GetName(id);
10913 }
10914
10916 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
10917 {
10918 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
10919 //read the flags
10920 int varFlags;
10921 if (!ctx.Read(varFlags))
10922 return;
10923
10924 if (varFlags & ItemVariableFlags.FLOAT)
10925 {
10926 ReadVarsFromCTX(ctx);
10927 }
10928 }
10929
10930 override void SerializeNumericalVars(array<float> floats_out)
10931 {
10932 //some variables handled on EntityAI level already!
10933 super.SerializeNumericalVars(floats_out);
10934
10935 // the order of serialization must be the same as the order of de-serialization
10936 //--------------------------------------------
10937 if (IsVariableSet(VARIABLE_QUANTITY))
10938 {
10939 floats_out.Insert(m_VarQuantity);
10940 }
10941 //--------------------------------------------
10942 if (IsVariableSet(VARIABLE_WET))
10943 {
10944 floats_out.Insert(m_VarWet);
10945 }
10946 //--------------------------------------------
10947 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
10948 {
10949 floats_out.Insert(m_VarLiquidType);
10950 }
10951 //--------------------------------------------
10952 if (IsVariableSet(VARIABLE_COLOR))
10953 {
10954 floats_out.Insert(m_ColorComponentR);
10955 floats_out.Insert(m_ColorComponentG);
10956 floats_out.Insert(m_ColorComponentB);
10957 floats_out.Insert(m_ColorComponentA);
10958 }
10959 //--------------------------------------------
10960 if (IsVariableSet(VARIABLE_CLEANNESS))
10961 {
10962 floats_out.Insert(m_Cleanness);
10963 }
10964 }
10965
10966 override void DeSerializeNumericalVars(array<float> floats)
10967 {
10968 //some variables handled on EntityAI level already!
10969 super.DeSerializeNumericalVars(floats);
10970
10971 // the order of serialization must be the same as the order of de-serialization
10972 int index = 0;
10973 int mask = Math.Round(floats.Get(index));
10974
10975 index++;
10976 //--------------------------------------------
10977 if (mask & VARIABLE_QUANTITY)
10978 {
10979 if (m_IsStoreLoad)
10980 {
10981 SetStoreLoadedQuantity(floats.Get(index));
10982 }
10983 else
10984 {
10985 float quantity = floats.Get(index);
10986 SetQuantity(quantity, true, false, false, false);
10987 }
10988 index++;
10989 }
10990 //--------------------------------------------
10991 if (mask & VARIABLE_WET)
10992 {
10993 float wet = floats.Get(index);
10994 SetWet(wet);
10995 index++;
10996 }
10997 //--------------------------------------------
10998 if (mask & VARIABLE_LIQUIDTYPE)
10999 {
11000 int liquidtype = Math.Round(floats.Get(index));
11001 SetLiquidType(liquidtype);
11002 index++;
11003 }
11004 //--------------------------------------------
11005 if (mask & VARIABLE_COLOR)
11006 {
11007 m_ColorComponentR = Math.Round(floats.Get(index));
11008 index++;
11009 m_ColorComponentG = Math.Round(floats.Get(index));
11010 index++;
11011 m_ColorComponentB = Math.Round(floats.Get(index));
11012 index++;
11013 m_ColorComponentA = Math.Round(floats.Get(index));
11014 index++;
11015 }
11016 //--------------------------------------------
11017 if (mask & VARIABLE_CLEANNESS)
11018 {
11019 int cleanness = Math.Round(floats.Get(index));
11020 SetCleanness(cleanness);
11021 index++;
11022 }
11023 }
11024
11025 override void WriteVarsToCTX(ParamsWriteContext ctx)
11026 {
11027 super.WriteVarsToCTX(ctx);
11028
11029 //--------------------------------------------
11030 if (IsVariableSet(VARIABLE_QUANTITY))
11031 {
11032 ctx.Write(GetQuantity());
11033 }
11034 //--------------------------------------------
11035 if (IsVariableSet(VARIABLE_WET))
11036 {
11037 ctx.Write(GetWet());
11038 }
11039 //--------------------------------------------
11040 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11041 {
11042 ctx.Write(GetLiquidType());
11043 }
11044 //--------------------------------------------
11045 if (IsVariableSet(VARIABLE_COLOR))
11046 {
11047 int r,g,b,a;
11048 GetColor(r,g,b,a);
11049 ctx.Write(r);
11050 ctx.Write(g);
11051 ctx.Write(b);
11052 ctx.Write(a);
11053 }
11054 //--------------------------------------------
11055 if (IsVariableSet(VARIABLE_CLEANNESS))
11056 {
11057 ctx.Write(GetCleanness());
11058 }
11059 }
11060
11061 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
11062 {
11063 if (!super.ReadVarsFromCTX(ctx,version))
11064 return false;
11065
11066 int intValue;
11067 float value;
11068
11069 if (version < 140)
11070 {
11071 if (!ctx.Read(intValue))
11072 return false;
11073
11074 m_VariablesMask = intValue;
11075 }
11076
11077 if (m_VariablesMask & VARIABLE_QUANTITY)
11078 {
11079 if (!ctx.Read(value))
11080 return false;
11081
11082 if (IsStoreLoad())
11083 {
11085 }
11086 else
11087 {
11088 SetQuantity(value, true, false, false, false);
11089 }
11090 }
11091 //--------------------------------------------
11092 if (version < 140)
11093 {
11094 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11095 {
11096 if (!ctx.Read(value))
11097 return false;
11098 SetTemperatureDirect(value);
11099 }
11100 }
11101 //--------------------------------------------
11102 if (m_VariablesMask & VARIABLE_WET)
11103 {
11104 if (!ctx.Read(value))
11105 return false;
11106 SetWet(value);
11107 }
11108 //--------------------------------------------
11109 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
11110 {
11111 if (!ctx.Read(intValue))
11112 return false;
11113 SetLiquidType(intValue);
11114 }
11115 //--------------------------------------------
11116 if (m_VariablesMask & VARIABLE_COLOR)
11117 {
11118 int r,g,b,a;
11119 if (!ctx.Read(r))
11120 return false;
11121 if (!ctx.Read(g))
11122 return false;
11123 if (!ctx.Read(b))
11124 return false;
11125 if (!ctx.Read(a))
11126 return false;
11127
11128 SetColor(r,g,b,a);
11129 }
11130 //--------------------------------------------
11131 if (m_VariablesMask & VARIABLE_CLEANNESS)
11132 {
11133 if (!ctx.Read(intValue))
11134 return false;
11135 SetCleanness(intValue);
11136 }
11137 //--------------------------------------------
11138 if (version >= 138 && version < 140)
11139 {
11140 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11141 {
11142 if (!ctx.Read(intValue))
11143 return false;
11144 SetFrozen(intValue);
11145 }
11146 }
11147
11148 return true;
11149 }
11150
11151 //----------------------------------------------------------------
11152 override bool OnStoreLoad(ParamsReadContext ctx, int version)
11153 {
11154 m_IsStoreLoad = true;
11156 {
11157 m_FixDamageSystemInit = true;
11158 }
11159
11160 if (!super.OnStoreLoad(ctx, version))
11161 {
11162 m_IsStoreLoad = false;
11163 return false;
11164 }
11165
11166 if (version >= 114)
11167 {
11168 bool hasQuickBarIndexSaved;
11169
11170 if (!ctx.Read(hasQuickBarIndexSaved))
11171 {
11172 m_IsStoreLoad = false;
11173 return false;
11174 }
11175
11176 if (hasQuickBarIndexSaved)
11177 {
11178 int itmQBIndex;
11179
11180 //Load quickbar item bind
11181 if (!ctx.Read(itmQBIndex))
11182 {
11183 m_IsStoreLoad = false;
11184 return false;
11185 }
11186
11187 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
11188 if (itmQBIndex != -1 && parentPlayer)
11189 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
11190 }
11191 }
11192 else
11193 {
11194 // Backup of how it used to be
11195 PlayerBase player;
11196 int itemQBIndex;
11197 if (version == int.MAX)
11198 {
11199 if (!ctx.Read(itemQBIndex))
11200 {
11201 m_IsStoreLoad = false;
11202 return false;
11203 }
11204 }
11205 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
11206 {
11207 //Load quickbar item bind
11208 if (!ctx.Read(itemQBIndex))
11209 {
11210 m_IsStoreLoad = false;
11211 return false;
11212 }
11213 if (itemQBIndex != -1 && player)
11214 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
11215 }
11216 }
11217
11218 if (version < 140)
11219 {
11220 // variable management system
11221 if (!LoadVariables(ctx, version))
11222 {
11223 m_IsStoreLoad = false;
11224 return false;
11225 }
11226 }
11227
11228 //agent trasmission system
11229 if (!LoadAgents(ctx, version))
11230 {
11231 m_IsStoreLoad = false;
11232 return false;
11233 }
11234 if (version >= 132)
11235 {
11236 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11237 if (raib)
11238 {
11239 if (!raib.OnStoreLoad(ctx,version))
11240 {
11241 m_IsStoreLoad = false;
11242 return false;
11243 }
11244 }
11245 }
11246
11247 m_IsStoreLoad = false;
11248 return true;
11249 }
11250
11251 //----------------------------------------------------------------
11252
11253 override void OnStoreSave(ParamsWriteContext ctx)
11254 {
11255 super.OnStoreSave(ctx);
11256
11257 PlayerBase player;
11258 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
11259 {
11260 ctx.Write(true); // Keep track of if we should actually read this in or not
11261 //Save quickbar item bind
11262 int itemQBIndex = -1;
11263 itemQBIndex = player.FindQuickBarEntityIndex(this);
11264 ctx.Write(itemQBIndex);
11265 }
11266 else
11267 {
11268 ctx.Write(false); // Keep track of if we should actually read this in or not
11269 }
11270
11271 SaveAgents(ctx);//agent trasmission system
11272
11273 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11274 if (raib)
11275 {
11276 raib.OnStoreSave(ctx);
11277 }
11278 }
11279 //----------------------------------------------------------------
11280
11281 override void AfterStoreLoad()
11282 {
11283 super.AfterStoreLoad();
11284
11286 {
11288 }
11289
11290 if (GetStoreLoadedQuantity() != float.LOWEST)
11291 {
11293 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
11294 }
11295 }
11296
11297 override void EEOnAfterLoad()
11298 {
11299 super.EEOnAfterLoad();
11300
11302 {
11303 m_FixDamageSystemInit = false;
11304 }
11305
11308 }
11309
11310 bool CanBeDisinfected()
11311 {
11312 return false;
11313 }
11314
11315
11316 //----------------------------------------------------------------
11317 override void OnVariablesSynchronized()
11318 {
11319 if (m_Initialized)
11320 {
11321 #ifdef PLATFORM_CONSOLE
11322 //bruteforce it is
11323 if (IsSplitable())
11324 {
11325 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
11326 if (menu)
11327 {
11328 menu.Refresh();
11329 }
11330 }
11331 #endif
11332 }
11333
11335 {
11336 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
11337 m_WantPlayImpactSound = false;
11338 }
11339
11341 {
11342 SetWeightDirty();
11344 }
11345 if (m_VarWet != m_VarWetPrev)
11346 {
11349 }
11350
11351 if (m_SoundSyncPlay != 0)
11352 {
11353 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
11354 m_SoundSyncPlay = 0;
11355 }
11356 if (m_SoundSyncStop != 0)
11357 {
11358 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
11359 m_SoundSyncStop = 0;
11360 }
11361
11362 super.OnVariablesSynchronized();
11363 }
11364
11365 //------------------------- Quantity
11366 //----------------------------------------------------------------
11368 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
11369 {
11370 if (!IsServerCheck(allow_client))
11371 return false;
11372
11373 if (!HasQuantity())
11374 return false;
11375
11376 float min = GetQuantityMin();
11377 float max = GetQuantityMax();
11378
11379 if (value <= (min + 0.001))
11380 value = min;
11381
11382 if (value == min)
11383 {
11384 if (destroy_config)
11385 {
11386 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
11387 if (dstr)
11388 {
11389 m_VarQuantity = Math.Clamp(value, min, max);
11390 this.Delete();
11391 return true;
11392 }
11393 }
11394 else if (destroy_forced)
11395 {
11396 m_VarQuantity = Math.Clamp(value, min, max);
11397 this.Delete();
11398 return true;
11399 }
11400 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
11401 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
11402 }
11403
11404 float delta = m_VarQuantity;
11405 m_VarQuantity = Math.Clamp(value, min, max);
11406
11407 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
11408 {
11409 delta = m_VarQuantity - delta;
11410
11411 if (delta)
11412 OnQuantityChanged(delta);
11413 }
11414
11415 SetVariableMask(VARIABLE_QUANTITY);
11416
11417 return false;
11418 }
11419
11420 //----------------------------------------------------------------
11422 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
11423 {
11424 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
11425 }
11426 //----------------------------------------------------------------
11427 void SetQuantityMax()
11428 {
11429 float max = GetQuantityMax();
11430 SetQuantity(max);
11431 }
11432
11433 override void SetQuantityToMinimum()
11434 {
11435 float min = GetQuantityMin();
11436 SetQuantity(min);
11437 }
11438 //----------------------------------------------------------------
11440 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
11441 {
11442 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
11443 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
11444 SetQuantity(result, destroy_config, destroy_forced);
11445 }
11446
11447 //----------------------------------------------------------------
11449 override float GetQuantityNormalized()
11450 {
11451 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
11452 }
11453
11455 {
11456 return GetQuantityNormalized();
11457 }
11458
11459 /*void SetAmmoNormalized(float value)
11460 {
11461 float value_clamped = Math.Clamp(value, 0, 1);
11462 Magazine this_mag = Magazine.Cast(this);
11463 int max_rounds = this_mag.GetAmmoMax();
11464 int result = value * max_rounds;//can the rounded if higher precision is required
11465 this_mag.SetAmmoCount(result);
11466 }*/
11467 //----------------------------------------------------------------
11468 override int GetQuantityMax()
11469 {
11470 int slot = -1;
11471 if (GetInventory())
11472 {
11473 InventoryLocation il = new InventoryLocation;
11474 GetInventory().GetCurrentInventoryLocation(il);
11475 slot = il.GetSlot();
11476 }
11477
11478 return GetTargetQuantityMax(slot);
11479 }
11480
11481 override int GetTargetQuantityMax(int attSlotID = -1)
11482 {
11483 float quantity_max = 0;
11484
11485 if (IsSplitable()) //only stackable/splitable items can check for stack size
11486 {
11487 if (attSlotID != -1)
11488 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
11489
11490 if (quantity_max <= 0)
11491 quantity_max = m_VarStackMax;
11492 }
11493
11494 if (quantity_max <= 0)
11495 quantity_max = m_VarQuantityMax;
11496
11497 return quantity_max;
11498 }
11499 //----------------------------------------------------------------
11500 override int GetQuantityMin()
11501 {
11502 return m_VarQuantityMin;
11503 }
11504 //----------------------------------------------------------------
11505 int GetQuantityInit()
11506 {
11507 return m_VarQuantityInit;
11508 }
11509
11510 //----------------------------------------------------------------
11511 override bool HasQuantity()
11512 {
11513 return !(GetQuantityMax() - GetQuantityMin() == 0);
11514 }
11515
11516 override float GetQuantity()
11517 {
11518 return m_VarQuantity;
11519 }
11520
11521 bool IsFullQuantity()
11522 {
11523 return GetQuantity() >= GetQuantityMax();
11524 }
11525
11526 //Calculates weight of single item without attachments and cargo
11527 override float GetSingleInventoryItemWeightEx()
11528 {
11529 //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
11530 float weightEx = GetWeightEx();//overall weight of the item
11531 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
11532 return weightEx - special;
11533 }
11534
11535 // Obsolete, use GetSingleInventoryItemWeightEx() instead
11537 {
11539 }
11540
11541 override protected float GetWeightSpecialized(bool forceRecalc = false)
11542 {
11543 if (IsSplitable()) //quantity determines size of the stack
11544 {
11545 #ifdef DEVELOPER
11546 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11547 {
11548 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
11549 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
11550 }
11551 #endif
11552
11553 return GetQuantity() * GetConfigWeightModified();
11554 }
11555 else if (HasEnergyManager())// items with energy manager
11556 {
11557 #ifdef DEVELOPER
11558 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11559 {
11560 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
11561 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
11562 }
11563 #endif
11564 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
11565 }
11566 else//everything else
11567 {
11568 #ifdef DEVELOPER
11569 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11570 {
11571 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
11572 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
11573 }
11574 #endif
11575 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
11576 }
11577 }
11578
11580 int GetNumberOfItems()
11581 {
11582 int item_count = 0;
11583 ItemBase item;
11584
11585 if (GetInventory().GetCargo() != NULL)
11586 {
11587 item_count = GetInventory().GetCargo().GetItemCount();
11588 }
11589
11590 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
11591 {
11592 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
11593 if (item)
11594 item_count += item.GetNumberOfItems();
11595 }
11596 return item_count;
11597 }
11598
11600 float GetUnitWeight(bool include_wetness = true)
11601 {
11602 float weight = 0;
11603 float wetness = 1;
11604 if (include_wetness)
11605 wetness += GetWet();
11606 if (IsSplitable()) //quantity determines size of the stack
11607 {
11608 weight = wetness * m_ConfigWeight;
11609 }
11610 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
11611 {
11612 weight = 1;
11613 }
11614 return weight;
11615 }
11616
11617 //-----------------------------------------------------------------
11618
11619 override void ClearInventory()
11620 {
11621 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
11622 {
11623 GameInventory inv = GetInventory();
11624 array<EntityAI> items = new array<EntityAI>;
11625 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
11626 for (int i = 0; i < items.Count(); i++)
11627 {
11628 ItemBase item = ItemBase.Cast(items.Get(i));
11629 if (item)
11630 {
11631 GetGame().ObjectDelete(item);
11632 }
11633 }
11634 }
11635 }
11636
11637 //------------------------- Energy
11638
11639 //----------------------------------------------------------------
11640 float GetEnergy()
11641 {
11642 float energy = 0;
11643 if (HasEnergyManager())
11644 {
11645 energy = GetCompEM().GetEnergy();
11646 }
11647 return energy;
11648 }
11649
11650
11651 override void OnEnergyConsumed()
11652 {
11653 super.OnEnergyConsumed();
11654
11656 }
11657
11658 override void OnEnergyAdded()
11659 {
11660 super.OnEnergyAdded();
11661
11663 }
11664
11665 // Converts energy (from Energy Manager) to quantity, if enabled.
11667 {
11668 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
11669 {
11670 if (HasQuantity())
11671 {
11672 float energy_0to1 = GetCompEM().GetEnergy0To1();
11673 SetQuantityNormalized(energy_0to1);
11674 }
11675 }
11676 }
11677
11678 //----------------------------------------------------------------
11679 float GetHeatIsolationInit()
11680 {
11681 return ConfigGetFloat("heatIsolation");
11682 }
11683
11684 float GetHeatIsolation()
11685 {
11686 return m_HeatIsolation;
11687 }
11688
11689 float GetDryingIncrement(string pIncrementName)
11690 {
11691 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
11692 if (GetGame().ConfigIsExisting(paramPath))
11693 return GetGame().ConfigGetFloat(paramPath);
11694
11695 return 0.0;
11696 }
11697
11698 float GetSoakingIncrement(string pIncrementName)
11699 {
11700 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
11701 if (GetGame().ConfigIsExisting(paramPath))
11702 return GetGame().ConfigGetFloat(paramPath);
11703
11704 return 0.0;
11705 }
11706 //----------------------------------------------------------------
11707 override void SetWet(float value, bool allow_client = false)
11708 {
11709 if (!IsServerCheck(allow_client))
11710 return;
11711
11712 float min = GetWetMin();
11713 float max = GetWetMax();
11714
11715 float previousValue = m_VarWet;
11716
11717 m_VarWet = Math.Clamp(value, min, max);
11718
11719 if (previousValue != m_VarWet)
11720 {
11721 SetVariableMask(VARIABLE_WET);
11722 OnWetChanged(m_VarWet, previousValue);
11723 }
11724 }
11725 //----------------------------------------------------------------
11726 override void AddWet(float value)
11727 {
11728 SetWet(GetWet() + value);
11729 }
11730 //----------------------------------------------------------------
11731 override void SetWetMax()
11732 {
11734 }
11735 //----------------------------------------------------------------
11736 override float GetWet()
11737 {
11738 return m_VarWet;
11739 }
11740 //----------------------------------------------------------------
11741 override float GetWetMax()
11742 {
11743 return m_VarWetMax;
11744 }
11745 //----------------------------------------------------------------
11746 override float GetWetMin()
11747 {
11748 return m_VarWetMin;
11749 }
11750 //----------------------------------------------------------------
11751 override float GetWetInit()
11752 {
11753 return m_VarWetInit;
11754 }
11755 //----------------------------------------------------------------
11756 override void OnWetChanged(float newVal, float oldVal)
11757 {
11758 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
11759 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
11760 if (newLevel != oldLevel)
11761 {
11762 OnWetLevelChanged(newLevel,oldLevel);
11763 }
11764 }
11765
11766 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
11767 {
11768 SetWeightDirty();
11769 }
11770
11771 override EWetnessLevel GetWetLevel()
11772 {
11773 return GetWetLevelInternal(m_VarWet);
11774 }
11775
11776 //----------------------------------------------------------------
11777
11778 override void SetStoreLoad(bool value)
11779 {
11780 m_IsStoreLoad = value;
11781 }
11782
11783 override bool IsStoreLoad()
11784 {
11785 return m_IsStoreLoad;
11786 }
11787
11788 override void SetStoreLoadedQuantity(float value)
11789 {
11790 m_StoreLoadedQuantity = value;
11791 }
11792
11793 override float GetStoreLoadedQuantity()
11794 {
11795 return m_StoreLoadedQuantity;
11796 }
11797
11798 //----------------------------------------------------------------
11799
11800 float GetItemModelLength()
11801 {
11802 if (ConfigIsExisting("itemModelLength"))
11803 {
11804 return ConfigGetFloat("itemModelLength");
11805 }
11806 return 0;
11807 }
11808
11809 float GetItemAttachOffset()
11810 {
11811 if (ConfigIsExisting("itemAttachOffset"))
11812 {
11813 return ConfigGetFloat("itemAttachOffset");
11814 }
11815 return 0;
11816 }
11817
11818 override void SetCleanness(int value, bool allow_client = false)
11819 {
11820 if (!IsServerCheck(allow_client))
11821 return;
11822
11823 int previousValue = m_Cleanness;
11824
11825 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
11826
11827 if (previousValue != m_Cleanness)
11828 SetVariableMask(VARIABLE_CLEANNESS);
11829 }
11830
11831 override int GetCleanness()
11832 {
11833 return m_Cleanness;
11834 }
11835
11837 {
11838 return true;
11839 }
11840
11841 //----------------------------------------------------------------
11842 // ATTACHMENT LOCKING
11843 // Getters relevant to generic ActionLockAttachment
11844 int GetLockType()
11845 {
11846 return m_LockType;
11847 }
11848
11849 string GetLockSoundSet()
11850 {
11851 return m_LockSoundSet;
11852 }
11853
11854 //----------------------------------------------------------------
11855 //------------------------- Color
11856 // sets items color variable given color components
11857 override void SetColor(int r, int g, int b, int a)
11858 {
11863 SetVariableMask(VARIABLE_COLOR);
11864 }
11866 override void GetColor(out int r,out int g,out int b,out int a)
11867 {
11872 }
11873
11874 bool IsColorSet()
11875 {
11876 return IsVariableSet(VARIABLE_COLOR);
11877 }
11878
11880 string GetColorString()
11881 {
11882 int r,g,b,a;
11883 GetColor(r,g,b,a);
11884 r = r/255;
11885 g = g/255;
11886 b = b/255;
11887 a = a/255;
11888 return MiscGameplayFunctions.GetColorString(r, g, b, a);
11889 }
11890 //----------------------------------------------------------------
11891 //------------------------- LiquidType
11892
11893 override void SetLiquidType(int value, bool allow_client = false)
11894 {
11895 if (!IsServerCheck(allow_client))
11896 return;
11897
11898 int old = m_VarLiquidType;
11899 m_VarLiquidType = value;
11900 OnLiquidTypeChanged(old,value);
11901 SetVariableMask(VARIABLE_LIQUIDTYPE);
11902 }
11903
11904 int GetLiquidTypeInit()
11905 {
11906 return ConfigGetInt("varLiquidTypeInit");
11907 }
11908
11909 override int GetLiquidType()
11910 {
11911 return m_VarLiquidType;
11912 }
11913
11914 protected void OnLiquidTypeChanged(int oldType, int newType)
11915 {
11916 if (newType == LIQUID_NONE && GetIsFrozen())
11917 SetFrozen(false);
11918 }
11919
11921 void UpdateQuickbarShortcutVisibility(PlayerBase player)
11922 {
11923 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
11924 }
11925
11926 // -------------------------------------------------------------------------
11928 void OnInventoryEnter(Man player)
11929 {
11930 PlayerBase nplayer;
11931 if (PlayerBase.CastTo(nplayer, player))
11932 {
11933 m_CanPlayImpactSound = true;
11934 //nplayer.OnItemInventoryEnter(this);
11935 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
11936 }
11937 }
11938
11939 // -------------------------------------------------------------------------
11941 void OnInventoryExit(Man player)
11942 {
11943 PlayerBase nplayer;
11944 if (PlayerBase.CastTo(nplayer,player))
11945 {
11946 //nplayer.OnItemInventoryExit(this);
11947 nplayer.SetEnableQuickBarEntityShortcut(this,false);
11948
11949 }
11950
11951 //if (!GetGame().IsDedicatedServer())
11952 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
11953
11954
11955 if (HasEnergyManager())
11956 {
11957 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
11958 }
11959 }
11960
11961 // ADVANCED PLACEMENT EVENTS
11962 override void OnPlacementStarted(Man player)
11963 {
11964 super.OnPlacementStarted(player);
11965
11966 SetTakeable(false);
11967 }
11968
11969 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
11970 {
11971 if (m_AdminLog)
11972 {
11973 m_AdminLog.OnPlacementComplete(player, this);
11974 }
11975
11976 super.OnPlacementComplete(player, position, orientation);
11977 }
11978
11979 //-----------------------------
11980 // AGENT SYSTEM
11981 //-----------------------------
11982 //--------------------------------------------------------------------------
11983 bool ContainsAgent(int agent_id)
11984 {
11985 if (agent_id & m_AttachedAgents)
11986 {
11987 return true;
11988 }
11989 else
11990 {
11991 return false;
11992 }
11993 }
11994
11995 //--------------------------------------------------------------------------
11996 override void RemoveAgent(int agent_id)
11997 {
11998 if (ContainsAgent(agent_id))
11999 {
12000 m_AttachedAgents = ~agent_id & m_AttachedAgents;
12001 }
12002 }
12003
12004 //--------------------------------------------------------------------------
12005 override void RemoveAllAgents()
12006 {
12007 m_AttachedAgents = 0;
12008 }
12009 //--------------------------------------------------------------------------
12010 override void RemoveAllAgentsExcept(int agent_to_keep)
12011 {
12012 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
12013 }
12014 // -------------------------------------------------------------------------
12015 override void InsertAgent(int agent, float count = 1)
12016 {
12017 if (count < 1)
12018 return;
12019 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
12021 }
12022
12024 void TransferAgents(int agents)
12025 {
12027 }
12028
12029 // -------------------------------------------------------------------------
12030 override int GetAgents()
12031 {
12032 return m_AttachedAgents;
12033 }
12034 //----------------------------------------------------------------------
12035
12036 /*int GetContaminationType()
12037 {
12038 int contamination_type;
12039
12040 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
12041 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
12042 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
12043 const int DIRTY_MASK = eAgents.WOUND_AGENT;
12044
12045 Edible_Base edible = Edible_Base.Cast(this);
12046 int agents = GetAgents();
12047 if (edible)
12048 {
12049 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
12050 if (profile)
12051 {
12052 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
12053 }
12054 }
12055 if (agents & CONTAMINATED_MASK)
12056 {
12057 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
12058 }
12059 if (agents & POISONED_MASK)
12060 {
12061 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
12062 }
12063 if (agents & NERVE_GAS_MASK)
12064 {
12065 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
12066 }
12067 if (agents & DIRTY_MASK)
12068 {
12069 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
12070 }
12071
12072 return agents;
12073 }*/
12074
12075 // -------------------------------------------------------------------------
12076 bool LoadAgents(ParamsReadContext ctx, int version)
12077 {
12078 if (!ctx.Read(m_AttachedAgents))
12079 return false;
12080 return true;
12081 }
12082 // -------------------------------------------------------------------------
12084 {
12085
12087 }
12088 // -------------------------------------------------------------------------
12089
12091 override void CheckForRoofLimited(float timeTresholdMS = 3000)
12092 {
12093 super.CheckForRoofLimited(timeTresholdMS);
12094
12095 float time = GetGame().GetTime();
12096 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
12097 {
12098 m_PreviousRoofTestTime = time;
12099 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
12100 }
12101 }
12102
12103 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
12104 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
12105 {
12106 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
12107 {
12108 return 0;
12109 }
12110
12111 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
12112 {
12113 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
12114 if (filter)
12115 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
12116 else
12117 return 0;//otherwise return 0 when no filter attached
12118 }
12119
12120 string subclassPath, entryName;
12121
12122 switch (type)
12123 {
12124 case DEF_BIOLOGICAL:
12125 entryName = "biological";
12126 break;
12127 case DEF_CHEMICAL:
12128 entryName = "chemical";
12129 break;
12130 default:
12131 entryName = "biological";
12132 break;
12133 }
12134
12135 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
12136
12137 return GetGame().ConfigGetFloat(subclassPath + entryName);
12138 }
12139
12140
12141
12143 override void EEOnCECreate()
12144 {
12145 if (!IsMagazine())
12147
12149 }
12150
12151
12152 //-------------------------
12153 // OPEN/CLOSE USER ACTIONS
12154 //-------------------------
12156 void Open();
12157 void Close();
12158 bool IsOpen()
12159 {
12160 return true;
12161 }
12162
12163 override bool CanDisplayCargo()
12164 {
12165 return IsOpen();
12166 }
12167
12168
12169 // ------------------------------------------------------------
12170 // CONDITIONS
12171 // ------------------------------------------------------------
12172 override bool CanPutInCargo(EntityAI parent)
12173 {
12174 if (parent)
12175 {
12176 if (parent.IsInherited(DayZInfected))
12177 return true;
12178
12179 if (!parent.IsRuined())
12180 return true;
12181 }
12182
12183 return true;
12184 }
12185
12186 override bool CanPutAsAttachment(EntityAI parent)
12187 {
12188 if (!super.CanPutAsAttachment(parent))
12189 {
12190 return false;
12191 }
12192
12193 if (!IsRuined() && !parent.IsRuined())
12194 {
12195 return true;
12196 }
12197
12198 return false;
12199 }
12200
12201 override bool CanReceiveItemIntoCargo(EntityAI item)
12202 {
12203 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12204 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12205 // return false;
12206
12207 return super.CanReceiveItemIntoCargo(item);
12208 }
12209
12210 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
12211 {
12212 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12213 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12214 // return false;
12215
12216 GameInventory attachmentInv = attachment.GetInventory();
12217 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12218 {
12219 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12220 return false;
12221 }
12222
12223 InventoryLocation loc = new InventoryLocation();
12224 attachment.GetInventory().GetCurrentInventoryLocation(loc);
12225 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
12226 return false;
12227
12228 return super.CanReceiveAttachment(attachment, slotId);
12229 }
12230
12231 override bool CanReleaseAttachment(EntityAI attachment)
12232 {
12233 if (!super.CanReleaseAttachment(attachment))
12234 return false;
12235
12236 return GetInventory().AreChildrenAccessible();
12237 }
12238
12239 /*override bool CanLoadAttachment(EntityAI attachment)
12240 {
12241 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12242 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12243 // return false;
12244
12245 GameInventory attachmentInv = attachment.GetInventory();
12246 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12247 {
12248 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
12249 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
12250
12251 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12252 return false;
12253 }
12254
12255 return super.CanLoadAttachment(attachment);
12256 }*/
12257
12258 // Plays muzzle flash particle effects
12259 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12260 {
12261 int id = muzzle_owner.GetMuzzleID();
12262 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
12263
12264 if (WPOF_array)
12265 {
12266 for (int i = 0; i < WPOF_array.Count(); i++)
12267 {
12268 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
12269
12270 if (WPOF)
12271 {
12272 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
12273 }
12274 }
12275 }
12276 }
12277
12278 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
12279 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12280 {
12281 int id = muzzle_owner.GetMuzzleID();
12282 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
12283
12284 if (WPOBE_array)
12285 {
12286 for (int i = 0; i < WPOBE_array.Count(); i++)
12287 {
12288 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
12289
12290 if (WPOBE)
12291 {
12292 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12293 }
12294 }
12295 }
12296 }
12297
12298 // Plays all weapon overheating particles
12299 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12300 {
12301 int id = muzzle_owner.GetMuzzleID();
12302 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12303
12304 if (WPOOH_array)
12305 {
12306 for (int i = 0; i < WPOOH_array.Count(); i++)
12307 {
12308 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12309
12310 if (WPOOH)
12311 {
12312 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12313 }
12314 }
12315 }
12316 }
12317
12318 // Updates all weapon overheating particles
12319 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12320 {
12321 int id = muzzle_owner.GetMuzzleID();
12322 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12323
12324 if (WPOOH_array)
12325 {
12326 for (int i = 0; i < WPOOH_array.Count(); i++)
12327 {
12328 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12329
12330 if (WPOOH)
12331 {
12332 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
12333 }
12334 }
12335 }
12336 }
12337
12338 // Stops overheating particles
12339 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12340 {
12341 int id = muzzle_owner.GetMuzzleID();
12342 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12343
12344 if (WPOOH_array)
12345 {
12346 for (int i = 0; i < WPOOH_array.Count(); i++)
12347 {
12348 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12349
12350 if (WPOOH)
12351 {
12352 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
12353 }
12354 }
12355 }
12356 }
12357
12358 //----------------------------------------------------------------
12359 //Item Behaviour - unified approach
12360 override bool IsHeavyBehaviour()
12361 {
12362 if (m_ItemBehaviour == 0)
12363 {
12364 return true;
12365 }
12366
12367 return false;
12368 }
12369
12370 override bool IsOneHandedBehaviour()
12371 {
12372 if (m_ItemBehaviour == 1)
12373 {
12374 return true;
12375 }
12376
12377 return false;
12378 }
12379
12380 override bool IsTwoHandedBehaviour()
12381 {
12382 if (m_ItemBehaviour == 2)
12383 {
12384 return true;
12385 }
12386
12387 return false;
12388 }
12389
12390 bool IsDeployable()
12391 {
12392 return false;
12393 }
12394
12396 float GetDeployTime()
12397 {
12398 return UATimeSpent.DEFAULT_DEPLOY;
12399 }
12400
12401
12402 //----------------------------------------------------------------
12403 // Item Targeting (User Actions)
12404 override void SetTakeable(bool pState)
12405 {
12406 m_IsTakeable = pState;
12407 SetSynchDirty();
12408 }
12409
12410 override bool IsTakeable()
12411 {
12412 return m_IsTakeable;
12413 }
12414
12415 // For cases where we want to show object widget which cant be taken to hands
12417 {
12418 return false;
12419 }
12420
12422 protected void PreLoadSoundAttachmentType()
12423 {
12424 string att_type = "None";
12425
12426 if (ConfigIsExisting("soundAttType"))
12427 {
12428 att_type = ConfigGetString("soundAttType");
12429 }
12430
12431 m_SoundAttType = att_type;
12432 }
12433
12434 override string GetAttachmentSoundType()
12435 {
12436 return m_SoundAttType;
12437 }
12438
12439 //----------------------------------------------------------------
12440 //SOUNDS - ItemSoundHandler
12441 //----------------------------------------------------------------
12442
12443 string GetPlaceSoundset(); // played when deploy starts
12444 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
12445 string GetDeploySoundset(); // played when deploy sucessfully finishes
12446 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
12447 string GetFoldSoundset(); // played when fold sucessfully finishes
12448
12450 {
12451 if (!m_ItemSoundHandler)
12453
12454 return m_ItemSoundHandler;
12455 }
12456
12457 // override to initialize sounds
12458 protected void InitItemSounds()
12459 {
12460 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
12461 return;
12462
12464
12465 if (GetPlaceSoundset() != string.Empty)
12466 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
12467
12468 if (GetDeploySoundset() != string.Empty)
12469 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
12470
12471 SoundParameters params = new SoundParameters();
12472 params.m_Loop = true;
12473 if (GetLoopDeploySoundset() != string.Empty)
12474 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
12475 }
12476
12477 // Start sound using ItemSoundHandler
12478 void StartItemSoundServer(int id)
12479 {
12480 if (!GetGame().IsServer())
12481 return;
12482
12483 m_SoundSyncPlay = id;
12484 SetSynchDirty();
12485
12486 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
12488 }
12489
12490 // Stop sound using ItemSoundHandler
12491 void StopItemSoundServer(int id)
12492 {
12493 if (!GetGame().IsServer())
12494 return;
12495
12496 m_SoundSyncStop = id;
12497 SetSynchDirty();
12498
12499 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
12501 }
12502
12503 protected void ClearStartItemSoundServer()
12504 {
12505 m_SoundSyncPlay = 0;
12506 }
12507
12508 protected void ClearStopItemSoundServer()
12509 {
12510 m_SoundSyncStop = 0;
12511 }
12512
12514 void PlayAttachSound(string slot_type)
12515 {
12516 if (!GetGame().IsDedicatedServer())
12517 {
12518 if (ConfigIsExisting("attachSoundSet"))
12519 {
12520 string cfg_path = "";
12521 string soundset = "";
12522 string type_name = GetType();
12523
12524 TStringArray cfg_soundset_array = new TStringArray;
12525 TStringArray cfg_slot_array = new TStringArray;
12526 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
12527 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
12528
12529 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
12530 {
12531 for (int i = 0; i < cfg_soundset_array.Count(); i++)
12532 {
12533 if (cfg_slot_array[i] == slot_type)
12534 {
12535 soundset = cfg_soundset_array[i];
12536 break;
12537 }
12538 }
12539 }
12540
12541 if (soundset != "")
12542 {
12543 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
12544 sound.SetAutodestroy(true);
12545 }
12546 }
12547 }
12548 }
12549
12550 void PlayDetachSound(string slot_type)
12551 {
12552 //TODO - evaluate if needed and devise universal config structure if so
12553 }
12554
12555 void OnApply(PlayerBase player);
12556
12558 {
12559 return 1.0;
12560 };
12561 //returns applicable selection
12562 array<string> GetHeadHidingSelection()
12563 {
12565 }
12566
12568 {
12570 }
12571
12572 WrittenNoteData GetWrittenNoteData() {};
12573
12575 {
12576 SetDynamicPhysicsLifeTime(0.01);
12577 m_ItemBeingDroppedPhys = false;
12578 }
12579
12581 {
12582 array<string> zone_names = new array<string>;
12583 GetDamageZones(zone_names);
12584 for (int i = 0; i < zone_names.Count(); i++)
12585 {
12586 SetHealthMax(zone_names.Get(i),"Health");
12587 }
12588 SetHealthMax("","Health");
12589 }
12590
12592 void SetZoneDamageCEInit()
12593 {
12594 float global_health = GetHealth01("","Health");
12595 array<string> zones = new array<string>;
12596 GetDamageZones(zones);
12597 //set damage of all zones to match global health level
12598 for (int i = 0; i < zones.Count(); i++)
12599 {
12600 SetHealth01(zones.Get(i),"Health",global_health);
12601 }
12602 }
12603
12605 bool IsCoverFaceForShave(string slot_name)
12606 {
12607 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
12608 }
12609
12610 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12611 {
12612 if (!hasRootAsPlayer)
12613 {
12614 if (refParentIB)
12615 {
12616 // parent is wet
12617 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
12618 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
12619 // parent has liquid inside
12620 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
12621 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
12622 // drying
12623 else if (m_VarWet > m_VarWetMin)
12624 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
12625 }
12626 else
12627 {
12628 // drying on ground or inside non-itembase (car, ...)
12629 if (m_VarWet > m_VarWetMin)
12630 AddWet(-1 * delta * GetDryingIncrement("ground"));
12631 }
12632 }
12633 }
12634
12635 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12636 {
12638 {
12639 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
12640 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
12641 {
12642 float heatPermCoef = 1.0;
12643 EntityAI ent = this;
12644 while (ent)
12645 {
12646 heatPermCoef *= ent.GetHeatPermeabilityCoef();
12647 ent = ent.GetHierarchyParent();
12648 }
12649
12650 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
12651 }
12652 }
12653 }
12654
12655 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
12656 {
12657 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
12658 EntityAI parent = GetHierarchyParent();
12659 if (!parent)
12660 {
12661 hasParent = false;
12662 hasRootAsPlayer = false;
12663 }
12664 else
12665 {
12666 hasParent = true;
12667 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
12668 refParentIB = ItemBase.Cast(parent);
12669 }
12670 }
12671
12672 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
12673 {
12674 // this is stub, implemented on Edible_Base
12675 }
12676
12677 bool CanDecay()
12678 {
12679 // return true used on selected food clases so they can decay
12680 return false;
12681 }
12682
12683 protected bool CanProcessDecay()
12684 {
12685 // this is stub, implemented on Edible_Base class
12686 // used to determine whether it is still necessary for the food to decay
12687 return false;
12688 }
12689
12690 protected bool CanHaveWetness()
12691 {
12692 // return true used on selected items that have a wetness effect
12693 return false;
12694 }
12695
12697 bool CanBeConsumed(ConsumeConditionData data = null)
12698 {
12699 return !GetIsFrozen() && IsOpen();
12700 }
12701
12702 override void ProcessVariables()
12703 {
12704 bool hasParent = false, hasRootAsPlayer = false;
12705 ItemBase refParentIB;
12706
12707 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
12708 bool foodDecay = g_Game.IsFoodDecayEnabled();
12709
12710 if (wwtu || foodDecay)
12711 {
12712 bool processWetness = wwtu && CanHaveWetness();
12713 bool processTemperature = wwtu && CanHaveTemperature();
12714 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
12715
12716 if (processWetness || processTemperature || processDecay)
12717 {
12718 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
12719
12720 if (processWetness)
12721 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12722
12723 if (processTemperature)
12724 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12725
12726 if (processDecay)
12727 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
12728 }
12729 }
12730 }
12731
12734 {
12735 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
12736 }
12737
12738 override float GetTemperatureFreezeThreshold()
12739 {
12741 return Liquid.GetFreezeThreshold(GetLiquidType());
12742
12743 return super.GetTemperatureFreezeThreshold();
12744 }
12745
12746 override float GetTemperatureThawThreshold()
12747 {
12749 return Liquid.GetThawThreshold(GetLiquidType());
12750
12751 return super.GetTemperatureThawThreshold();
12752 }
12753
12754 override float GetItemOverheatThreshold()
12755 {
12757 return Liquid.GetBoilThreshold(GetLiquidType());
12758
12759 return super.GetItemOverheatThreshold();
12760 }
12761
12762 override float GetTemperatureFreezeTime()
12763 {
12764 if (HasQuantity())
12765 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
12766
12767 return super.GetTemperatureFreezeTime();
12768 }
12769
12770 override float GetTemperatureThawTime()
12771 {
12772 if (HasQuantity())
12773 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
12774
12775 return super.GetTemperatureThawTime();
12776 }
12777
12779 void AffectLiquidContainerOnFill(int liquid_type, float amount);
12781 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
12782
12783 bool IsCargoException4x3(EntityAI item)
12784 {
12785 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
12786 }
12787
12789 {
12790 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
12791 }
12792
12794 void AddLightSourceItem(ItemBase lightsource)
12795 {
12796 m_LightSourceItem = lightsource;
12797 }
12798
12800 {
12801 m_LightSourceItem = null;
12802 }
12803
12805 {
12806 return m_LightSourceItem;
12807 }
12808
12810 array<int> GetValidFinishers()
12811 {
12812 return null;
12813 }
12814
12816 bool GetActionWidgetOverride(out typename name)
12817 {
12818 return false;
12819 }
12820
12821 bool PairWithDevice(notnull ItemBase otherDevice)
12822 {
12823 if (GetGame().IsServer())
12824 {
12825 ItemBase explosive = otherDevice;
12827 if (!trg)
12828 {
12829 trg = RemoteDetonatorTrigger.Cast(otherDevice);
12830 explosive = this;
12831 }
12832
12833 explosive.PairRemote(trg);
12834 trg.SetControlledDevice(explosive);
12835
12836 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
12837 trg.SetPersistentPairID(persistentID);
12838 explosive.SetPersistentPairID(persistentID);
12839
12840 return true;
12841 }
12842 return false;
12843 }
12844
12846 float GetBaitEffectivity()
12847 {
12848 float ret = 1.0;
12849 if (HasQuantity())
12850 ret *= GetQuantityNormalized();
12851 ret *= GetHealth01();
12852
12853 return ret;
12854 }
12855
12856 #ifdef DEVELOPER
12857 override void SetDebugItem()
12858 {
12859 super.SetDebugItem();
12860 _itemBase = this;
12861 }
12862
12863 override string GetDebugText()
12864 {
12865 string text = super.GetDebugText();
12866
12867 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
12868 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
12869
12870 return text;
12871 }
12872 #endif
12873
12874 bool CanBeUsedForSuicide()
12875 {
12876 return true;
12877 }
12878
12880 //DEPRECATED BELOW
12882 // Backwards compatibility
12883 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12884 {
12885 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
12886 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
12887 }
12888
12889 // replaced by ItemSoundHandler
12890 protected EffectSound m_SoundDeployFinish;
12891 protected EffectSound m_SoundPlace;
12892 protected EffectSound m_DeployLoopSoundEx;
12893 protected EffectSound m_SoundDeploy;
12894 bool m_IsPlaceSound;
12895 bool m_IsDeploySound;
12897
12898 string GetDeployFinishSoundset();
12899 void PlayDeploySound();
12900 void PlayDeployFinishSound();
12901 void PlayPlaceSound();
12902 void PlayDeployLoopSoundEx();
12903 void StopDeployLoopSoundEx();
12904 void SoundSynchRemoteReset();
12905 void SoundSynchRemote();
12906 bool UsesGlobalDeploy(){return false;}
12907 bool CanPlayDeployLoopSound(){return false;}
12909 bool IsPlaceSound(){return m_IsPlaceSound;}
12910 bool IsDeploySound(){return m_IsDeploySound;}
12911 void SetIsPlaceSound(bool is_place_sound);
12912 void SetIsDeploySound(bool is_deploy_sound);
12913}
12914
12915EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
12916{
12917 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
12918 if (entity)
12919 {
12920 bool is_item = entity.IsInherited(ItemBase);
12921 if (is_item && full_quantity)
12922 {
12923 ItemBase item = ItemBase.Cast(entity);
12924 item.SetQuantity(item.GetQuantityInit());
12925 }
12926 }
12927 else
12928 {
12929 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
12930 return NULL;
12931 }
12932 return entity;
12933}
12934
12935void SetupSpawnedItem(ItemBase item, float health, float quantity)
12936{
12937 if (item)
12938 {
12939 if (health > 0)
12940 item.SetHealth("", "", health);
12941
12942 if (item.CanHaveTemperature())
12943 {
12944 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
12945 if (item.CanFreeze())
12946 item.SetFrozen(false);
12947 }
12948
12949 if (item.HasEnergyManager())
12950 {
12951 if (quantity >= 0)
12952 {
12953 item.GetCompEM().SetEnergy0To1(quantity);
12954 }
12955 else
12956 {
12957 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
12958 }
12959 }
12960 else if (item.IsMagazine())
12961 {
12962 Magazine mag = Magazine.Cast(item);
12963 if (quantity >= 0)
12964 {
12965 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
12966 }
12967 else
12968 {
12969 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
12970 }
12971
12972 }
12973 else
12974 {
12975 if (quantity >= 0)
12976 {
12977 item.SetQuantityNormalized(quantity, false);
12978 }
12979 else
12980 {
12981 item.SetQuantity(Math.AbsFloat(quantity));
12982 }
12983
12984 }
12985 }
12986}
12987
12988#ifdef DEVELOPER
12989ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
12990#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Определения 3_Game/Entities/EntityAI.c:97
Param3 TSelectableActionInfo
EWetnessLevel
Определения 3_Game/Entities/EntityAI.c:2
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
const int INPUT_UDT_ITEM_MANIPULATION
class LogManager EntityAI
eBleedingSourceType GetType()
ItemSuppressor SuppressorBase
void ActionDropItem()
Определения ActionDropItem.c:14
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Определения ActionManagerClient.c:1
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void RemoveAction(typename actionName)
Определения AdvancedCommunication.c:252
TInputActionMap m_InputActionMap
Определения AdvancedCommunication.c:137
bool m_ActionsInitialize
Определения AdvancedCommunication.c:138
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Определения AdvancedCommunication.c:202
void InitializeActions()
Определения AdvancedCommunication.c:190
int GetLiquidType()
Определения CCTWaterSurface.c:129
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:36
const int RF_DEFAULT
Определения CentralEconomy.c:65
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
Open
Implementations only.
override void EEOnCECreate()
Определения ContaminatedArea_Dynamic.c:42
map
Определения ControlsXboxNew.c:4
CookingMethodType
Определения Cooking.c:2
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
DayZGame g_Game
Определения DayZGame.c:3868
DayZGame GetDayZGame()
Определения DayZGame.c:3870
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
PluginAdminLog m_AdminLog
Определения EmoteManager.c:142
const int MAX
Определения EnConvert.c:27
float GetTemperature()
Определения Environment.c:497
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool CanHaveTemperature()
Определения FireplaceBase.c:559
class GP5GasMask extends MaskBase ItemBase
Empty
Определения Hand_States.c:14
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool DamageItemInCargo(float damage)
Определения ItemBase.c:6380
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5620
bool HidesSelectionBySlot()
Определения ItemBase.c:9347
float m_VarWetMin
Определения ItemBase.c:4881
void SplitItem(PlayerBase player)
Определения ItemBase.c:6831
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9568
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8795
override float GetQuantityNormalized()
Gets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8229
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5625
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:8938
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6798
override bool IsHeavyBehaviour()
Определения ItemBase.c:9140
override void SetWetMax()
Определения ItemBase.c:8511
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9385
void ClearStartItemSoundServer()
Определения ItemBase.c:9283
float m_VarWet
Определения ItemBase.c:4878
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9415
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:2
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8790
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4941
bool CanBeMovedOverride()
Определения ItemBase.c:7522
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8487
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4927
override void ProcessVariables()
Определения ItemBase.c:9482
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:4955
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8321
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8856
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8701
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5211
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:4953
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9518
bool m_IsSoundSynchRemote
Определения ItemBase.c:9676
float m_OverheatingShots
Определения ItemBase.c:4948
void StopItemSoundServer(int id)
Определения ItemBase.c:9271
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5640
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5364
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9542
ref array< int > m_CompatibleLocks
Определения ItemBase.c:4965
bool CanBeCooked()
Определения ItemBase.c:7478
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5707
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:4977
bool m_RecipesInitialized
Определения ItemBase.c:4863
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6471
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9526
override void OnEnergyConsumed()
Определения ItemBase.c:8431
void RefreshAudioVisualsOnClient(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
cooking-related effect methods
Определения Bottle_Base.c:158
int GetNumberOfItems()
Returns the number of items in cargo, otherwise returns 0(non-cargo objects). Recursive.
Определения ItemBase.c:8360
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8551
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8316
ref TIntArray m_InteractActions
Определения ItemBase.c:4929
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7542
float m_VarQuantity
Определения ItemBase.c:4869
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9687
override float GetWetMax()
Определения ItemBase.c:8521
bool CanBeUsedForSuicide()
Определения ItemBase.c:9654
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7117
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5845
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7696
void StartItemSoundServer(int id)
Определения ItemBase.c:9258
void DoAmmoExplosion()
Определения ItemBase.c:6315
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4940
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6655
int GetItemSize()
Определения ItemBase.c:7507
bool m_CanBeMovedOverride
Определения ItemBase.c:4906
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6239
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5432
bool CanDecay()
Определения ItemBase.c:9457
ScriptedLightBase GetLight()
string GetPlaceSoundset()
bool AddQuantity(float value, bool destroy_config=true, bool destroy_forced=false)
add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Определения ItemBase.c:8202
void SetQuantityMax()
Определения ItemBase.c:8207
override float GetQuantity()
Определения ItemBase.c:8296
int m_ColorComponentR
Определения ItemBase.c:4918
int m_ShotsToStartOverheating
Определения ItemBase.c:4950
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8536
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5439
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9039
void OnOverheatingDecay()
Определения ItemBase.c:5402
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8469
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4884
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5540
bool UsesGlobalDeploy()
Определения ItemBase.c:9686
int m_ItemBehaviour
Определения ItemBase.c:4899
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:9011
float m_HeatIsolation
Определения ItemBase.c:4894
float m_VarWetInit
Определения ItemBase.c:4880
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5885
void SetCEBasedQuantity()
Определения ItemBase.c:5653
bool m_CanPlayImpactSound
Определения ItemBase.c:4890
override string GetAttachmentSoundType()
Определения ItemBase.c:9214
float GetOverheatingCoef()
Определения ItemBase.c:5459
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9342
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9294
override bool IsStoreLoad()
Определения ItemBase.c:8563
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7093
bool IsLightSource()
Определения ItemBase.c:5781
bool m_HasQuantityBar
Определения ItemBase.c:4912
void SetResultOfSplit(bool value)
Определения ItemBase.c:7088
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6719
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6889
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5467
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8478
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9119
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8573
int m_LockType
Определения ItemBase.c:4966
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:4971
bool m_CanBeDigged
Определения ItemBase.c:4913
float m_ItemAttachOffset
Определения ItemBase.c:4896
float GetItemModelLength()
Определения ItemBase.c:8580
bool m_ThrowItemOnDrop
Определения ItemBase.c:4904
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7841
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8871
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8464
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7122
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9513
bool CanHaveWetness()
Определения ItemBase.c:9470
int m_CleannessMin
Определения ItemBase.c:4886
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8804
string IDToName(int id)
Определения ItemBase.c:7689
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9477
float GetHeatIsolationInit()
Определения ItemBase.c:8459
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7529
override bool HasQuantity()
Определения ItemBase.c:8291
float m_VarWetPrev
Определения ItemBase.c:4879
int m_SoundSyncStop
Определения ItemBase.c:4973
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9563
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4928
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5549
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5234
int m_VarLiquidType
Определения ItemBase.c:4898
int m_QuickBarBonus
Определения ItemBase.c:4900
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9202
override float GetWetInit()
Определения ItemBase.c:8531
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4892
int m_SoundSyncPlay
Определения ItemBase.c:4972
int m_MaxOverheatingValue
Определения ItemBase.c:4951
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4875
bool m_IsTakeable
Определения ItemBase.c:4903
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:6428
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4943
string GetLockSoundSet()
Определения ItemBase.c:8629
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8660
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9590
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6895
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4855
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9229
override int GetQuantityMin()
Определения ItemBase.c:8280
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6634
override int GetQuickBarBonus()
Определения ItemBase.c:5119
override void SetTakeable(bool pState)
Определения ItemBase.c:9184
float m_OverheatingDecayInterval
Определения ItemBase.c:4952
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6448
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9435
bool CanProcessDecay()
Определения ItemBase.c:9463
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5630
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9579
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7493
bool can_this_be_combined
Определения ItemBase.c:4908
EffectSound m_SoundDeploy
Определения ItemBase.c:9673
int m_Count
Определения ItemBase.c:4874
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9626
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9176
override bool IsSplitable()
Определения ItemBase.c:6415
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6399
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7805
void ConvertEnergyToQuantity()
Определения ItemBase.c:8446
override void RemoveAllAgents()
Определения ItemBase.c:8785
override void SetQuantityToMinimum()
Определения ItemBase.c:8213
bool m_WantPlayImpactSound
Определения ItemBase.c:4889
override float GetTemperatureThawTime()
Определения ItemBase.c:9550
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4942
int m_ColorComponentG
Определения ItemBase.c:4919
float m_StoreLoadedQuantity
Определения ItemBase.c:4876
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7560
int m_ColorComponentA
Определения ItemBase.c:4921
int m_VarQuantityInit
Определения ItemBase.c:4871
float GetFilterDamageRatio()
Определения ItemBase.c:5534
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8673
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6865
void OnApply(PlayerBase player)
override void SetQuantityNormalized(float value, bool destroy_config=true, bool destroy_forced=false)
Sets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8220
bool m_HideSelectionsBySlot
Определения ItemBase.c:4956
bool IsOverheatingEffectActive()
Определения ItemBase.c:5397
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5814
int GetLiquidContainerMask()
Определения ItemBase.c:5751
void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
Определения ItemBase.c:7002
ref Timer m_CheckOverheating
Определения ItemBase.c:4949
void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
Определения ItemBase.c:5445
float GetEnergy()
Определения ItemBase.c:8420
bool CanBeDigged()
Определения ItemBase.c:5830
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9596
bool IsNVG()
Определения ItemBase.c:5762
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8380
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9372
bool m_IsDeploySound
Определения ItemBase.c:9675
bool CanEat()
Определения ItemBase.c:7453
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9079
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9150
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9574
bool IsLiquidContainer()
Определения ItemBase.c:5746
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7473
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8307
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8863
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8261
int m_CleannessInit
Определения ItemBase.c:4885
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5529
override int GetAgents()
Определения ItemBase.c:8810
int m_VarQuantityMax
Определения ItemBase.c:4873
override bool IsHologram()
Определения ItemBase.c:5825
float GetItemAttachOffset()
Определения ItemBase.c:8589
bool IsPlaceSound()
Определения ItemBase.c:9689
static int GetDebugActionsMask()
Определения ItemBase.c:5615
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9452
override bool IsItemBase()
Определения ItemBase.c:7606
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9160
void ExplodeAmmo()
Определения ItemBase.c:6302
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:7078
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8884
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9059
override void OnEnergyAdded()
Определения ItemBase.c:8438
void AffectLiquidContainerOnFill(int liquid_type, float amount)
from enviro source
void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature)
from other liquid container source
string GetExplosiveTriggerSlotName()
Определения ItemBase.c:5774
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9672
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7746
void StopItemDynamicPhysics()
Определения ItemBase.c:9354
bool HasFoodStage()
Определения ItemBase.c:7466
override void SetStoreLoad(bool value)
Определения ItemBase.c:8558
float GetOverheatingValue()
Определения ItemBase.c:5359
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8763
override void AddWet(float value)
Определения ItemBase.c:8506
bool IsLiquidPresent()
Определения ItemBase.c:5741
bool IsFullQuantity()
Определения ItemBase.c:8301
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:6015
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6770
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6746
int m_CleannessMax
Определения ItemBase.c:4887
float m_VarStackMax
Определения ItemBase.c:4875
ref Timer m_PhysDropTimer
Определения ItemBase.c:4962
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7578
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8568
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4916
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5380
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5695
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7500
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8694
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5426
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8616
bool m_IsOverheatingEffectActive
Определения ItemBase.c:4947
int m_LiquidContainerMask
Определения ItemBase.c:4897
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9390
override int GetCleanness()
Определения ItemBase.c:8611
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9601
bool IsDeploySound()
Определения ItemBase.c:9690
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5635
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9099
int m_VarQuantityMin
Определения ItemBase.c:4872
void PerformDamageSystemReinit()
Определения ItemBase.c:9360
override void ClearInventory()
Определения ItemBase.c:8399
static int m_LastRegisteredWeaponID
Определения ItemBase.c:4944
ItemBase GetLightSourceItem()
Определения ItemBase.c:9584
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7596
override float GetItemOverheatThreshold()
Определения ItemBase.c:9534
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4909
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7710
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6685
float m_ItemModelLength
Определения ItemBase.c:4895
bool m_IsHologram
Определения ItemBase.c:4902
static int m_DebugActionsMask
Определения ItemBase.c:4862
void KillAllOverheatingParticles()
Определения ItemBase.c:5495
bool CanBeCookedOnStick()
Определения ItemBase.c:7483
override int GetQuantityMax()
Определения ItemBase.c:8248
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7156
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8654
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8776
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4905
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:8966
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9330
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4856
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9663
override bool IsBeingPlaced()
Определения ItemBase.c:5809
int GetQuantityInit()
Определения ItemBase.c:8285
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7098
bool IsResultOfSplit()
Определения ItemBase.c:7083
bool m_FixDamageSystemInit
Определения ItemBase.c:4907
float m_ImpactSpeed
Определения ItemBase.c:4891
bool m_IsStoreLoad
Определения ItemBase.c:4910
int GetLiquidTypeInit()
Определения ItemBase.c:8684
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4925
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5682
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6557
int m_AttachedAgents
Определения ItemBase.c:4933
string m_LockSoundSet
Определения ItemBase.c:4968
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5303
float m_VarQuantityPrev
Определения ItemBase.c:4870
bool IsSoundSynchRemote()
Определения ItemBase.c:9688
bool m_CanShowQuantity
Определения ItemBase.c:4911
override void OnRightClick()
Определения ItemBase.c:6938
int m_ColorComponentB
Определения ItemBase.c:4920
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4858
bool IsActionTargetVisible()
Определения ItemBase.c:9196
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:6050
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6339
bool m_IsBeingPlaced
Определения ItemBase.c:4901
int NameToID(string name)
Определения ItemBase.c:7683
void ~ItemBase()
Определения ItemBase.c:5580
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8546
void ClearStopItemSoundServer()
Определения ItemBase.c:9288
override string ChangeIntoOnDetach()
Определения ItemBase.c:6263
float m_VarWetMax
Определения ItemBase.c:4882
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6680
int GetLockType()
Определения ItemBase.c:8624
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9670
override float GetWet()
Определения ItemBase.c:8516
EffectSound m_SoundPlace
Определения ItemBase.c:9671
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8234
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8598
bool m_IsPlaceSound
Определения ItemBase.c:9674
override float GetWetMin()
Определения ItemBase.c:8526
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:4974
override bool KindOf(string tag)
Определения ItemBase.c:7612
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
string Type
Определения JsonDataContaminatedArea.c:11
EffectSound m_LockingSound
Определения Land_Underground_Entrance.c:321
string GetDebugText()
Определения ModifierBase.c:71
PlayerBase GetPlayer()
Определения ModifierBase.c:51
@ LOWEST
Определения PPEConstants.c:54
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
EntityAI GetItem()
Определения RadialQuickbarMenu.c:37
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Определения RemoteDetonator.c:272
void RemoteDetonatorTrigger()
Определения RemoteDetonator.c:233
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Определения RemoteDetonator.c:305
int particle_id
Определения SmokeSimulation.c:28
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
override void Explode(int damageType, string ammoType="")
Определения Trap_LandMine.c:220
bool m_Initialized
Определения UiHintPanel.c:317
void Debug()
Определения UniversalTemperatureSource.c:349
int GetID()
Определения ActionBase.c:1360
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:998
GetInputType()
Определения ActionBase.c:215
int m_StanceMask
Определения ActionBase.c:25
int m_CommandUIDProne
Определения ActionBase.c:24
int m_CommandUID
Определения ActionBase.c:23
void OnItemAttachedAtPlayer(EntityAI item, string slot_name)
Определения AnalyticsManagerClient.c:77
proto native UIManager GetUIManager()
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native float ConfigGetFloat(string path)
Get float value from config on path.
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
proto native void GizmoSelectObject(Object object)
proto native bool ConfigIsExisting(string path)
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto native DayZPlayer GetPlayer()
proto native void GizmoSelectPhysics(Physics physics)
proto int GetTime()
returns mission time in milliseconds
proto native int ConfigGetType(string path)
Returns type of config value.
AnalyticsManagerClient GetAnalyticsClient()
Определения Global/game.c:1568
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native SoundOnVehicle CreateSoundOnObject(Object source, string sound_name, float distance, bool looped, bool create_local=false)
proto native void ObjectDelete(Object obj)
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
float GetEnergyAtSpawn()
Определения ComponentEnergyManager.c:1280
void SetEnergy0To1(float energy01)
Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value be...
Определения ComponentEnergyManager.c:541
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Определения ComponentEnergyManager.c:1275
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:603
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
Определения EffectSound.c:274
override bool IsMan()
Определения 3_Game/Entities/Man.c:44
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
Определения ItemBase.c:15
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetCol()
returns column of cargo if current type is Cargo / ProxyCargo
proto native int GetRow()
returns row of cargo if current type is Cargo / ProxyCargo
bool WriteToContext(ParamsWriteContext ctx)
Определения InventoryLocation.c:469
proto native int GetType()
returns type of InventoryLocation
proto native int GetIdx()
returns index of cargo if current type is Cargo / ProxyCargo
proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
sets current inventory location type to Cargo with coordinates (idx, row, col)
proto native bool GetFlip()
returns flip status of cargo
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:29
override bool CanDisplayCargo()
Определения UndergroundStash.c:24
override void OnInventoryEnter(Man player)
Определения BarbedWire.c:203
override string GetFoldSoundset()
Определения BaseBuildingBase.c:108
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:6
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:913
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения GardenBase.c:199
override void OnWasDetached(EntityAI parent, int slot_id)
override void EEOnAfterLoad()
Определения GardenBase.c:242
override void EEDelete(EntityAI parent)
Определения BaseBuildingBase.c:68
override bool CanBeRepairedByCrafting()
Определения TentBase.c:86
override void OnPlacementStarted(Man player)
Определения BatteryCharger.c:376
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Определения BarbedWire.c:357
override bool IsElectricAppliance()
Определения BatteryCharger.c:43
override bool IsItemTent()
Определения TentBase.c:81
override void SetActions()
override string GetLoopFoldSoundset()
Определения BaseBuildingBase.c:113
override bool CanMakeGardenplot()
Определения FieldShovel.c:3
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения PowerGenerator.c:412
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения HandcuffsLocked.c:12
override WrittenNoteData GetWrittenNoteData()
Определения Paper.c:30
override int GetDamageSystemVersionChange()
Определения BaseBuildingBase.c:1238
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
override void InitItemVariables()
Определения Matchbox.c:3
override void SetActionAnimOverrides()
Определения PickAxe.c:28
override void OnCreatePhysics()
Определения BaseBuildingBase.c:489
override string GetDeploySoundset()
Определения BarbedWire.c:392
override float GetBandagingEffectivity()
Определения BandageDressing.c:49
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения PowerGenerator.c:424
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения BaseBuildingBase.c:496
override void OnStoreSave(ParamsWriteContext ctx)
Определения GardenBase.c:266
override void AfterStoreLoad()
Определения BarbedWire.c:155
override int GetOnDigWormsAmount()
Определения FieldShovel.c:27
override bool IsSelfAdjustingTemperature()
Определения PortableGasStove.c:287
override bool IsPlayerInside(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1037
override void OnVariablesSynchronized()
Определения GardenBase.c:97
override void RefreshPhysics()
Определения BatteryCharger.c:359
override bool CanObstruct()
Определения BaseBuildingBase.c:84
override void OnWasAttached(EntityAI parent, int slot_id)
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения BaseBuildingBase.c:982
override bool CanPutInCargo(EntityAI parent)
Определения GardenBase.c:331
override string GetLoopDeploySoundset()
Определения BarbedWire.c:397
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Определения BarbedWire.c:372
override void OnInventoryExit(Man player)
Определения BatteryCharger.c:341
override bool IsTakeable()
Определения BaseBuildingBase.c:1008
override bool IsIgnoredByConstruction()
Определения BaseBuildingBase.c:1170
override void InitItemSounds()
Определения BaseBuildingBase.c:94
override void EEKilled(Object killer)
Определения HandcuffsLocked.c:70
override void OnCombine(ItemBase other_item)
Определения BandageDressing.c:71
override bool CanExplodeInFire()
Определения LargeGasCannister.c:3
override bool IsFacingPlayer(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1032
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Определения Rag.c:61
override bool IsBloodContainer()
Определения BloodContainerBase.c:10
override bool IsClothing()
override bool CanBeSplit()
Определения Rag.c:34
override bool IsDeployable()
Определения BaseBuildingBase.c:365
override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения ToolBase.c:24
override bool CanBeDisinfected()
Определения BandageDressing.c:54
override float GetInfectionChance(int system=0, Param param=null)
Определения BandageDressing.c:59
override void OnEndPlacement()
Определения KitBase.c:65
Определения EnMath.c:7
float GetOverheatingLimitMax()
Определения WeaponParticles.c:417
void SetOverheatingLimitMax(float max)
Определения WeaponParticles.c:407
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
Определения WeaponParticles.c:422
float GetOverheatingLimitMin()
Определения WeaponParticles.c:412
Particle GetParticle()
Определения WeaponParticles.c:397
void SetOverheatingLimitMin(float min)
Определения WeaponParticles.c:402
void RegisterParticle(Particle p)
Определения WeaponParticles.c:392
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Определения Particle.c:266
void SetControlledDevice(EntityAI pDevice)
Определения RemoteDetonator.c:140
bool OnStoreLoad(ParamsReadContext ctx, int version)
void OnStoreSave(ParamsWriteContext ctx)
proto void Remove(func fn)
remove specific call from queue
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto native void Send()
proto bool Write(void value_out)
proto bool Read(void value_in)
bool m_Loop
Определения ItemSoundHandler.c:5
override void Stop()
Определения DayZPlayerImplement.c:64
proto native float GetDamage(string zoneName, string healthType)
UIScriptedMenu FindMenu(int id)
Returns menu with specific ID if it is open (see MenuID)
Определения UIManager.c:160
override void Refresh()
Определения ChatInputMenu.c:70
void SetCalcDetails(string details)
Определения 3_Game/tools/Debug.c:816
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения WrittenNoteData.c:13
const float LOWEST
Определения EnConvert.c:100
Serializer ParamsReadContext
Определения gameplay.c:15
class LOD Object
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Определения gameplay.c:6
proto native CGame GetGame()
Serializer ParamsWriteContext
Определения gameplay.c:16
const int DEF_BIOLOGICAL
Определения 3_Game/constants.c:512
const int DEF_CHEMICAL
Определения 3_Game/constants.c:513
const int COMP_TYPE_ENERGY_MANAGER
Определения Component.c:9
ErrorExSeverity
Определения EnDebug.c:62
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
enum ShapeType ErrorEx
proto native void SetColor(int color)
array< string > TStringArray
Определения EnScript.c:709
array< int > TIntArray
Определения EnScript.c:711
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/constants.c:808
const int VARIABLE_LIQUIDTYPE
Определения 3_Game/constants.c:632
const int VARIABLE_CLEANNESS
Определения 3_Game/constants.c:635
const int VARIABLE_COLOR
Определения 3_Game/constants.c:634
const int VARIABLE_TEMPERATURE
Определения 3_Game/constants.c:630
const int VARIABLE_QUANTITY
Определения 3_Game/constants.c:628
const int VARIABLE_WET
Определения 3_Game/constants.c:631
const int LIQUID_NONE
Определения 3_Game/constants.c:529
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения 3_Game/constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения 3_Game/constants.c:453
const int SAT_DEBUG_ACTION
Определения 3_Game/constants.c:454
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
const int CALL_CATEGORY_GAMEPLAY
Определения 3_Game/tools/tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/tools/tools.c:8
proto native int GetColor()