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

◆ SetWet()

override void SpawnItemOnLocation::SetWet ( float value,
bool allow_client = false )
protected

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

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

Используется в InventoryItem::AddWet(), AddWetnessToFireplace(), InventoryItem::DeSerializeNumericalVars(), InventoryItem::ReadVarsFromCTX() и InventoryItem::SetWetMax().