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

◆ GetCleanness()

override int SpawnItemOnLocation::GetCleanness ( )
protected

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

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