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

◆ GetUnitWeight()

float SpawnItemOnLocation::GetUnitWeight ( bool include_wetness = true)
protected

Obsolete, use GetWeightEx instead.

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

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