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

◆ OnVariablesSynchronized()

override void SpawnItemOnLocation::OnVariablesSynchronized ( )
protected

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

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