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

◆ GetWet()

override float SpawnItemOnLocation::GetWet ( )
protected

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

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