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

◆ AddQuantity()

bool SpawnItemOnLocation::AddQuantity ( float value,
bool destroy_config = true,
bool destroy_forced = false )
protected

add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity reaches varQuantityMin or lower and the item config contains the varQuantityDestroyOnMin = true entry, the item gets destroyed. destroy_forced = true means item gets destroyed when quantity reaches varQuantityMin or lower regardless of config setting, returns true if the item gets deleted

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

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

Используется в InventoryItem::CombineItems(), Edible_Base::Consume(), InventoryItem::OnAction(), ItemBase::OnIgnitedTarget(), ItemBase::OnIgnitedTargetFailed(), ItemBase::RemovePlanks(), InventoryItem::SplitIntoStackMax(), InventoryItem::SplitIntoStackMaxCargo(), InventoryItem::SplitIntoStackMaxEx(), InventoryItem::SplitIntoStackMaxHands(), InventoryItem::SplitIntoStackMaxToInventoryLocationEx(), InventoryItem::SplitItem() и InventoryItem::SplitItemToInventoryLocation().