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

◆ SplitIntoStackMaxToInventoryLocationEx()

ItemBase SpawnItemOnLocation::SplitIntoStackMaxToInventoryLocationEx ( notnull InventoryLocation dst)
protected

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

6689{
6690 override bool CanPutAsAttachment(EntityAI parent)
6691 {
6692 return true;
6693 }
6694};
6695
6696//const bool QUANTITY_DEBUG_REMOVE_ME = false;
6697
6698class ItemBase extends InventoryItem
6699{
6703
6705
6706 static int m_DebugActionsMask;
6708 // ============================================
6709 // Variable Manipulation System
6710 // ============================================
6711 // Quantity
6712
6713 float m_VarQuantity;
6714 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
6716 int m_VarQuantityMin;
6717 int m_VarQuantityMax;
6718 int m_Count;
6719 float m_VarStackMax;
6720 float m_StoreLoadedQuantity = float.LOWEST;
6721 // Wet
6722 float m_VarWet;
6723 float m_VarWetPrev;//for client to know wetness changed during synchronization
6724 float m_VarWetInit;
6725 float m_VarWetMin;
6726 float m_VarWetMax;
6727 // Cleanness
6728 int m_Cleanness;
6729 int m_CleannessInit;
6730 int m_CleannessMin;
6731 int m_CleannessMax;
6732 // impact sounds
6734 bool m_CanPlayImpactSound = true;
6735 float m_ImpactSpeed;
6737 //
6738 float m_HeatIsolation;
6739 float m_ItemModelLength;
6740 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
6742 int m_VarLiquidType;
6743 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
6744 int m_QuickBarBonus;
6745 bool m_IsBeingPlaced;
6746 bool m_IsHologram;
6747 bool m_IsTakeable;
6748 bool m_ThrowItemOnDrop;
6751 bool m_FixDamageSystemInit = false; //can be changed on storage version check
6752 bool can_this_be_combined; //Check if item can be combined
6753 bool m_CanThisBeSplit; //Check if item can be split
6754 bool m_IsStoreLoad = false;
6755 bool m_CanShowQuantity;
6756 bool m_HasQuantityBar;
6757 protected bool m_CanBeDigged;
6758 protected bool m_IsResultOfSplit
6759
6760 string m_SoundAttType;
6761 // items color variables
6766 //-------------------------------------------------------
6767
6768 // light source managing
6770
6774
6775 //==============================================
6776 // agent system
6777 private int m_AttachedAgents;
6778
6780 void TransferModifiers(PlayerBase reciever);
6781
6782
6783 // Weapons & suppressors particle effects
6788 static int m_LastRegisteredWeaponID = 0;
6789
6790 // Overheating effects
6792 float m_OverheatingShots;
6793 ref Timer m_CheckOverheating;
6794 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
6795 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
6796 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
6797 ref array <ref OverheatingParticle> m_OverheatingParticles;
6798
6800 protected bool m_HideSelectionsBySlot;
6801
6802 // Admin Log
6803 PluginAdminLog m_AdminLog;
6804
6805 // misc
6806 ref Timer m_PhysDropTimer;
6807
6808 // Attachment Locking variables
6809 ref array<int> m_CompatibleLocks;
6810 protected int m_LockType;
6811 protected ref EffectSound m_LockingSound;
6812 protected string m_LockSoundSet;
6813
6814 // ItemSoundHandler
6815 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
6816 protected int m_SoundSyncPlay; // id for sound to play
6817 protected int m_SoundSyncStop; // id for sound to stop
6819
6820 //temperature
6821 private float m_TemperaturePerQuantityWeight;
6822
6823 // -------------------------------------------------------------------------
6824 void ItemBase()
6825 {
6826 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
6830
6831 if (!GetGame().IsDedicatedServer())
6832 {
6833 if (HasMuzzle())
6834 {
6836
6838 {
6840 }
6841 }
6842
6844 m_ActionsInitialize = false;
6845 }
6846
6847 m_OldLocation = null;
6848
6849 if (GetGame().IsServer())
6850 {
6851 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
6852 }
6853
6854 if (ConfigIsExisting("headSelectionsToHide"))
6855 {
6857 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
6858 }
6859
6860 m_HideSelectionsBySlot = false;
6861 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
6862 {
6863 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
6864 }
6865
6866 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
6867
6868 m_IsResultOfSplit = false;
6869
6871 }
6872
6873 override void InitItemVariables()
6874 {
6875 super.InitItemVariables();
6876
6877 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
6878 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
6879 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
6880 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
6881 m_VarStackMax = ConfigGetFloat("varStackMax");
6882 m_Count = ConfigGetInt("count");
6883
6884 m_CanShowQuantity = ConfigGetBool("quantityShow");
6885 m_HasQuantityBar = ConfigGetBool("quantityBar");
6886
6887 m_CleannessInit = ConfigGetInt("varCleannessInit");
6889 m_CleannessMin = ConfigGetInt("varCleannessMin");
6890 m_CleannessMax = ConfigGetInt("varCleannessMax");
6891
6892 m_WantPlayImpactSound = false;
6893 m_ImpactSpeed = 0.0;
6894
6895 m_VarWetInit = ConfigGetFloat("varWetInit");
6897 m_VarWetMin = ConfigGetFloat("varWetMin");
6898 m_VarWetMax = ConfigGetFloat("varWetMax");
6899
6900 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
6901 if (IsLiquidContainer() && GetQuantity() != 0)
6903 m_IsBeingPlaced = false;
6904 m_IsHologram = false;
6905 m_IsTakeable = true;
6906 m_CanBeMovedOverride = false;
6910 m_CanBeDigged = ConfigGetBool("canBeDigged");
6911
6912 m_CompatibleLocks = new array<int>();
6913 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
6914 m_LockType = ConfigGetInt("lockType");
6915
6916 //Define if item can be split and set ability to be combined accordingly
6917 m_CanThisBeSplit = false;
6918 can_this_be_combined = false;
6919 if (ConfigIsExisting("canBeSplit"))
6920 {
6921 can_this_be_combined = ConfigGetBool("canBeSplit");
6923 }
6924
6925 m_ItemBehaviour = -1;
6926 if (ConfigIsExisting("itemBehaviour"))
6927 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
6928
6929 //RegisterNetSyncVariableInt("m_VariablesMask");
6930 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
6931 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
6932 RegisterNetSyncVariableInt("m_VarLiquidType");
6933 RegisterNetSyncVariableInt("m_Cleanness",0,1);
6934
6935 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
6936 RegisterNetSyncVariableFloat("m_ImpactSpeed");
6937 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
6938
6939 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
6940 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
6941 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
6942 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
6943
6944 RegisterNetSyncVariableBool("m_IsBeingPlaced");
6945 RegisterNetSyncVariableBool("m_IsTakeable");
6946 RegisterNetSyncVariableBool("m_IsHologram");
6947
6948 InitItemSounds();
6950 {
6951 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
6952 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
6953 }
6954
6955 m_LockSoundSet = ConfigGetString("lockSoundSet");
6956
6958 if (ConfigIsExisting("temperaturePerQuantityWeight"))
6959 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
6960
6961 }
6962
6963 override int GetQuickBarBonus()
6964 {
6965 return m_QuickBarBonus;
6966 }
6967
6968 void InitializeActions()
6969 {
6971 if (!m_InputActionMap)
6972 {
6974 m_InputActionMap = iam;
6975 SetActions();
6977 }
6978 }
6979
6980 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
6981 {
6983 {
6984 m_ActionsInitialize = true;
6986 }
6987
6988 actions = m_InputActionMap.Get(action_input_type);
6989 }
6990
6991 void SetActions()
6992 {
6993 AddAction(ActionTakeItem);
6994 AddAction(ActionTakeItemToHands);
6995 AddAction(ActionWorldCraft);
6997 AddAction(ActionAttachWithSwitch);
6998 }
6999
7000 void SetActionAnimOverrides(); // Override action animation for specific item
7001
7002 void AddAction(typename actionName)
7003 {
7004 ActionBase action = ActionManagerBase.GetAction(actionName);
7005
7006 if (!action)
7007 {
7008 Debug.LogError("Action " + actionName + " dosn't exist!");
7009 return;
7010 }
7011
7012 typename ai = action.GetInputType();
7013 if (!ai)
7014 {
7015 m_ActionsInitialize = false;
7016 return;
7017 }
7018
7019 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
7020 if (!action_array)
7021 {
7022 action_array = new array<ActionBase_Basic>;
7023 m_InputActionMap.Insert(ai, action_array);
7024 }
7025 if (LogManager.IsActionLogEnable())
7026 {
7027 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
7028 }
7029
7030 if (action_array.Find(action) != -1)
7031 {
7032 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
7033 }
7034 else
7035 {
7036 action_array.Insert(action);
7037 }
7038 }
7039
7040 void RemoveAction(typename actionName)
7041 {
7042 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
7043 ActionBase action = player.GetActionManager().GetAction(actionName);
7044 typename ai = action.GetInputType();
7045 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
7046
7047 if (action_array)
7048 {
7049 action_array.RemoveItem(action);
7050 }
7051 }
7052
7053 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
7054 // Set -1 for params which should stay in default state
7055 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
7056 {
7057 ActionOverrideData overrideData = new ActionOverrideData();
7058 overrideData.m_CommandUID = commandUID;
7059 overrideData.m_CommandUIDProne = commandUIDProne;
7060 overrideData.m_StanceMask = stanceMask;
7061
7062 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
7063 if (!actionMap) // create new map of action > overidables map
7064 {
7065 actionMap = new TActionAnimOverrideMap();
7066 m_ItemActionOverrides.Insert(action, actionMap);
7067 }
7068
7069 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
7070
7071 }
7072
7073 void OnItemInHandsPlayerSwimStart(PlayerBase player);
7074
7075 ScriptedLightBase GetLight();
7076
7077 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
7078 void LoadParticleConfigOnFire(int id)
7079 {
7080 if (!m_OnFireEffect)
7082
7085
7086 string config_to_search = "CfgVehicles";
7087 string muzzle_owner_config;
7088
7089 if (!m_OnFireEffect.Contains(id))
7090 {
7091 if (IsInherited(Weapon))
7092 config_to_search = "CfgWeapons";
7093
7094 muzzle_owner_config = config_to_search + " " + GetType() + " ";
7095
7096 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
7097
7098 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
7099
7100 if (config_OnFire_subclass_count > 0)
7101 {
7102 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
7103
7104 for (int i = 0; i < config_OnFire_subclass_count; i++)
7105 {
7106 string particle_class = "";
7107 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
7108 string config_OnFire_entry = config_OnFire_class + particle_class;
7109 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
7110 WPOF_array.Insert(WPOF);
7111 }
7112
7113
7114 m_OnFireEffect.Insert(id, WPOF_array);
7115 }
7116 }
7117
7118 if (!m_OnBulletCasingEjectEffect.Contains(id))
7119 {
7120 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
7121 muzzle_owner_config = config_to_search + " " + GetType() + " ";
7122
7123 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
7124
7125 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
7126
7127 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
7128 {
7129 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
7130
7131 for (i = 0; i < config_OnBulletCasingEject_count; i++)
7132 {
7133 string particle_class2 = "";
7134 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
7135 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
7136 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
7137 WPOBE_array.Insert(WPOBE);
7138 }
7139
7140
7141 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
7142 }
7143 }
7144 }
7145
7146 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
7148 {
7151
7152 if (!m_OnOverheatingEffect.Contains(id))
7153 {
7154 string config_to_search = "CfgVehicles";
7155
7156 if (IsInherited(Weapon))
7157 config_to_search = "CfgWeapons";
7158
7159 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
7160 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
7161
7162 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
7163 {
7164
7165 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
7166
7168 {
7169 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
7170 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
7171 Error(error);
7172 return;
7173 }
7174
7175 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
7176 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
7177
7178
7179
7180 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
7181 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
7182
7183 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
7184 {
7185 string particle_class = "";
7186 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
7187 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
7188 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
7189
7190 if (entry_type == CT_CLASS)
7191 {
7192 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
7193 WPOOH_array.Insert(WPOF);
7194 }
7195 }
7196
7197
7198 m_OnOverheatingEffect.Insert(id, WPOOH_array);
7199 }
7200 }
7201 }
7202
7203 float GetOverheatingValue()
7204 {
7205 return m_OverheatingShots;
7206 }
7207
7208 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
7209 {
7210 if (m_MaxOverheatingValue > 0)
7211 {
7213
7214 if (!m_CheckOverheating)
7216
7218 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
7219
7220 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7221 }
7222 }
7223
7224 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7225 {
7227 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7228
7230 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7231
7233 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7234
7236 {
7238 }
7239 }
7240
7242 {
7244 }
7245
7246 void OnOverheatingDecay()
7247 {
7248 if (m_MaxOverheatingValue > 0)
7249 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
7250 else
7252
7253 if (m_OverheatingShots <= 0)
7254 {
7257 }
7258 else
7259 {
7260 if (!m_CheckOverheating)
7262
7264 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
7265 }
7266
7267 CheckOverheating(this, "", this);
7268 }
7269
7270 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7271 {
7273 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
7274 }
7275
7276 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7277 {
7279 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
7281 }
7282
7283 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7284 {
7286 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7287 }
7288
7289 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
7290 {
7292 m_OverheatingParticles = new array<ref OverheatingParticle>;
7293
7294 OverheatingParticle OP = new OverheatingParticle();
7295 OP.RegisterParticle(p);
7296 OP.SetOverheatingLimitMin(min_heat_coef);
7297 OP.SetOverheatingLimitMax(max_heat_coef);
7298 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
7299
7300 m_OverheatingParticles.Insert(OP);
7301 }
7302
7303 float GetOverheatingCoef()
7304 {
7305 if (m_MaxOverheatingValue > 0)
7307
7308 return -1;
7309 }
7310
7312 {
7314 {
7315 float overheat_coef = GetOverheatingCoef();
7316 int count = m_OverheatingParticles.Count();
7317
7318 for (int i = count; i > 0; --i)
7319 {
7320 int id = i - 1;
7321 OverheatingParticle OP = m_OverheatingParticles.Get(id);
7322 Particle p = OP.GetParticle();
7323
7324 float overheat_min = OP.GetOverheatingLimitMin();
7325 float overheat_max = OP.GetOverheatingLimitMax();
7326
7327 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
7328 {
7329 if (p)
7330 {
7331 p.Stop();
7332 OP.RegisterParticle(null);
7333 }
7334 }
7335 }
7336 }
7337 }
7338
7340 {
7342 {
7343 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
7344 {
7345 int id = i - 1;
7346 OverheatingParticle OP = m_OverheatingParticles.Get(id);
7347
7348 if (OP)
7349 {
7350 Particle p = OP.GetParticle();
7351
7352 if (p)
7353 {
7354 p.Stop();
7355 }
7356
7357 delete OP;
7358 }
7359 }
7360
7361 m_OverheatingParticles.Clear();
7363 }
7364 }
7365
7367 float GetInfectionChance(int system = 0, Param param = null)
7368 {
7369 return 0.0;
7370 }
7371
7372
7373 float GetDisinfectQuantity(int system = 0, Param param1 = null)
7374 {
7375 return 250;//default value
7376 }
7377
7378 float GetFilterDamageRatio()
7379 {
7380 return 0;
7381 }
7382
7384 bool HasMuzzle()
7385 {
7386 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
7387 return true;
7388
7389 return false;
7390 }
7391
7393 int GetMuzzleID()
7394 {
7395 if (!m_WeaponTypeToID)
7397
7398 if (m_WeaponTypeToID.Contains(GetType()))
7399 {
7400 return m_WeaponTypeToID.Get(GetType());
7401 }
7402 else
7403 {
7404 // Register new weapon ID
7406 }
7407
7409 }
7410
7417 {
7418 return -1;
7419 }
7420
7421
7422
7423 // -------------------------------------------------------------------------
7424 void ~ItemBase()
7425 {
7426 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
7427 {
7428 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
7429 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
7430
7431 if (r_index >= 0)
7432 {
7433 InventoryLocation r_il = new InventoryLocation;
7434 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
7435
7436 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
7437 int r_type = r_il.GetType();
7438 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
7439 {
7440 r_il.GetParent().GetOnReleaseLock().Invoke(this);
7441 }
7442 else if (r_type == InventoryLocationType.ATTACHMENT)
7443 {
7444 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
7445 }
7446
7447 }
7448
7449 player.GetHumanInventory().ClearUserReservedLocation(this);
7450 }
7451
7452 if (m_LockingSound)
7453 SEffectManager.DestroyEffect(m_LockingSound);
7454 }
7455
7456
7457
7458 // -------------------------------------------------------------------------
7459 static int GetDebugActionsMask()
7460 {
7461 return ItemBase.m_DebugActionsMask;
7462 }
7463
7464 static bool HasDebugActionsMask(int mask)
7465 {
7466 return ItemBase.m_DebugActionsMask & mask;
7467 }
7468
7469 static void SetDebugActionsMask(int mask)
7470 {
7471 ItemBase.m_DebugActionsMask = mask;
7472 }
7473
7474 static void AddDebugActionsMask(int mask)
7475 {
7476 ItemBase.m_DebugActionsMask |= mask;
7477 }
7478
7479 static void RemoveDebugActionsMask(int mask)
7480 {
7481 ItemBase.m_DebugActionsMask &= ~mask;
7482 }
7483
7484 static void ToggleDebugActionsMask(int mask)
7485 {
7486 if (HasDebugActionsMask(mask))
7487 {
7489 }
7490 else
7491 {
7492 AddDebugActionsMask(mask);
7493 }
7494 }
7495
7496 // -------------------------------------------------------------------------
7497 void SetCEBasedQuantity()
7498 {
7499 if (GetEconomyProfile())
7500 {
7501 float q_max = GetEconomyProfile().GetQuantityMax();
7502 if (q_max > 0)
7503 {
7504 float q_min = GetEconomyProfile().GetQuantityMin();
7505 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
7506
7507 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
7508 {
7509 ComponentEnergyManager comp = GetCompEM();
7510 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
7511 {
7512 comp.SetEnergy0To1(quantity_randomized);
7513 }
7514 }
7515 else if (HasQuantity())
7516 {
7517 SetQuantityNormalized(quantity_randomized, false);
7518 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
7519 }
7520
7521 }
7522 }
7523 }
7524
7526 void LockToParent()
7527 {
7528 EntityAI parent = GetHierarchyParent();
7529
7530 if (parent)
7531 {
7532 InventoryLocation inventory_location_to_lock = new InventoryLocation;
7533 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
7534 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
7535 }
7536 }
7537
7539 void UnlockFromParent()
7540 {
7541 EntityAI parent = GetHierarchyParent();
7542
7543 if (parent)
7544 {
7545 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
7546 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
7547 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
7548 }
7549 }
7550
7551 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
7552 {
7553 /*
7554 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
7555 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
7556 */
7557 ItemBase item2 = ItemBase.Cast(entity2);
7558
7559 if (GetGame().IsClient())
7560 {
7561 if (ScriptInputUserData.CanStoreInputUserData())
7562 {
7563 ScriptInputUserData ctx = new ScriptInputUserData;
7565 ctx.Write(-1);
7566 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7567 ctx.Write(i1);
7568 ctx.Write(item2);
7569 ctx.Write(use_stack_max);
7570 ctx.Write(-1);
7571 ctx.Send();
7572
7573 if (IsCombineAll(item2, use_stack_max))
7574 {
7575 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
7576 }
7577 }
7578 }
7579 else if (!GetGame().IsMultiplayer())
7580 {
7581 CombineItems(item2, use_stack_max);
7582 }
7583 }
7584
7585 bool IsLiquidPresent()
7586 {
7587 return (GetLiquidType() != 0 && HasQuantity());
7588 }
7589
7590 bool IsLiquidContainer()
7591 {
7592 return m_LiquidContainerMask != 0;
7593 }
7594
7596 {
7597 return m_LiquidContainerMask;
7598 }
7599
7600 bool IsBloodContainer()
7601 {
7602 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
7603 return false;
7604 }
7605
7606 bool IsNVG()
7607 {
7608 return false;
7609 }
7610
7613 bool IsExplosive()
7614 {
7615 return false;
7616 }
7617
7619 {
7620 return "";
7621 }
7622
7624
7625 bool IsLightSource()
7626 {
7627 return false;
7628 }
7629
7631 {
7632 return true;
7633 }
7634
7635 //--- ACTION CONDITIONS
7636 //direction
7637 bool IsFacingPlayer(PlayerBase player, string selection)
7638 {
7639 return true;
7640 }
7641
7642 bool IsPlayerInside(PlayerBase player, string selection)
7643 {
7644 return true;
7645 }
7646
7647 override bool CanObstruct()
7648 {
7649 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
7650 return !player || !IsPlayerInside(player, "");
7651 }
7652
7653 override bool IsBeingPlaced()
7654 {
7655 return m_IsBeingPlaced;
7656 }
7657
7658 void SetIsBeingPlaced(bool is_being_placed)
7659 {
7660 m_IsBeingPlaced = is_being_placed;
7661 if (!is_being_placed)
7663 SetSynchDirty();
7664 }
7665
7666 //server-side
7667 void OnEndPlacement() {}
7668
7669 override bool IsHologram()
7670 {
7671 return m_IsHologram;
7672 }
7673
7674 bool CanBeDigged()
7675 {
7676 return m_CanBeDigged;
7677 }
7678
7680 {
7681 return 1;
7682 }
7683
7684 bool CanMakeGardenplot()
7685 {
7686 return false;
7687 }
7688
7689 void SetIsHologram(bool is_hologram)
7690 {
7691 m_IsHologram = is_hologram;
7692 SetSynchDirty();
7693 }
7694 /*
7695 protected float GetNutritionalEnergy()
7696 {
7697 Edible_Base edible = Edible_Base.Cast(this);
7698 return edible.GetFoodEnergy();
7699 }
7700
7701 protected float GetNutritionalWaterContent()
7702 {
7703 Edible_Base edible = Edible_Base.Cast(this);
7704 return edible.GetFoodWater();
7705 }
7706
7707 protected float GetNutritionalIndex()
7708 {
7709 Edible_Base edible = Edible_Base.Cast(this);
7710 return edible.GetFoodNutritionalIndex();
7711 }
7712
7713 protected float GetNutritionalFullnessIndex()
7714 {
7715 Edible_Base edible = Edible_Base.Cast(this);
7716 return edible.GetFoodTotalVolume();
7717 }
7718
7719 protected float GetNutritionalToxicity()
7720 {
7721 Edible_Base edible = Edible_Base.Cast(this);
7722 return edible.GetFoodToxicity();
7723
7724 }
7725 */
7726
7727
7728 // -------------------------------------------------------------------------
7729 override void OnMovedInsideCargo(EntityAI container)
7730 {
7731 super.OnMovedInsideCargo(container);
7732
7733 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
7734 }
7735
7736 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
7737 {
7738 super.EEItemLocationChanged(oldLoc,newLoc);
7739
7740 PlayerBase new_player = null;
7741 PlayerBase old_player = null;
7742
7743 if (newLoc.GetParent())
7744 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
7745
7746 if (oldLoc.GetParent())
7747 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
7748
7749 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
7750 {
7751 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
7752
7753 if (r_index >= 0)
7754 {
7755 InventoryLocation r_il = new InventoryLocation;
7756 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
7757
7758 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
7759 int r_type = r_il.GetType();
7760 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
7761 {
7762 r_il.GetParent().GetOnReleaseLock().Invoke(this);
7763 }
7764 else if (r_type == InventoryLocationType.ATTACHMENT)
7765 {
7766 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
7767 }
7768
7769 }
7770 }
7771
7772 if (newLoc.GetType() == InventoryLocationType.HANDS)
7773 {
7774 if (new_player)
7775 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
7776
7777 if (new_player == old_player)
7778 {
7779
7780 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
7781 {
7782 if (oldLoc.GetType() == InventoryLocationType.CARGO)
7783 {
7784 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
7785 {
7786 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
7787 }
7788 }
7789 else
7790 {
7791 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
7792 }
7793 }
7794
7795 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
7796 {
7797 int type = oldLoc.GetType();
7798 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
7799 {
7800 oldLoc.GetParent().GetOnSetLock().Invoke(this);
7801 }
7802 else if (type == InventoryLocationType.ATTACHMENT)
7803 {
7804 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
7805 }
7806 }
7807 if (!m_OldLocation)
7808 {
7809 m_OldLocation = new InventoryLocation;
7810 }
7811 m_OldLocation.Copy(oldLoc);
7812 }
7813 else
7814 {
7815 if (m_OldLocation)
7816 {
7817 m_OldLocation.Reset();
7818 }
7819 }
7820
7822 }
7823 else
7824 {
7825 if (new_player)
7826 {
7827 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
7828 if (res_index >= 0)
7829 {
7830 InventoryLocation il = new InventoryLocation;
7831 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
7832 ItemBase it = ItemBase.Cast(il.GetItem());
7833 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
7834 int rel_type = il.GetType();
7835 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
7836 {
7837 il.GetParent().GetOnReleaseLock().Invoke(it);
7838 }
7839 else if (rel_type == InventoryLocationType.ATTACHMENT)
7840 {
7841 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
7842 }
7843 //it.GetOnReleaseLock().Invoke(it);
7844 }
7845 }
7846 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
7847 {
7848 //ThrowPhysically(old_player, vector.Zero);
7849 m_ThrowItemOnDrop = false;
7850 }
7851
7852 if (m_OldLocation)
7853 {
7854 m_OldLocation.Reset();
7855 }
7856 }
7857 }
7858
7859 override void EOnContact(IEntity other, Contact extra)
7860 {
7862 {
7863 int liquidType = -1;
7864 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
7865 if (impactSpeed > 0.0)
7866 {
7867 m_ImpactSpeed = impactSpeed;
7868 #ifndef SERVER
7869 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
7870 #else
7871 m_WantPlayImpactSound = true;
7872 SetSynchDirty();
7873 #endif
7874 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
7875 }
7876 }
7877
7878 #ifdef SERVER
7879 if (GetCompEM() && GetCompEM().IsPlugged())
7880 {
7881 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
7882 GetCompEM().UnplugThis();
7883 }
7884 #endif
7885 }
7886
7887 void RefreshPhysics();
7888
7889 override void OnCreatePhysics()
7890 {
7892 }
7893
7894 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
7895 {
7896
7897 }
7898 // -------------------------------------------------------------------------
7899 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
7900 {
7901 super.OnItemLocationChanged(old_owner, new_owner);
7902
7903 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
7904 PlayerBase playerNew = PlayerBase.Cast(new_owner);
7905
7906 if (!relatedPlayer && playerNew)
7907 relatedPlayer = playerNew;
7908
7909 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
7910 {
7911 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
7912 if (actionMgr)
7913 {
7914 ActionBase currentAction = actionMgr.GetRunningAction();
7915 if (currentAction)
7916 currentAction.OnItemLocationChanged(this);
7917 }
7918 }
7919
7920 Man ownerPlayerOld = null;
7921 Man ownerPlayerNew = null;
7922
7923 if (old_owner)
7924 {
7925 if (old_owner.IsMan())
7926 {
7927 ownerPlayerOld = Man.Cast(old_owner);
7928 }
7929 else
7930 {
7931 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
7932 }
7933 }
7934 else
7935 {
7936 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
7937 {
7938 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
7939
7940 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
7941 {
7942 GetCompEM().UnplugThis();
7943 }
7944 }
7945 }
7946
7947 if (new_owner)
7948 {
7949 if (new_owner.IsMan())
7950 {
7951 ownerPlayerNew = Man.Cast(new_owner);
7952 }
7953 else
7954 {
7955 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
7956 }
7957 }
7958
7959 if (ownerPlayerOld != ownerPlayerNew)
7960 {
7961 if (ownerPlayerOld)
7962 {
7963 array<EntityAI> subItemsExit = new array<EntityAI>;
7964 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
7965 for (int i = 0; i < subItemsExit.Count(); i++)
7966 {
7967 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
7968 itemExit.OnInventoryExit(ownerPlayerOld);
7969 }
7970 }
7971
7972 if (ownerPlayerNew)
7973 {
7974 array<EntityAI> subItemsEnter = new array<EntityAI>;
7975 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
7976 for (int j = 0; j < subItemsEnter.Count(); j++)
7977 {
7978 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
7979 itemEnter.OnInventoryEnter(ownerPlayerNew);
7980 }
7981 }
7982 }
7983 else if (ownerPlayerNew != null)
7984 {
7985 PlayerBase nplayer;
7986 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
7987 {
7988 array<EntityAI> subItemsUpdate = new array<EntityAI>;
7989 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
7990 for (int k = 0; k < subItemsUpdate.Count(); k++)
7991 {
7992 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
7993 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
7994 }
7995 }
7996 }
7997
7998 if (old_owner)
7999 old_owner.OnChildItemRemoved(this);
8000 if (new_owner)
8001 new_owner.OnChildItemReceived(this);
8002 }
8003
8004 // -------------------------------------------------------------------------------
8005 override void EEDelete(EntityAI parent)
8006 {
8007 super.EEDelete(parent);
8008 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
8009 if (player)
8010 {
8011 OnInventoryExit(player);
8012
8013 if (player.IsAlive())
8014 {
8015 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
8016 if (r_index >= 0)
8017 {
8018 InventoryLocation r_il = new InventoryLocation;
8019 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8020
8021 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8022 int r_type = r_il.GetType();
8023 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8024 {
8025 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8026 }
8027 else if (r_type == InventoryLocationType.ATTACHMENT)
8028 {
8029 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8030 }
8031
8032 }
8033
8034 player.RemoveQuickBarEntityShortcut(this);
8035 }
8036 }
8037 }
8038 // -------------------------------------------------------------------------------
8039 override void EEKilled(Object killer)
8040 {
8041 super.EEKilled(killer);
8042
8044 if (killer && killer.IsFireplace() && CanExplodeInFire())
8045 {
8046 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
8047 {
8048 if (IsMagazine())
8049 {
8050 if (Magazine.Cast(this).GetAmmoCount() > 0)
8051 {
8052 ExplodeAmmo();
8053 }
8054 }
8055 else
8056 {
8057 Explode(DamageType.EXPLOSION);
8058 }
8059 }
8060 }
8061 }
8062
8063 override void OnWasAttached(EntityAI parent, int slot_id)
8064 {
8065 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
8066
8067 super.OnWasAttached(parent, slot_id);
8068
8069 if (HasQuantity())
8070 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8071
8072 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
8073 }
8074
8075 override void OnWasDetached(EntityAI parent, int slot_id)
8076 {
8077 super.OnWasDetached(parent, slot_id);
8078
8079 if (HasQuantity())
8080 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8081 }
8082
8083 override string ChangeIntoOnAttach(string slot)
8084 {
8085 int idx;
8086 TStringArray inventory_slots = new TStringArray;
8087 TStringArray attach_types = new TStringArray;
8088
8089 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
8090 if (inventory_slots.Count() < 1) //is string
8091 {
8092 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
8093 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
8094 }
8095 else //is array
8096 {
8097 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
8098 }
8099
8100 idx = inventory_slots.Find(slot);
8101 if (idx < 0)
8102 return "";
8103
8104 return attach_types.Get(idx);
8105 }
8106
8107 override string ChangeIntoOnDetach()
8108 {
8109 int idx = -1;
8110 string slot;
8111
8112 TStringArray inventory_slots = new TStringArray;
8113 TStringArray detach_types = new TStringArray;
8114
8115 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
8116 if (inventory_slots.Count() < 1) //is string
8117 {
8118 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
8119 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
8120 }
8121 else //is array
8122 {
8123 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
8124 if (detach_types.Count() < 1)
8125 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
8126 }
8127
8128 for (int i = 0; i < inventory_slots.Count(); i++)
8129 {
8130 slot = inventory_slots.Get(i);
8131 }
8132
8133 if (slot != "")
8134 {
8135 if (detach_types.Count() == 1)
8136 idx = 0;
8137 else
8138 idx = inventory_slots.Find(slot);
8139 }
8140 if (idx < 0)
8141 return "";
8142
8143 return detach_types.Get(idx);
8144 }
8145
8146 void ExplodeAmmo()
8147 {
8148 //timer
8149 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
8150
8151 //min/max time
8152 float min_time = 1;
8153 float max_time = 3;
8154 float delay = Math.RandomFloat(min_time, max_time);
8155
8156 explode_timer.Run(delay, this, "DoAmmoExplosion");
8157 }
8158
8159 void DoAmmoExplosion()
8160 {
8161 Magazine magazine = Magazine.Cast(this);
8162 int pop_sounds_count = 6;
8163 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
8164
8165 //play sound
8166 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
8167 string sound_name = pop_sounds[ sound_idx ];
8168 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
8169
8170 //remove ammo count
8171 magazine.ServerAddAmmoCount(-1);
8172
8173 //if condition then repeat -> ExplodeAmmo
8174 float min_temp_to_explode = 100; //min temperature for item to explode
8175
8176 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
8177 {
8178 ExplodeAmmo();
8179 }
8180 }
8181
8182 // -------------------------------------------------------------------------------
8183 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
8184 {
8185 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
8186
8187 const int CHANCE_DAMAGE_CARGO = 4;
8188 const int CHANCE_DAMAGE_ATTACHMENT = 1;
8189 const int CHANCE_DAMAGE_NOTHING = 2;
8190
8191 if (IsClothing() || IsContainer() || IsItemTent())
8192 {
8193 float dmg = damageResult.GetDamage("","Health") * -0.5;
8194 int chances;
8195 int rnd;
8196
8197 if (GetInventory().GetCargo())
8198 {
8199 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
8200 rnd = Math.RandomInt(0,chances);
8201
8202 if (rnd < CHANCE_DAMAGE_CARGO)
8203 {
8204 DamageItemInCargo(dmg);
8205 }
8206 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
8207 {
8209 }
8210 }
8211 else
8212 {
8213 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
8214 rnd = Math.RandomInt(0,chances);
8215
8216 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
8217 {
8219 }
8220 }
8221 }
8222 }
8223
8224 bool DamageItemInCargo(float damage)
8225 {
8226 if (GetInventory().GetCargo())
8227 {
8228 int item_count = GetInventory().GetCargo().GetItemCount();
8229 if (item_count > 0)
8230 {
8231 int random_pick = Math.RandomInt(0, item_count);
8232 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
8233 if (!item.IsExplosive())
8234 {
8235 item.AddHealth("","",damage);
8236 return true;
8237 }
8238 }
8239 }
8240 return false;
8241 }
8242
8243 bool DamageItemAttachments(float damage)
8244 {
8245 int attachment_count = GetInventory().AttachmentCount();
8246 if (attachment_count > 0)
8247 {
8248 int random_pick = Math.RandomInt(0, attachment_count);
8249 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
8250 if (!attachment.IsExplosive())
8251 {
8252 attachment.AddHealth("","",damage);
8253 return true;
8254 }
8255 }
8256 return false;
8257 }
8258
8259 override bool IsSplitable()
8260 {
8261 return m_CanThisBeSplit;
8262 }
8263 //----------------
8264 override bool CanBeSplit()
8265 {
8266 if (IsSplitable() && (GetQuantity() > 1))
8267 return GetInventory().CanRemoveEntity();
8268
8269 return false;
8270 }
8271
8272 protected bool ShouldSplitQuantity(float quantity)
8273 {
8274 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
8275 if (!IsSplitable())
8276 return false;
8277
8278 // nothing to split?
8279 if (GetQuantity() <= 1)
8280 return false;
8281
8282 // check if we should re-use the item instead of creating a new copy?
8283 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
8284 int delta = GetQuantity() - quantity;
8285 if (delta == 0)
8286 return false;
8287
8288 // valid to split
8289 return true;
8290 }
8291
8292 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
8293 {
8294 if (GetGame().IsClient())
8295 {
8296 if (ScriptInputUserData.CanStoreInputUserData())
8297 {
8298 ScriptInputUserData ctx = new ScriptInputUserData;
8300 ctx.Write(1);
8301 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8302 ctx.Write(i1);
8303 ctx.Write(destination_entity);
8304 ctx.Write(true);
8305 ctx.Write(slot_id);
8306 ctx.Send();
8307 }
8308 }
8309 else if (!GetGame().IsMultiplayer())
8310 {
8311 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
8312 }
8313 }
8314
8315 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
8316 {
8317 float split_quantity_new;
8318 ItemBase new_item;
8319 float quantity = GetQuantity();
8320 float stack_max = GetTargetQuantityMax(slot_id);
8321 InventoryLocation loc = new InventoryLocation;
8322
8323 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
8324 {
8325 if (stack_max <= GetQuantity())
8326 split_quantity_new = stack_max;
8327 else
8328 split_quantity_new = GetQuantity();
8329
8330 if (ShouldSplitQuantity(split_quantity_new))
8331 {
8332 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
8333 if (new_item)
8334 {
8335 new_item.SetResultOfSplit(true);
8336 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8337 AddQuantity(-split_quantity_new, false, true);
8338 new_item.SetQuantity(split_quantity_new, false, true);
8339 }
8340 }
8341 }
8342 else if (destination_entity && slot_id == -1)
8343 {
8344 if (quantity > stack_max)
8345 split_quantity_new = stack_max;
8346 else
8347 split_quantity_new = quantity;
8348
8349 if (ShouldSplitQuantity(split_quantity_new))
8350 {
8351 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
8352 {
8353 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
8354 new_item = ItemBase.Cast(o);
8355 }
8356
8357 if (new_item)
8358 {
8359 new_item.SetResultOfSplit(true);
8360 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8361 AddQuantity(-split_quantity_new, false, true);
8362 new_item.SetQuantity(split_quantity_new, false, true);
8363 }
8364 }
8365 }
8366 else
8367 {
8368 if (stack_max != 0)
8369 {
8370 if (stack_max < GetQuantity())
8371 {
8372 split_quantity_new = GetQuantity() - stack_max;
8373 }
8374
8375 if (split_quantity_new == 0)
8376 {
8377 if (!GetGame().IsMultiplayer())
8378 player.PhysicalPredictiveDropItem(this);
8379 else
8380 player.ServerDropEntity(this);
8381 return;
8382 }
8383
8384 if (ShouldSplitQuantity(split_quantity_new))
8385 {
8386 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
8387
8388 if (new_item)
8389 {
8390 new_item.SetResultOfSplit(true);
8391 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8392 SetQuantity(split_quantity_new, false, true);
8393 new_item.SetQuantity(stack_max, false, true);
8394 new_item.PlaceOnSurface();
8395 }
8396 }
8397 }
8398 }
8399 }
8400
8401 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
8402 {
8403 float split_quantity_new;
8404 ItemBase new_item;
8405 float quantity = GetQuantity();
8406 float stack_max = GetTargetQuantityMax(slot_id);
8407 InventoryLocation loc = new InventoryLocation;
8408
8409 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
8410 {
8411 if (stack_max <= GetQuantity())
8412 split_quantity_new = stack_max;
8413 else
8414 split_quantity_new = GetQuantity();
8415
8416 if (ShouldSplitQuantity(split_quantity_new))
8417 {
8418 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
8419 if (new_item)
8420 {
8421 new_item.SetResultOfSplit(true);
8422 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8423 AddQuantity(-split_quantity_new, false, true);
8424 new_item.SetQuantity(split_quantity_new, false, true);
8425 }
8426 }
8427 }
8428 else if (destination_entity && slot_id == -1)
8429 {
8430 if (quantity > stack_max)
8431 split_quantity_new = stack_max;
8432 else
8433 split_quantity_new = quantity;
8434
8435 if (ShouldSplitQuantity(split_quantity_new))
8436 {
8437 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
8438 {
8439 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
8440 new_item = ItemBase.Cast(o);
8441 }
8442
8443 if (new_item)
8444 {
8445 new_item.SetResultOfSplit(true);
8446 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8447 AddQuantity(-split_quantity_new, false, true);
8448 new_item.SetQuantity(split_quantity_new, false, true);
8449 }
8450 }
8451 }
8452 else
8453 {
8454 if (stack_max != 0)
8455 {
8456 if (stack_max < GetQuantity())
8457 {
8458 split_quantity_new = GetQuantity() - stack_max;
8459 }
8460
8461 if (ShouldSplitQuantity(split_quantity_new))
8462 {
8463 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
8464
8465 if (new_item)
8466 {
8467 new_item.SetResultOfSplit(true);
8468 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8469 SetQuantity(split_quantity_new, false, true);
8470 new_item.SetQuantity(stack_max, false, true);
8471 new_item.PlaceOnSurface();
8472 }
8473 }
8474 }
8475 }
8476 }
8477
8478 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
8479 {
8480 if (GetGame().IsClient())
8481 {
8482 if (ScriptInputUserData.CanStoreInputUserData())
8483 {
8484 ScriptInputUserData ctx = new ScriptInputUserData;
8486 ctx.Write(4);
8487 ItemBase thiz = this; // @NOTE: workaround for correct serialization
8488 ctx.Write(thiz);
8489 dst.WriteToContext(ctx);
8490 ctx.Send();
8491 }
8492 }
8493 else if (!GetGame().IsMultiplayer())
8494 {
8496 }
8497 }
8498
8499 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
8500 {
8501 if (GetGame().IsClient())
8502 {
8503 if (ScriptInputUserData.CanStoreInputUserData())
8504 {
8505 ScriptInputUserData ctx = new ScriptInputUserData;
8507 ctx.Write(2);
8508 ItemBase dummy = this; // @NOTE: workaround for correct serialization
8509 ctx.Write(dummy);
8510 ctx.Write(destination_entity);
8511 ctx.Write(true);
8512 ctx.Write(idx);
8513 ctx.Write(row);
8514 ctx.Write(col);
8515 ctx.Send();
8516 }
8517 }
8518 else if (!GetGame().IsMultiplayer())
8519 {
8520 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
8521 }
8522 }
8523
8524 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
8525 {
8527 }
8528
8529 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
8530 {
8531 float quantity = GetQuantity();
8532 float split_quantity_new;
8533 ItemBase new_item;
8534 if (dst.IsValid())
8535 {
8536 int slot_id = dst.GetSlot();
8537 float stack_max = GetTargetQuantityMax(slot_id);
8538
8539 if (quantity > stack_max)
8540 split_quantity_new = stack_max;
8541 else
8542 split_quantity_new = quantity;
8543
8544 if (ShouldSplitQuantity(split_quantity_new))
8545 {
8546 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
8547
8548 if (new_item)
8549 {
8550 new_item.SetResultOfSplit(true);
8551 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8552 AddQuantity(-split_quantity_new, false, true);
8553 new_item.SetQuantity(split_quantity_new, false, true);
8554 }
8555
8556 return new_item;
8557 }
8558 }
8559
8560 return null;
8561 }
8562
8563 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
8564 {
8565 float quantity = GetQuantity();
8566 float split_quantity_new;
8567 ItemBase new_item;
8568 if (destination_entity)
8569 {
8570 float stackable = GetTargetQuantityMax();
8571 if (quantity > stackable)
8572 split_quantity_new = stackable;
8573 else
8574 split_quantity_new = quantity;
8575
8576 if (ShouldSplitQuantity(split_quantity_new))
8577 {
8578 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
8579 if (new_item)
8580 {
8581 new_item.SetResultOfSplit(true);
8582 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8583 AddQuantity(-split_quantity_new, false, true);
8584 new_item.SetQuantity(split_quantity_new, false, true);
8585 }
8586 }
8587 }
8588 }
8589
8590 void SplitIntoStackMaxHandsClient(PlayerBase player)
8591 {
8592 if (GetGame().IsClient())
8593 {
8594 if (ScriptInputUserData.CanStoreInputUserData())
8595 {
8596 ScriptInputUserData ctx = new ScriptInputUserData;
8598 ctx.Write(3);
8599 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8600 ctx.Write(i1);
8601 ItemBase destination_entity = this;
8602 ctx.Write(destination_entity);
8603 ctx.Write(true);
8604 ctx.Write(0);
8605 ctx.Send();
8606 }
8607 }
8608 else if (!GetGame().IsMultiplayer())
8609 {
8610 SplitIntoStackMaxHands(player);
8611 }
8612 }
8613
8614 void SplitIntoStackMaxHands(PlayerBase player)
8615 {
8616 float quantity = GetQuantity();
8617 float split_quantity_new;
8618 ref ItemBase new_item;
8619 if (player)
8620 {
8621 float stackable = GetTargetQuantityMax();
8622 if (quantity > stackable)
8623 split_quantity_new = stackable;
8624 else
8625 split_quantity_new = quantity;
8626
8627 if (ShouldSplitQuantity(split_quantity_new))
8628 {
8629 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
8630 new_item = ItemBase.Cast(in_hands);
8631 if (new_item)
8632 {
8633 new_item.SetResultOfSplit(true);
8634 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8635 AddQuantity(-split_quantity_new, false, true);
8636 new_item.SetQuantity(split_quantity_new, false, true);
8637 }
8638 }
8639 }
8640 }
8641
8642 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
8643 {
8644 float quantity = GetQuantity();
8645 float split_quantity_new = Math.Floor(quantity * 0.5);
8646
8647 if (!ShouldSplitQuantity(split_quantity_new))
8648 return;
8649
8650 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
8651
8652 if (new_item)
8653 {
8654 if (new_item.GetQuantityMax() < split_quantity_new)
8655 {
8656 split_quantity_new = new_item.GetQuantityMax();
8657 }
8658
8659 new_item.SetResultOfSplit(true);
8660 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8661
8662 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
8663 {
8664 AddQuantity(-1, false, true);
8665 new_item.SetQuantity(1, false, true);
8666 }
8667 else
8668 {
8669 AddQuantity(-split_quantity_new, false, true);
8670 new_item.SetQuantity(split_quantity_new, false, true);
8671 }
8672 }
8673 }
8674
8675 void SplitItem(PlayerBase player)
8676 {
8677 float quantity = GetQuantity();
8678 float split_quantity_new = Math.Floor(quantity / 2);
8679
8680 if (!ShouldSplitQuantity(split_quantity_new))
8681 return;
8682
8683 InventoryLocation invloc = new InventoryLocation;
8684 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
8685
8686 ItemBase new_item;
8687 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
8688
8689 if (new_item)
8690 {
8691 if (new_item.GetQuantityMax() < split_quantity_new)
8692 {
8693 split_quantity_new = new_item.GetQuantityMax();
8694 }
8695 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
8696 {
8697 AddQuantity(-1, false, true);
8698 new_item.SetQuantity(1, false, true);
8699 }
8700 else if (split_quantity_new > 1)
8701 {
8702 AddQuantity(-split_quantity_new, false, true);
8703 new_item.SetQuantity(split_quantity_new, false, true);
8704 }
8705 }
8706 }
8707
8709 void OnQuantityChanged(float delta)
8710 {
8711 SetWeightDirty();
8712 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
8713
8714 if (parent)
8715 parent.OnAttachmentQuantityChangedEx(this, delta);
8716
8717 if (IsLiquidContainer())
8718 {
8719 if (GetQuantityNormalized() <= 0.0)
8720 {
8722 }
8723 else if (GetLiquidType() == LIQUID_NONE)
8724 {
8725 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
8727 }
8728 }
8729
8730 }
8731
8734 {
8735 // insert code here
8736 }
8737
8739 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
8740 {
8742 }
8743
8744 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
8745 {
8746 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
8747
8748 if (GetGame().IsServer())
8749 {
8750 if (newLevel == GameConstants.STATE_RUINED)
8751 {
8753 EntityAI parent = GetHierarchyParent();
8754 if (parent && parent.IsFireplace())
8755 {
8756 CargoBase cargo = GetInventory().GetCargo();
8757 if (cargo)
8758 {
8759 for (int i = 0; i < cargo.GetItemCount(); ++i)
8760 {
8761 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
8762 }
8763 }
8764 }
8765 }
8766
8767 if (IsResultOfSplit())
8768 {
8769 // reset the splitting result flag, return to normal item behavior
8770 SetResultOfSplit(false);
8771 return;
8772 }
8773
8774 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
8775 {
8776 SetCleanness(0);//unclean the item upon damage dealt
8777 }
8778 }
8779 }
8780
8781 // just the split? TODO: verify
8782 override void OnRightClick()
8783 {
8784 super.OnRightClick();
8785
8786 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
8787 {
8788 if (GetGame().IsClient())
8789 {
8790 if (ScriptInputUserData.CanStoreInputUserData())
8791 {
8792 EntityAI root = GetHierarchyRoot();
8793 Man playerOwner = GetHierarchyRootPlayer();
8794 InventoryLocation dst = new InventoryLocation;
8795
8796 // 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
8797 if (!playerOwner && root && root == this)
8798 {
8800 }
8801 else
8802 {
8803 // 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
8804 GetInventory().GetCurrentInventoryLocation(dst);
8805 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
8806 {
8807 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
8808 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
8809 {
8811 }
8812 else
8813 {
8814 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
8815 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
8816 this shouldnt cause issues within this scope*/
8817 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
8818 {
8820 }
8821 else
8822 {
8823 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
8824 }
8825 }
8826 }
8827 }
8828
8829 ScriptInputUserData ctx = new ScriptInputUserData;
8831 ctx.Write(4);
8832 ItemBase thiz = this; // @NOTE: workaround for correct serialization
8833 ctx.Write(thiz);
8834 dst.WriteToContext(ctx);
8835 ctx.Write(true); // dummy
8836 ctx.Send();
8837 }
8838 }
8839 else if (!GetGame().IsMultiplayer())
8840 {
8841 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
8842 }
8843 }
8844 }
8845
8846 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
8847 {
8848 if (root)
8849 {
8850 vector m4[4];
8851 root.GetTransform(m4);
8852 dst.SetGround(this, m4);
8853 }
8854 else
8855 {
8856 GetInventory().GetCurrentInventoryLocation(dst);
8857 }
8858 }
8859
8860 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
8861 {
8862 //TODO: delete check zero quantity check after fix double posts hands fsm events
8863 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
8864 return false;
8865
8866 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
8867 return false;
8868
8869 //can_this_be_combined = ConfigGetBool("canBeSplit");
8871 return false;
8872
8873
8874 Magazine mag = Magazine.Cast(this);
8875 if (mag)
8876 {
8877 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
8878 return false;
8879
8880 if (stack_max_limit)
8881 {
8882 Magazine other_mag = Magazine.Cast(other_item);
8883 if (other_item)
8884 {
8885 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
8886 return false;
8887 }
8888
8889 }
8890 }
8891 else
8892 {
8893 //TODO: delete check zero quantity check after fix double posts hands fsm events
8894 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
8895 return false;
8896
8897 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
8898 return false;
8899 }
8900
8901 PlayerBase player = null;
8902 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
8903 {
8904 if (player.GetInventory().HasAttachment(this))
8905 return false;
8906
8907 if (player.IsItemsToDelete())
8908 return false;
8909 }
8910
8911 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
8912 return false;
8913
8914 int slotID;
8915 string slotName;
8916 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
8917 return false;
8918
8919 return true;
8920 }
8921
8922 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
8923 {
8924 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
8925 }
8926
8927 bool IsResultOfSplit()
8928 {
8929 return m_IsResultOfSplit;
8930 }
8931
8932 void SetResultOfSplit(bool value)
8933 {
8934 m_IsResultOfSplit = value;
8935 }
8936
8937 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
8938 {
8939 return ComputeQuantityUsedEx(other_item, use_stack_max);
8940 }
8941
8942 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
8943 {
8944 float other_item_quantity = other_item.GetQuantity();
8945 float this_free_space;
8946
8947 float stack_max = GetQuantityMax();
8948
8949 this_free_space = stack_max - GetQuantity();
8950
8951 if (other_item_quantity > this_free_space)
8952 {
8953 return this_free_space;
8954 }
8955 else
8956 {
8957 return other_item_quantity;
8958 }
8959 }
8960
8961 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
8962 {
8963 CombineItems(ItemBase.Cast(entity2),use_stack_max);
8964 }
8965
8966 void CombineItems(ItemBase other_item, bool use_stack_max = true)
8967 {
8968 if (!CanBeCombined(other_item, false))
8969 return;
8970
8971 if (!IsMagazine() && other_item)
8972 {
8973 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
8974 if (quantity_used != 0)
8975 {
8976 float hp1 = GetHealth01("","");
8977 float hp2 = other_item.GetHealth01("","");
8978 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
8979 hpResult = hpResult / (GetQuantity() + quantity_used);
8980
8981 hpResult *= GetMaxHealth();
8982 Math.Round(hpResult);
8983 SetHealth("", "Health", hpResult);
8984
8985 AddQuantity(quantity_used);
8986 other_item.AddQuantity(-quantity_used);
8987 }
8988 }
8989 OnCombine(other_item);
8990 }
8991
8992 void OnCombine(ItemBase other_item)
8993 {
8994 #ifdef SERVER
8995 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
8996 GetHierarchyParent().IncreaseLifetimeUp();
8997 #endif
8998 };
8999
9000 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
9001 {
9002 PlayerBase p = PlayerBase.Cast(player);
9003
9004 array<int> recipesIds = p.m_Recipes;
9005 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
9006 if (moduleRecipesManager)
9007 {
9008 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
9009 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
9010 }
9011
9012 for (int i = 0;i < recipesIds.Count(); i++)
9013 {
9014 int key = recipesIds.Get(i);
9015 string recipeName = moduleRecipesManager.GetRecipeName(key);
9016 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
9017 }
9018 }
9019
9020 // -------------------------------------------------------------------------
9021 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
9022 {
9023 super.GetDebugActions(outputList);
9024
9025 //quantity
9026 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
9027 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
9028 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
9029 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
9030 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9031
9032 //health
9033 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
9034 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
9035 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
9036 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9037 //temperature
9038 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
9039 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
9040 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
9041 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9042
9043 //wet
9044 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
9045 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
9046 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9047
9048 //liquidtype
9049 if (IsLiquidContainer())
9050 {
9051 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
9052 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
9053 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9054 }
9055
9056 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
9057 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9058
9059 // watch
9060 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
9061 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
9062 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9063
9064 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
9065
9066 InventoryLocation loc = new InventoryLocation();
9067 GetInventory().GetCurrentInventoryLocation(loc);
9068 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
9069 {
9070 if (Gizmo_IsSupported())
9071 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
9072 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
9073 }
9074
9075 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9076 }
9077
9078 // -------------------------------------------------------------------------
9079 // -------------------------------------------------------------------------
9080 // -------------------------------------------------------------------------
9081 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
9082 {
9083 super.OnAction(action_id, player, ctx);
9084
9085 if (GetGame().IsClient() || !GetGame().IsMultiplayer())
9086 {
9087 switch (action_id)
9088 {
9089 case EActions.GIZMO_OBJECT:
9090 GetGame().GizmoSelectObject(this);
9091 return true;
9092 case EActions.GIZMO_PHYSICS:
9093 GetGame().GizmoSelectPhysics(GetPhysics());
9094 return true;
9095 }
9096 }
9097
9098 if (GetGame().IsServer())
9099 {
9100 switch (action_id)
9101 {
9102 case EActions.DELETE:
9103 Delete();
9104 return true;
9105 }
9106 }
9107
9108 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
9109 {
9110 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
9111 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
9112 PlayerBase p = PlayerBase.Cast(player);
9113 if (EActions.RECIPES_RANGE_START < 1000)
9114 {
9115 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
9116 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
9117 }
9118 }
9119 #ifndef SERVER
9120 else if (action_id == EActions.WATCH_PLAYER)
9121 {
9122 PluginDeveloper.SetDeveloperItemClientEx(player);
9123 }
9124 #endif
9125 if (GetGame().IsServer())
9126 {
9127 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
9128 {
9129 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
9130 OnDebugButtonPressServer(id + 1);
9131 }
9132
9133 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
9134 {
9135 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
9136 InsertAgent(agent_id,100);
9137 }
9138
9139 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
9140 {
9141 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
9142 RemoveAgent(agent_id2);
9143 }
9144
9145 else if (action_id == EActions.ADD_QUANTITY)
9146 {
9147 if (IsMagazine())
9148 {
9149 Magazine mag = Magazine.Cast(this);
9150 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
9151 }
9152 else
9153 {
9154 AddQuantity(GetQuantityMax() * 0.2);
9155 }
9156
9157 if (m_EM)
9158 {
9159 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
9160 }
9161 //PrintVariables();
9162 }
9163
9164 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
9165 {
9166 if (IsMagazine())
9167 {
9168 Magazine mag2 = Magazine.Cast(this);
9169 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
9170 }
9171 else
9172 {
9173 AddQuantity(- GetQuantityMax() * 0.2);
9174 }
9175 if (m_EM)
9176 {
9177 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
9178 }
9179 //PrintVariables();
9180 }
9181
9182 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
9183 {
9184 SetQuantity(0);
9185
9186 if (m_EM)
9187 {
9188 m_EM.SetEnergy(0);
9189 }
9190 }
9191
9192 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
9193 {
9195
9196 if (m_EM)
9197 {
9198 m_EM.SetEnergy(m_EM.GetEnergyMax());
9199 }
9200 }
9201
9202 else if (action_id == EActions.ADD_HEALTH)
9203 {
9204 AddHealth("","",GetMaxHealth("","Health")/5);
9205 }
9206 else if (action_id == EActions.REMOVE_HEALTH)
9207 {
9208 AddHealth("","",-GetMaxHealth("","Health")/5);
9209 }
9210 else if (action_id == EActions.DESTROY_HEALTH)
9211 {
9212 SetHealth01("","",0);
9213 }
9214 else if (action_id == EActions.WATCH_ITEM)
9215 {
9217 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
9218 #ifdef DEVELOPER
9219 SetDebugDeveloper_item(this);
9220 #endif
9221 }
9222
9223 else if (action_id == EActions.ADD_TEMPERATURE)
9224 {
9225 AddTemperature(20);
9226 //PrintVariables();
9227 }
9228
9229 else if (action_id == EActions.REMOVE_TEMPERATURE)
9230 {
9231 AddTemperature(-20);
9232 //PrintVariables();
9233 }
9234
9235 else if (action_id == EActions.FLIP_FROZEN)
9236 {
9237 SetFrozen(!GetIsFrozen());
9238 //PrintVariables();
9239 }
9240
9241 else if (action_id == EActions.ADD_WETNESS)
9242 {
9243 AddWet(GetWetMax()/5);
9244 //PrintVariables();
9245 }
9246
9247 else if (action_id == EActions.REMOVE_WETNESS)
9248 {
9249 AddWet(-GetWetMax()/5);
9250 //PrintVariables();
9251 }
9252
9253 else if (action_id == EActions.LIQUIDTYPE_UP)
9254 {
9255 int curr_type = GetLiquidType();
9256 SetLiquidType(curr_type * 2);
9257 //AddWet(1);
9258 //PrintVariables();
9259 }
9260
9261 else if (action_id == EActions.LIQUIDTYPE_DOWN)
9262 {
9263 int curr_type2 = GetLiquidType();
9264 SetLiquidType(curr_type2 / 2);
9265 }
9266
9267 else if (action_id == EActions.MAKE_SPECIAL)
9268 {
9269 auto debugParams = DebugSpawnParams.WithPlayer(player);
9270 OnDebugSpawnEx(debugParams);
9271 }
9272
9273 }
9274
9275
9276 return false;
9277 }
9278
9279 // -------------------------------------------------------------------------
9280
9281
9284 void OnActivatedByTripWire();
9285
9287 void OnActivatedByItem(notnull ItemBase item);
9288
9289 //----------------------------------------------------------------
9290 //returns true if item is able to explode when put in fire
9291 bool CanExplodeInFire()
9292 {
9293 return false;
9294 }
9295
9296 //----------------------------------------------------------------
9297 bool CanEat()
9298 {
9299 return true;
9300 }
9301
9302 //----------------------------------------------------------------
9303 override bool IsIgnoredByConstruction()
9304 {
9305 return true;
9306 }
9307
9308 //----------------------------------------------------------------
9309 //has FoodStages in config?
9310 bool HasFoodStage()
9311 {
9312 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
9313 return GetGame().ConfigIsExisting(config_path);
9314 }
9315
9317 FoodStage GetFoodStage()
9318 {
9319 return null;
9320 }
9321
9322 bool CanBeCooked()
9323 {
9324 return false;
9325 }
9326
9327 bool CanBeCookedOnStick()
9328 {
9329 return false;
9330 }
9331
9333 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
9335
9336 //----------------------------------------------------------------
9337 bool CanRepair(ItemBase item_repair_kit)
9338 {
9339 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
9340 return module_repairing.CanRepair(this, item_repair_kit);
9341 }
9342
9343 //----------------------------------------------------------------
9344 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
9345 {
9346 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
9347 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
9348 }
9349
9350 //----------------------------------------------------------------
9351 int GetItemSize()
9352 {
9353 /*
9354 vector v_size = this.ConfigGetVector("itemSize");
9355 int v_size_x = v_size[0];
9356 int v_size_y = v_size[1];
9357 int size = v_size_x * v_size_y;
9358 return size;
9359 */
9360
9361 return 1;
9362 }
9363
9364 //----------------------------------------------------------------
9365 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
9366 bool CanBeMovedOverride()
9367 {
9368 return m_CanBeMovedOverride;
9369 }
9370
9371 //----------------------------------------------------------------
9372 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
9373 void SetCanBeMovedOverride(bool setting)
9374 {
9375 m_CanBeMovedOverride = setting;
9376 }
9377
9378 //----------------------------------------------------------------
9386 void MessageToOwnerStatus(string text)
9387 {
9388 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9389
9390 if (player)
9391 {
9392 player.MessageStatus(text);
9393 }
9394 }
9395
9396 //----------------------------------------------------------------
9404 void MessageToOwnerAction(string text)
9405 {
9406 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9407
9408 if (player)
9409 {
9410 player.MessageAction(text);
9411 }
9412 }
9413
9414 //----------------------------------------------------------------
9422 void MessageToOwnerFriendly(string text)
9423 {
9424 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9425
9426 if (player)
9427 {
9428 player.MessageFriendly(text);
9429 }
9430 }
9431
9432 //----------------------------------------------------------------
9440 void MessageToOwnerImportant(string text)
9441 {
9442 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9443
9444 if (player)
9445 {
9446 player.MessageImportant(text);
9447 }
9448 }
9449
9450 override bool IsItemBase()
9451 {
9452 return true;
9453 }
9454
9455 // Checks if item is of questioned kind
9456 override bool KindOf(string tag)
9457 {
9458 bool found = false;
9459 string item_name = this.GetType();
9460 ref TStringArray item_tag_array = new TStringArray;
9461 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
9462
9463 int array_size = item_tag_array.Count();
9464 for (int i = 0; i < array_size; i++)
9465 {
9466 if (item_tag_array.Get(i) == tag)
9467 {
9468 found = true;
9469 break;
9470 }
9471 }
9472 return found;
9473 }
9474
9475
9476 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
9477 {
9478 //Debug.Log("OnRPC called");
9479 super.OnRPC(sender, rpc_type,ctx);
9480
9481 //Play soundset for attachment locking (ActionLockAttachment.c)
9482 switch (rpc_type)
9483 {
9484 #ifndef SERVER
9485 case ERPCs.RPC_SOUND_LOCK_ATTACH:
9486 Param2<bool, string> p = new Param2<bool, string>(false, "");
9487
9488 if (!ctx.Read(p))
9489 return;
9490
9491 bool play = p.param1;
9492 string soundSet = p.param2;
9493
9494 if (play)
9495 {
9496 if (m_LockingSound)
9497 {
9499 {
9500 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
9501 }
9502 }
9503 else
9504 {
9505 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
9506 }
9507 }
9508 else
9509 {
9510 SEffectManager.DestroyEffect(m_LockingSound);
9511 }
9512
9513 break;
9514 #endif
9515
9516 }
9517
9518 if (GetWrittenNoteData())
9519 {
9520 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
9521 }
9522 }
9523
9524 //-----------------------------
9525 // VARIABLE MANIPULATION SYSTEM
9526 //-----------------------------
9527 int NameToID(string name)
9528 {
9529 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
9530 return plugin.GetID(name);
9531 }
9532
9533 string IDToName(int id)
9534 {
9535 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
9536 return plugin.GetName(id);
9537 }
9538
9540 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
9541 {
9542 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
9543 //read the flags
9544 int varFlags;
9545 if (!ctx.Read(varFlags))
9546 return;
9547
9548 if (varFlags & ItemVariableFlags.FLOAT)
9549 {
9550 ReadVarsFromCTX(ctx);
9551 }
9552 }
9553
9554 override void SerializeNumericalVars(array<float> floats_out)
9555 {
9556 //some variables handled on EntityAI level already!
9557 super.SerializeNumericalVars(floats_out);
9558
9559 // the order of serialization must be the same as the order of de-serialization
9560 //--------------------------------------------
9561 if (IsVariableSet(VARIABLE_QUANTITY))
9562 {
9563 floats_out.Insert(m_VarQuantity);
9564 }
9565 //--------------------------------------------
9566 if (IsVariableSet(VARIABLE_WET))
9567 {
9568 floats_out.Insert(m_VarWet);
9569 }
9570 //--------------------------------------------
9571 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
9572 {
9573 floats_out.Insert(m_VarLiquidType);
9574 }
9575 //--------------------------------------------
9576 if (IsVariableSet(VARIABLE_COLOR))
9577 {
9578 floats_out.Insert(m_ColorComponentR);
9579 floats_out.Insert(m_ColorComponentG);
9580 floats_out.Insert(m_ColorComponentB);
9581 floats_out.Insert(m_ColorComponentA);
9582 }
9583 //--------------------------------------------
9584 if (IsVariableSet(VARIABLE_CLEANNESS))
9585 {
9586 floats_out.Insert(m_Cleanness);
9587 }
9588 }
9589
9590 override void DeSerializeNumericalVars(array<float> floats)
9591 {
9592 //some variables handled on EntityAI level already!
9593 super.DeSerializeNumericalVars(floats);
9594
9595 // the order of serialization must be the same as the order of de-serialization
9596 int index = 0;
9597 int mask = Math.Round(floats.Get(index));
9598
9599 index++;
9600 //--------------------------------------------
9601 if (mask & VARIABLE_QUANTITY)
9602 {
9603 if (m_IsStoreLoad)
9604 {
9605 SetStoreLoadedQuantity(floats.Get(index));
9606 }
9607 else
9608 {
9609 float quantity = floats.Get(index);
9610 SetQuantity(quantity, true, false, false, false);
9611 }
9612 index++;
9613 }
9614 //--------------------------------------------
9615 if (mask & VARIABLE_WET)
9616 {
9617 float wet = floats.Get(index);
9618 SetWet(wet);
9619 index++;
9620 }
9621 //--------------------------------------------
9622 if (mask & VARIABLE_LIQUIDTYPE)
9623 {
9624 int liquidtype = Math.Round(floats.Get(index));
9625 SetLiquidType(liquidtype);
9626 index++;
9627 }
9628 //--------------------------------------------
9629 if (mask & VARIABLE_COLOR)
9630 {
9631 m_ColorComponentR = Math.Round(floats.Get(index));
9632 index++;
9633 m_ColorComponentG = Math.Round(floats.Get(index));
9634 index++;
9635 m_ColorComponentB = Math.Round(floats.Get(index));
9636 index++;
9637 m_ColorComponentA = Math.Round(floats.Get(index));
9638 index++;
9639 }
9640 //--------------------------------------------
9641 if (mask & VARIABLE_CLEANNESS)
9642 {
9643 int cleanness = Math.Round(floats.Get(index));
9644 SetCleanness(cleanness);
9645 index++;
9646 }
9647 }
9648
9649 override void WriteVarsToCTX(ParamsWriteContext ctx)
9650 {
9651 super.WriteVarsToCTX(ctx);
9652
9653 //--------------------------------------------
9654 if (IsVariableSet(VARIABLE_QUANTITY))
9655 {
9656 ctx.Write(GetQuantity());
9657 }
9658 //--------------------------------------------
9659 if (IsVariableSet(VARIABLE_WET))
9660 {
9661 ctx.Write(GetWet());
9662 }
9663 //--------------------------------------------
9664 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
9665 {
9666 ctx.Write(GetLiquidType());
9667 }
9668 //--------------------------------------------
9669 if (IsVariableSet(VARIABLE_COLOR))
9670 {
9671 int r,g,b,a;
9672 GetColor(r,g,b,a);
9673 ctx.Write(r);
9674 ctx.Write(g);
9675 ctx.Write(b);
9676 ctx.Write(a);
9677 }
9678 //--------------------------------------------
9679 if (IsVariableSet(VARIABLE_CLEANNESS))
9680 {
9681 ctx.Write(GetCleanness());
9682 }
9683 }
9684
9685 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
9686 {
9687 if (!super.ReadVarsFromCTX(ctx,version))
9688 return false;
9689
9690 int intValue;
9691 float value;
9692
9693 if (version < 140)
9694 {
9695 if (!ctx.Read(intValue))
9696 return false;
9697
9698 m_VariablesMask = intValue;
9699 }
9700
9701 if (m_VariablesMask & VARIABLE_QUANTITY)
9702 {
9703 if (!ctx.Read(value))
9704 return false;
9705
9706 if (IsStoreLoad())
9707 {
9709 }
9710 else
9711 {
9712 SetQuantity(value, true, false, false, false);
9713 }
9714 }
9715 //--------------------------------------------
9716 if (version < 140)
9717 {
9718 if (m_VariablesMask & VARIABLE_TEMPERATURE)
9719 {
9720 if (!ctx.Read(value))
9721 return false;
9722 SetTemperatureDirect(value);
9723 }
9724 }
9725 //--------------------------------------------
9726 if (m_VariablesMask & VARIABLE_WET)
9727 {
9728 if (!ctx.Read(value))
9729 return false;
9730 SetWet(value);
9731 }
9732 //--------------------------------------------
9733 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
9734 {
9735 if (!ctx.Read(intValue))
9736 return false;
9737 SetLiquidType(intValue);
9738 }
9739 //--------------------------------------------
9740 if (m_VariablesMask & VARIABLE_COLOR)
9741 {
9742 int r,g,b,a;
9743 if (!ctx.Read(r))
9744 return false;
9745 if (!ctx.Read(g))
9746 return false;
9747 if (!ctx.Read(b))
9748 return false;
9749 if (!ctx.Read(a))
9750 return false;
9751
9752 SetColor(r,g,b,a);
9753 }
9754 //--------------------------------------------
9755 if (m_VariablesMask & VARIABLE_CLEANNESS)
9756 {
9757 if (!ctx.Read(intValue))
9758 return false;
9759 SetCleanness(intValue);
9760 }
9761 //--------------------------------------------
9762 if (version >= 138 && version < 140)
9763 {
9764 if (m_VariablesMask & VARIABLE_TEMPERATURE)
9765 {
9766 if (!ctx.Read(intValue))
9767 return false;
9768 SetFrozen(intValue);
9769 }
9770 }
9771
9772 return true;
9773 }
9774
9775 //----------------------------------------------------------------
9776 override bool OnStoreLoad(ParamsReadContext ctx, int version)
9777 {
9778 m_IsStoreLoad = true;
9780 {
9781 m_FixDamageSystemInit = true;
9782 }
9783
9784 if (!super.OnStoreLoad(ctx, version))
9785 {
9786 m_IsStoreLoad = false;
9787 return false;
9788 }
9789
9790 if (version >= 114)
9791 {
9792 bool hasQuickBarIndexSaved;
9793
9794 if (!ctx.Read(hasQuickBarIndexSaved))
9795 {
9796 m_IsStoreLoad = false;
9797 return false;
9798 }
9799
9800 if (hasQuickBarIndexSaved)
9801 {
9802 int itmQBIndex;
9803
9804 //Load quickbar item bind
9805 if (!ctx.Read(itmQBIndex))
9806 {
9807 m_IsStoreLoad = false;
9808 return false;
9809 }
9810
9811 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
9812 if (itmQBIndex != -1 && parentPlayer)
9813 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
9814 }
9815 }
9816 else
9817 {
9818 // Backup of how it used to be
9819 PlayerBase player;
9820 int itemQBIndex;
9821 if (version == int.MAX)
9822 {
9823 if (!ctx.Read(itemQBIndex))
9824 {
9825 m_IsStoreLoad = false;
9826 return false;
9827 }
9828 }
9829 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
9830 {
9831 //Load quickbar item bind
9832 if (!ctx.Read(itemQBIndex))
9833 {
9834 m_IsStoreLoad = false;
9835 return false;
9836 }
9837 if (itemQBIndex != -1 && player)
9838 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
9839 }
9840 }
9841
9842 if (version < 140)
9843 {
9844 // variable management system
9845 if (!LoadVariables(ctx, version))
9846 {
9847 m_IsStoreLoad = false;
9848 return false;
9849 }
9850 }
9851
9852 //agent trasmission system
9853 if (!LoadAgents(ctx, version))
9854 {
9855 m_IsStoreLoad = false;
9856 return false;
9857 }
9858 if (version >= 132)
9859 {
9860 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
9861 if (raib)
9862 {
9863 if (!raib.OnStoreLoad(ctx,version))
9864 {
9865 m_IsStoreLoad = false;
9866 return false;
9867 }
9868 }
9869 }
9870
9871 m_IsStoreLoad = false;
9872 return true;
9873 }
9874
9875 //----------------------------------------------------------------
9876
9877 override void OnStoreSave(ParamsWriteContext ctx)
9878 {
9879 super.OnStoreSave(ctx);
9880
9881 PlayerBase player;
9882 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
9883 {
9884 ctx.Write(true); // Keep track of if we should actually read this in or not
9885 //Save quickbar item bind
9886 int itemQBIndex = -1;
9887 itemQBIndex = player.FindQuickBarEntityIndex(this);
9888 ctx.Write(itemQBIndex);
9889 }
9890 else
9891 {
9892 ctx.Write(false); // Keep track of if we should actually read this in or not
9893 }
9894
9895 SaveAgents(ctx);//agent trasmission system
9896
9897 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
9898 if (raib)
9899 {
9900 raib.OnStoreSave(ctx);
9901 }
9902 }
9903 //----------------------------------------------------------------
9904
9905 override void AfterStoreLoad()
9906 {
9907 super.AfterStoreLoad();
9908
9910 {
9912 }
9913
9914 if (GetStoreLoadedQuantity() != float.LOWEST)
9915 {
9917 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
9918 }
9919 }
9920
9921 override void EEOnAfterLoad()
9922 {
9923 super.EEOnAfterLoad();
9924
9926 {
9927 m_FixDamageSystemInit = false;
9928 }
9929
9932 }
9933
9934 bool CanBeDisinfected()
9935 {
9936 return false;
9937 }
9938
9939
9940 //----------------------------------------------------------------
9941 override void OnVariablesSynchronized()
9942 {
9943 if (m_Initialized)
9944 {
9945 #ifdef PLATFORM_CONSOLE
9946 //bruteforce it is
9947 if (IsSplitable())
9948 {
9949 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
9950 if (menu)
9951 {
9952 menu.Refresh();
9953 }
9954 }
9955 #endif
9956 }
9957
9959 {
9960 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9961 m_WantPlayImpactSound = false;
9962 }
9963
9965 {
9966 SetWeightDirty();
9968 }
9969 if (m_VarWet != m_VarWetPrev)
9970 {
9973 }
9974
9975 if (m_SoundSyncPlay != 0)
9976 {
9977 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
9978 m_SoundSyncPlay = 0;
9979 }
9980 if (m_SoundSyncStop != 0)
9981 {
9982 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
9983 m_SoundSyncStop = 0;
9984 }
9985
9986 super.OnVariablesSynchronized();
9987 }
9988
9989 //------------------------- Quantity
9990 //----------------------------------------------------------------
9992 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
9993 {
9994 if (!IsServerCheck(allow_client))
9995 return false;
9996
9997 if (!HasQuantity())
9998 return false;
9999
10000 float min = GetQuantityMin();
10001 float max = GetQuantityMax();
10002
10003 if (value <= (min + 0.001))
10004 value = min;
10005
10006 if (value == min)
10007 {
10008 if (destroy_config)
10009 {
10010 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
10011 if (dstr)
10012 {
10013 m_VarQuantity = Math.Clamp(value, min, max);
10014 this.Delete();
10015 return true;
10016 }
10017 }
10018 else if (destroy_forced)
10019 {
10020 m_VarQuantity = Math.Clamp(value, min, max);
10021 this.Delete();
10022 return true;
10023 }
10024 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
10025 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
10026 }
10027
10028 float delta = m_VarQuantity;
10029 m_VarQuantity = Math.Clamp(value, min, max);
10030
10031 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
10032 {
10033 delta = m_VarQuantity - delta;
10034
10035 if (delta)
10036 OnQuantityChanged(delta);
10037 }
10038
10039 SetVariableMask(VARIABLE_QUANTITY);
10040
10041 return false;
10042 }
10043
10044 //----------------------------------------------------------------
10046 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
10047 {
10048 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
10049 }
10050 //----------------------------------------------------------------
10051 void SetQuantityMax()
10052 {
10053 float max = GetQuantityMax();
10054 SetQuantity(max);
10055 }
10056
10057 override void SetQuantityToMinimum()
10058 {
10059 float min = GetQuantityMin();
10060 SetQuantity(min);
10061 }
10062 //----------------------------------------------------------------
10064 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
10065 {
10066 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
10067 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
10068 SetQuantity(result, destroy_config, destroy_forced);
10069 }
10070
10071 //----------------------------------------------------------------
10073 override float GetQuantityNormalized()
10074 {
10075 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
10076 }
10077
10079 {
10080 return GetQuantityNormalized();
10081 }
10082
10083 /*void SetAmmoNormalized(float value)
10084 {
10085 float value_clamped = Math.Clamp(value, 0, 1);
10086 Magazine this_mag = Magazine.Cast(this);
10087 int max_rounds = this_mag.GetAmmoMax();
10088 int result = value * max_rounds;//can the rounded if higher precision is required
10089 this_mag.SetAmmoCount(result);
10090 }*/
10091 //----------------------------------------------------------------
10092 override int GetQuantityMax()
10093 {
10094 int slot = -1;
10095 if (GetInventory())
10096 {
10097 InventoryLocation il = new InventoryLocation;
10098 GetInventory().GetCurrentInventoryLocation(il);
10099 slot = il.GetSlot();
10100 }
10101
10102 return GetTargetQuantityMax(slot);
10103 }
10104
10105 override int GetTargetQuantityMax(int attSlotID = -1)
10106 {
10107 float quantity_max = 0;
10108
10109 if (IsSplitable()) //only stackable/splitable items can check for stack size
10110 {
10111 if (attSlotID != -1)
10112 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
10113
10114 if (quantity_max <= 0)
10115 quantity_max = m_VarStackMax;
10116 }
10117
10118 if (quantity_max <= 0)
10119 quantity_max = m_VarQuantityMax;
10120
10121 return quantity_max;
10122 }
10123 //----------------------------------------------------------------
10124 override int GetQuantityMin()
10125 {
10126 return m_VarQuantityMin;
10127 }
10128 //----------------------------------------------------------------
10129 int GetQuantityInit()
10130 {
10131 return m_VarQuantityInit;
10132 }
10133
10134 //----------------------------------------------------------------
10135 override bool HasQuantity()
10136 {
10137 return !(GetQuantityMax() - GetQuantityMin() == 0);
10138 }
10139
10140 override float GetQuantity()
10141 {
10142 return m_VarQuantity;
10143 }
10144
10145 bool IsFullQuantity()
10146 {
10147 return GetQuantity() >= GetQuantityMax();
10148 }
10149
10150 //Calculates weight of single item without attachments and cargo
10151 override float GetSingleInventoryItemWeightEx()
10152 {
10153 //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
10154 float weightEx = GetWeightEx();//overall weight of the item
10155 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
10156 return weightEx - special;
10157 }
10158
10159 // Obsolete, use GetSingleInventoryItemWeightEx() instead
10161 {
10163 }
10164
10165 override protected float GetWeightSpecialized(bool forceRecalc = false)
10166 {
10167 if (IsSplitable()) //quantity determines size of the stack
10168 {
10169 #ifdef DEVELOPER
10170 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
10171 {
10172 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
10173 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
10174 }
10175 #endif
10176
10177 return GetQuantity() * GetConfigWeightModified();
10178 }
10179 else if (HasEnergyManager())// items with energy manager
10180 {
10181 #ifdef DEVELOPER
10182 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
10183 {
10184 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
10185 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
10186 }
10187 #endif
10188 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
10189 }
10190 else//everything else
10191 {
10192 #ifdef DEVELOPER
10193 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
10194 {
10195 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
10196 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
10197 }
10198 #endif
10199 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
10200 }
10201 }
10202
10204 int GetNumberOfItems()
10205 {
10206 int item_count = 0;
10207 ItemBase item;
10208
10209 if (GetInventory().GetCargo() != NULL)
10210 {
10211 item_count = GetInventory().GetCargo().GetItemCount();
10212 }
10213
10214 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
10215 {
10216 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
10217 if (item)
10218 item_count += item.GetNumberOfItems();
10219 }
10220 return item_count;
10221 }
10222
10224 float GetUnitWeight(bool include_wetness = true)
10225 {
10226 float weight = 0;
10227 float wetness = 1;
10228 if (include_wetness)
10229 wetness += GetWet();
10230 if (IsSplitable()) //quantity determines size of the stack
10231 {
10232 weight = wetness * m_ConfigWeight;
10233 }
10234 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
10235 {
10236 weight = 1;
10237 }
10238 return weight;
10239 }
10240
10241 //-----------------------------------------------------------------
10242
10243 override void ClearInventory()
10244 {
10245 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
10246 {
10247 GameInventory inv = GetInventory();
10248 array<EntityAI> items = new array<EntityAI>;
10249 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
10250 for (int i = 0; i < items.Count(); i++)
10251 {
10252 ItemBase item = ItemBase.Cast(items.Get(i));
10253 if (item)
10254 {
10255 GetGame().ObjectDelete(item);
10256 }
10257 }
10258 }
10259 }
10260
10261 //------------------------- Energy
10262
10263 //----------------------------------------------------------------
10264 float GetEnergy()
10265 {
10266 float energy = 0;
10267 if (HasEnergyManager())
10268 {
10269 energy = GetCompEM().GetEnergy();
10270 }
10271 return energy;
10272 }
10273
10274
10275 override void OnEnergyConsumed()
10276 {
10277 super.OnEnergyConsumed();
10278
10280 }
10281
10282 override void OnEnergyAdded()
10283 {
10284 super.OnEnergyAdded();
10285
10287 }
10288
10289 // Converts energy (from Energy Manager) to quantity, if enabled.
10291 {
10292 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
10293 {
10294 if (HasQuantity())
10295 {
10296 float energy_0to1 = GetCompEM().GetEnergy0To1();
10297 SetQuantityNormalized(energy_0to1);
10298 }
10299 }
10300 }
10301
10302 //----------------------------------------------------------------
10303 float GetHeatIsolationInit()
10304 {
10305 return ConfigGetFloat("heatIsolation");
10306 }
10307
10308 float GetHeatIsolation()
10309 {
10310 return m_HeatIsolation;
10311 }
10312
10313 float GetDryingIncrement(string pIncrementName)
10314 {
10315 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
10316 if (GetGame().ConfigIsExisting(paramPath))
10317 return GetGame().ConfigGetFloat(paramPath);
10318
10319 return 0.0;
10320 }
10321
10322 float GetSoakingIncrement(string pIncrementName)
10323 {
10324 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
10325 if (GetGame().ConfigIsExisting(paramPath))
10326 return GetGame().ConfigGetFloat(paramPath);
10327
10328 return 0.0;
10329 }
10330 //----------------------------------------------------------------
10331 override void SetWet(float value, bool allow_client = false)
10332 {
10333 if (!IsServerCheck(allow_client))
10334 return;
10335
10336 float min = GetWetMin();
10337 float max = GetWetMax();
10338
10339 float previousValue = m_VarWet;
10340
10341 m_VarWet = Math.Clamp(value, min, max);
10342
10343 if (previousValue != m_VarWet)
10344 {
10345 SetVariableMask(VARIABLE_WET);
10346 OnWetChanged(m_VarWet, previousValue);
10347 }
10348 }
10349 //----------------------------------------------------------------
10350 override void AddWet(float value)
10351 {
10352 SetWet(GetWet() + value);
10353 }
10354 //----------------------------------------------------------------
10355 override void SetWetMax()
10356 {
10358 }
10359 //----------------------------------------------------------------
10360 override float GetWet()
10361 {
10362 return m_VarWet;
10363 }
10364 //----------------------------------------------------------------
10365 override float GetWetMax()
10366 {
10367 return m_VarWetMax;
10368 }
10369 //----------------------------------------------------------------
10370 override float GetWetMin()
10371 {
10372 return m_VarWetMin;
10373 }
10374 //----------------------------------------------------------------
10375 override float GetWetInit()
10376 {
10377 return m_VarWetInit;
10378 }
10379 //----------------------------------------------------------------
10380 override void OnWetChanged(float newVal, float oldVal)
10381 {
10382 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
10383 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
10384 if (newLevel != oldLevel)
10385 {
10386 OnWetLevelChanged(newLevel,oldLevel);
10387 }
10388 }
10389
10390 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
10391 {
10392 SetWeightDirty();
10393 }
10394
10395 override EWetnessLevel GetWetLevel()
10396 {
10397 return GetWetLevelInternal(m_VarWet);
10398 }
10399
10400 //----------------------------------------------------------------
10401
10402 override void SetStoreLoad(bool value)
10403 {
10404 m_IsStoreLoad = value;
10405 }
10406
10407 override bool IsStoreLoad()
10408 {
10409 return m_IsStoreLoad;
10410 }
10411
10412 override void SetStoreLoadedQuantity(float value)
10413 {
10414 m_StoreLoadedQuantity = value;
10415 }
10416
10417 override float GetStoreLoadedQuantity()
10418 {
10419 return m_StoreLoadedQuantity;
10420 }
10421
10422 //----------------------------------------------------------------
10423
10424 float GetItemModelLength()
10425 {
10426 if (ConfigIsExisting("itemModelLength"))
10427 {
10428 return ConfigGetFloat("itemModelLength");
10429 }
10430 return 0;
10431 }
10432
10433 float GetItemAttachOffset()
10434 {
10435 if (ConfigIsExisting("itemAttachOffset"))
10436 {
10437 return ConfigGetFloat("itemAttachOffset");
10438 }
10439 return 0;
10440 }
10441
10442 override void SetCleanness(int value, bool allow_client = false)
10443 {
10444 if (!IsServerCheck(allow_client))
10445 return;
10446
10447 int previousValue = m_Cleanness;
10448
10449 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
10450
10451 if (previousValue != m_Cleanness)
10452 SetVariableMask(VARIABLE_CLEANNESS);
10453 }
10454
10455 override int GetCleanness()
10456 {
10457 return m_Cleanness;
10458 }
10459
10461 {
10462 return true;
10463 }
10464
10465 //----------------------------------------------------------------
10466 // ATTACHMENT LOCKING
10467 // Getters relevant to generic ActionLockAttachment
10468 int GetLockType()
10469 {
10470 return m_LockType;
10471 }
10472
10473 string GetLockSoundSet()
10474 {
10475 return m_LockSoundSet;
10476 }
10477
10478 //----------------------------------------------------------------
10479 //------------------------- Color
10480 // sets items color variable given color components
10481 override void SetColor(int r, int g, int b, int a)
10482 {
10487 SetVariableMask(VARIABLE_COLOR);
10488 }
10490 override void GetColor(out int r,out int g,out int b,out int a)
10491 {
10496 }
10497
10498 bool IsColorSet()
10499 {
10500 return IsVariableSet(VARIABLE_COLOR);
10501 }
10502
10504 string GetColorString()
10505 {
10506 int r,g,b,a;
10507 GetColor(r,g,b,a);
10508 r = r/255;
10509 g = g/255;
10510 b = b/255;
10511 a = a/255;
10512 return MiscGameplayFunctions.GetColorString(r, g, b, a);
10513 }
10514 //----------------------------------------------------------------
10515 //------------------------- LiquidType
10516
10517 override void SetLiquidType(int value, bool allow_client = false)
10518 {
10519 if (!IsServerCheck(allow_client))
10520 return;
10521
10522 int old = m_VarLiquidType;
10523 m_VarLiquidType = value;
10524 OnLiquidTypeChanged(old,value);
10525 SetVariableMask(VARIABLE_LIQUIDTYPE);
10526 }
10527
10528 int GetLiquidTypeInit()
10529 {
10530 return ConfigGetInt("varLiquidTypeInit");
10531 }
10532
10533 override int GetLiquidType()
10534 {
10535 return m_VarLiquidType;
10536 }
10537
10538 protected void OnLiquidTypeChanged(int oldType, int newType)
10539 {
10540 if (newType == LIQUID_NONE && GetIsFrozen())
10541 SetFrozen(false);
10542 }
10543
10545 void UpdateQuickbarShortcutVisibility(PlayerBase player)
10546 {
10547 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
10548 }
10549
10550 // -------------------------------------------------------------------------
10552 void OnInventoryEnter(Man player)
10553 {
10554 PlayerBase nplayer;
10555 if (PlayerBase.CastTo(nplayer, player))
10556 {
10557 m_CanPlayImpactSound = true;
10558 //nplayer.OnItemInventoryEnter(this);
10559 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
10560 }
10561 }
10562
10563 // -------------------------------------------------------------------------
10565 void OnInventoryExit(Man player)
10566 {
10567 PlayerBase nplayer;
10568 if (PlayerBase.CastTo(nplayer,player))
10569 {
10570 //nplayer.OnItemInventoryExit(this);
10571 nplayer.SetEnableQuickBarEntityShortcut(this,false);
10572
10573 }
10574
10575 //if (!GetGame().IsDedicatedServer())
10576 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
10577
10578
10579 if (HasEnergyManager())
10580 {
10581 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
10582 }
10583 }
10584
10585 // ADVANCED PLACEMENT EVENTS
10586 override void OnPlacementStarted(Man player)
10587 {
10588 super.OnPlacementStarted(player);
10589
10590 SetTakeable(false);
10591 }
10592
10593 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
10594 {
10595 if (m_AdminLog)
10596 {
10597 m_AdminLog.OnPlacementComplete(player, this);
10598 }
10599
10600 super.OnPlacementComplete(player, position, orientation);
10601 }
10602
10603 //-----------------------------
10604 // AGENT SYSTEM
10605 //-----------------------------
10606 //--------------------------------------------------------------------------
10607 bool ContainsAgent(int agent_id)
10608 {
10609 if (agent_id & m_AttachedAgents)
10610 {
10611 return true;
10612 }
10613 else
10614 {
10615 return false;
10616 }
10617 }
10618
10619 //--------------------------------------------------------------------------
10620 override void RemoveAgent(int agent_id)
10621 {
10622 if (ContainsAgent(agent_id))
10623 {
10624 m_AttachedAgents = ~agent_id & m_AttachedAgents;
10625 }
10626 }
10627
10628 //--------------------------------------------------------------------------
10629 override void RemoveAllAgents()
10630 {
10631 m_AttachedAgents = 0;
10632 }
10633 //--------------------------------------------------------------------------
10634 override void RemoveAllAgentsExcept(int agent_to_keep)
10635 {
10636 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
10637 }
10638 // -------------------------------------------------------------------------
10639 override void InsertAgent(int agent, float count = 1)
10640 {
10641 if (count < 1)
10642 return;
10643 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
10645 }
10646
10648 void TransferAgents(int agents)
10649 {
10651 }
10652
10653 // -------------------------------------------------------------------------
10654 override int GetAgents()
10655 {
10656 return m_AttachedAgents;
10657 }
10658 //----------------------------------------------------------------------
10659
10660 /*int GetContaminationType()
10661 {
10662 int contamination_type;
10663
10664 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
10665 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
10666 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
10667 const int DIRTY_MASK = eAgents.WOUND_AGENT;
10668
10669 Edible_Base edible = Edible_Base.Cast(this);
10670 int agents = GetAgents();
10671 if (edible)
10672 {
10673 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
10674 if (profile)
10675 {
10676 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
10677 }
10678 }
10679 if (agents & CONTAMINATED_MASK)
10680 {
10681 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
10682 }
10683 if (agents & POISONED_MASK)
10684 {
10685 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
10686 }
10687 if (agents & NERVE_GAS_MASK)
10688 {
10689 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
10690 }
10691 if (agents & DIRTY_MASK)
10692 {
10693 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
10694 }
10695
10696 return agents;
10697 }*/
10698
10699 // -------------------------------------------------------------------------
10700 bool LoadAgents(ParamsReadContext ctx, int version)
10701 {
10702 if (!ctx.Read(m_AttachedAgents))
10703 return false;
10704 return true;
10705 }
10706 // -------------------------------------------------------------------------
10708 {
10709
10711 }
10712 // -------------------------------------------------------------------------
10713
10715 override void CheckForRoofLimited(float timeTresholdMS = 3000)
10716 {
10717 super.CheckForRoofLimited(timeTresholdMS);
10718
10719 float time = GetGame().GetTime();
10720 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
10721 {
10722 m_PreviousRoofTestTime = time;
10723 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
10724 }
10725 }
10726
10727 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
10728 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
10729 {
10730 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
10731 {
10732 return 0;
10733 }
10734
10735 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
10736 {
10737 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
10738 if (filter)
10739 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
10740 else
10741 return 0;//otherwise return 0 when no filter attached
10742 }
10743
10744 string subclassPath, entryName;
10745
10746 switch (type)
10747 {
10748 case DEF_BIOLOGICAL:
10749 entryName = "biological";
10750 break;
10751 case DEF_CHEMICAL:
10752 entryName = "chemical";
10753 break;
10754 default:
10755 entryName = "biological";
10756 break;
10757 }
10758
10759 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
10760
10761 return GetGame().ConfigGetFloat(subclassPath + entryName);
10762 }
10763
10764
10765
10767 override void EEOnCECreate()
10768 {
10769 if (!IsMagazine())
10771
10773 }
10774
10775
10776 //-------------------------
10777 // OPEN/CLOSE USER ACTIONS
10778 //-------------------------
10780 void Open();
10781 void Close();
10782 bool IsOpen()
10783 {
10784 return true;
10785 }
10786
10787 override bool CanDisplayCargo()
10788 {
10789 return IsOpen();
10790 }
10791
10792
10793 // ------------------------------------------------------------
10794 // CONDITIONS
10795 // ------------------------------------------------------------
10796 override bool CanPutInCargo(EntityAI parent)
10797 {
10798 if (parent)
10799 {
10800 if (parent.IsInherited(DayZInfected))
10801 return true;
10802
10803 if (!parent.IsRuined())
10804 return true;
10805 }
10806
10807 return true;
10808 }
10809
10810 override bool CanPutAsAttachment(EntityAI parent)
10811 {
10812 if (!super.CanPutAsAttachment(parent))
10813 {
10814 return false;
10815 }
10816
10817 if (!IsRuined() && !parent.IsRuined())
10818 {
10819 return true;
10820 }
10821
10822 return false;
10823 }
10824
10825 override bool CanReceiveItemIntoCargo(EntityAI item)
10826 {
10827 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
10828 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
10829 // return false;
10830
10831 return super.CanReceiveItemIntoCargo(item);
10832 }
10833
10834 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
10835 {
10836 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
10837 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
10838 // return false;
10839
10840 GameInventory attachmentInv = attachment.GetInventory();
10841 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
10842 {
10843 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
10844 return false;
10845 }
10846
10847 InventoryLocation loc = new InventoryLocation();
10848 attachment.GetInventory().GetCurrentInventoryLocation(loc);
10849 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
10850 return false;
10851
10852 return super.CanReceiveAttachment(attachment, slotId);
10853 }
10854
10855 override bool CanReleaseAttachment(EntityAI attachment)
10856 {
10857 if (!super.CanReleaseAttachment(attachment))
10858 return false;
10859
10860 return GetInventory().AreChildrenAccessible();
10861 }
10862
10863 /*override bool CanLoadAttachment(EntityAI attachment)
10864 {
10865 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
10866 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
10867 // return false;
10868
10869 GameInventory attachmentInv = attachment.GetInventory();
10870 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
10871 {
10872 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
10873 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
10874
10875 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
10876 return false;
10877 }
10878
10879 return super.CanLoadAttachment(attachment);
10880 }*/
10881
10882 // Plays muzzle flash particle effects
10883 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10884 {
10885 int id = muzzle_owner.GetMuzzleID();
10886 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
10887
10888 if (WPOF_array)
10889 {
10890 for (int i = 0; i < WPOF_array.Count(); i++)
10891 {
10892 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
10893
10894 if (WPOF)
10895 {
10896 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
10897 }
10898 }
10899 }
10900 }
10901
10902 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
10903 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10904 {
10905 int id = muzzle_owner.GetMuzzleID();
10906 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
10907
10908 if (WPOBE_array)
10909 {
10910 for (int i = 0; i < WPOBE_array.Count(); i++)
10911 {
10912 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
10913
10914 if (WPOBE)
10915 {
10916 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
10917 }
10918 }
10919 }
10920 }
10921
10922 // Plays all weapon overheating particles
10923 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10924 {
10925 int id = muzzle_owner.GetMuzzleID();
10926 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10927
10928 if (WPOOH_array)
10929 {
10930 for (int i = 0; i < WPOOH_array.Count(); i++)
10931 {
10932 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10933
10934 if (WPOOH)
10935 {
10936 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
10937 }
10938 }
10939 }
10940 }
10941
10942 // Updates all weapon overheating particles
10943 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10944 {
10945 int id = muzzle_owner.GetMuzzleID();
10946 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10947
10948 if (WPOOH_array)
10949 {
10950 for (int i = 0; i < WPOOH_array.Count(); i++)
10951 {
10952 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10953
10954 if (WPOOH)
10955 {
10956 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10957 }
10958 }
10959 }
10960 }
10961
10962 // Stops overheating particles
10963 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10964 {
10965 int id = muzzle_owner.GetMuzzleID();
10966 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10967
10968 if (WPOOH_array)
10969 {
10970 for (int i = 0; i < WPOOH_array.Count(); i++)
10971 {
10972 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10973
10974 if (WPOOH)
10975 {
10976 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10977 }
10978 }
10979 }
10980 }
10981
10982 //----------------------------------------------------------------
10983 //Item Behaviour - unified approach
10984 override bool IsHeavyBehaviour()
10985 {
10986 if (m_ItemBehaviour == 0)
10987 {
10988 return true;
10989 }
10990
10991 return false;
10992 }
10993
10994 override bool IsOneHandedBehaviour()
10995 {
10996 if (m_ItemBehaviour == 1)
10997 {
10998 return true;
10999 }
11000
11001 return false;
11002 }
11003
11004 override bool IsTwoHandedBehaviour()
11005 {
11006 if (m_ItemBehaviour == 2)
11007 {
11008 return true;
11009 }
11010
11011 return false;
11012 }
11013
11014 bool IsDeployable()
11015 {
11016 return false;
11017 }
11018
11020 float GetDeployTime()
11021 {
11022 return UATimeSpent.DEFAULT_DEPLOY;
11023 }
11024
11025
11026 //----------------------------------------------------------------
11027 // Item Targeting (User Actions)
11028 override void SetTakeable(bool pState)
11029 {
11030 m_IsTakeable = pState;
11031 SetSynchDirty();
11032 }
11033
11034 override bool IsTakeable()
11035 {
11036 return m_IsTakeable;
11037 }
11038
11039 // For cases where we want to show object widget which cant be taken to hands
11041 {
11042 return false;
11043 }
11044
11046 protected void PreLoadSoundAttachmentType()
11047 {
11048 string att_type = "None";
11049
11050 if (ConfigIsExisting("soundAttType"))
11051 {
11052 att_type = ConfigGetString("soundAttType");
11053 }
11054
11055 m_SoundAttType = att_type;
11056 }
11057
11058 override string GetAttachmentSoundType()
11059 {
11060 return m_SoundAttType;
11061 }
11062
11063 //----------------------------------------------------------------
11064 //SOUNDS - ItemSoundHandler
11065 //----------------------------------------------------------------
11066
11067 string GetPlaceSoundset(); // played when deploy starts
11068 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
11069 string GetDeploySoundset(); // played when deploy sucessfully finishes
11070 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
11071 string GetFoldSoundset(); // played when fold sucessfully finishes
11072
11074 {
11075 if (!m_ItemSoundHandler)
11077
11078 return m_ItemSoundHandler;
11079 }
11080
11081 // override to initialize sounds
11082 protected void InitItemSounds()
11083 {
11084 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
11085 return;
11086
11088
11089 if (GetPlaceSoundset() != string.Empty)
11090 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
11091
11092 if (GetDeploySoundset() != string.Empty)
11093 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
11094
11095 SoundParameters params = new SoundParameters();
11096 params.m_Loop = true;
11097 if (GetLoopDeploySoundset() != string.Empty)
11098 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
11099 }
11100
11101 // Start sound using ItemSoundHandler
11102 void StartItemSoundServer(int id)
11103 {
11104 if (!GetGame().IsServer())
11105 return;
11106
11107 m_SoundSyncPlay = id;
11108 SetSynchDirty();
11109
11110 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
11112 }
11113
11114 // Stop sound using ItemSoundHandler
11115 void StopItemSoundServer(int id)
11116 {
11117 if (!GetGame().IsServer())
11118 return;
11119
11120 m_SoundSyncStop = id;
11121 SetSynchDirty();
11122
11123 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
11125 }
11126
11127 protected void ClearStartItemSoundServer()
11128 {
11129 m_SoundSyncPlay = 0;
11130 }
11131
11132 protected void ClearStopItemSoundServer()
11133 {
11134 m_SoundSyncStop = 0;
11135 }
11136
11138 void PlayAttachSound(string slot_type)
11139 {
11140 if (!GetGame().IsDedicatedServer())
11141 {
11142 if (ConfigIsExisting("attachSoundSet"))
11143 {
11144 string cfg_path = "";
11145 string soundset = "";
11146 string type_name = GetType();
11147
11148 TStringArray cfg_soundset_array = new TStringArray;
11149 TStringArray cfg_slot_array = new TStringArray;
11150 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
11151 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
11152
11153 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
11154 {
11155 for (int i = 0; i < cfg_soundset_array.Count(); i++)
11156 {
11157 if (cfg_slot_array[i] == slot_type)
11158 {
11159 soundset = cfg_soundset_array[i];
11160 break;
11161 }
11162 }
11163 }
11164
11165 if (soundset != "")
11166 {
11167 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
11168 sound.SetAutodestroy(true);
11169 }
11170 }
11171 }
11172 }
11173
11174 void PlayDetachSound(string slot_type)
11175 {
11176 //TODO - evaluate if needed and devise universal config structure if so
11177 }
11178
11179 void OnApply(PlayerBase player);
11180
11182 {
11183 return 1.0;
11184 };
11185 //returns applicable selection
11186 array<string> GetHeadHidingSelection()
11187 {
11189 }
11190
11192 {
11194 }
11195
11196 WrittenNoteData GetWrittenNoteData() {};
11197
11199 {
11200 SetDynamicPhysicsLifeTime(0.01);
11201 m_ItemBeingDroppedPhys = false;
11202 }
11203
11205 {
11206 array<string> zone_names = new array<string>;
11207 GetDamageZones(zone_names);
11208 for (int i = 0; i < zone_names.Count(); i++)
11209 {
11210 SetHealthMax(zone_names.Get(i),"Health");
11211 }
11212 SetHealthMax("","Health");
11213 }
11214
11216 void SetZoneDamageCEInit()
11217 {
11218 float global_health = GetHealth01("","Health");
11219 array<string> zones = new array<string>;
11220 GetDamageZones(zones);
11221 //set damage of all zones to match global health level
11222 for (int i = 0; i < zones.Count(); i++)
11223 {
11224 SetHealth01(zones.Get(i),"Health",global_health);
11225 }
11226 }
11227
11229 bool IsCoverFaceForShave(string slot_name)
11230 {
11231 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
11232 }
11233
11234 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
11235 {
11236 if (!hasRootAsPlayer)
11237 {
11238 if (refParentIB)
11239 {
11240 // parent is wet
11241 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
11242 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
11243 // parent has liquid inside
11244 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
11245 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
11246 // drying
11247 else if (m_VarWet > m_VarWetMin)
11248 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
11249 }
11250 else
11251 {
11252 // drying on ground or inside non-itembase (car, ...)
11253 if (m_VarWet > m_VarWetMin)
11254 AddWet(-1 * delta * GetDryingIncrement("ground"));
11255 }
11256 }
11257 }
11258
11259 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
11260 {
11262 {
11263 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
11264 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
11265 {
11266 float heatPermCoef = 1.0;
11267 EntityAI ent = this;
11268 while (ent)
11269 {
11270 heatPermCoef *= ent.GetHeatPermeabilityCoef();
11271 ent = ent.GetHierarchyParent();
11272 }
11273
11274 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
11275 }
11276 }
11277 }
11278
11279 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
11280 {
11281 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
11282 EntityAI parent = GetHierarchyParent();
11283 if (!parent)
11284 {
11285 hasParent = false;
11286 hasRootAsPlayer = false;
11287 }
11288 else
11289 {
11290 hasParent = true;
11291 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
11292 refParentIB = ItemBase.Cast(parent);
11293 }
11294 }
11295
11296 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
11297 {
11298 // this is stub, implemented on Edible_Base
11299 }
11300
11301 bool CanDecay()
11302 {
11303 // return true used on selected food clases so they can decay
11304 return false;
11305 }
11306
11307 protected bool CanProcessDecay()
11308 {
11309 // this is stub, implemented on Edible_Base class
11310 // used to determine whether it is still necessary for the food to decay
11311 return false;
11312 }
11313
11314 protected bool CanHaveWetness()
11315 {
11316 // return true used on selected items that have a wetness effect
11317 return false;
11318 }
11319
11321 bool CanBeConsumed(ConsumeConditionData data = null)
11322 {
11323 return !GetIsFrozen() && IsOpen();
11324 }
11325
11326 override void ProcessVariables()
11327 {
11328 bool hasParent = false, hasRootAsPlayer = false;
11329 ItemBase refParentIB;
11330
11331 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
11332 bool foodDecay = g_Game.IsFoodDecayEnabled();
11333
11334 if (wwtu || foodDecay)
11335 {
11336 bool processWetness = wwtu && CanHaveWetness();
11337 bool processTemperature = wwtu && CanHaveTemperature();
11338 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
11339
11340 if (processWetness || processTemperature || processDecay)
11341 {
11342 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
11343
11344 if (processWetness)
11345 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
11346
11347 if (processTemperature)
11348 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
11349
11350 if (processDecay)
11351 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
11352 }
11353 }
11354 }
11355
11358 {
11359 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
11360 }
11361
11362 override float GetTemperatureFreezeThreshold()
11363 {
11365 return Liquid.GetFreezeThreshold(GetLiquidType());
11366
11367 return super.GetTemperatureFreezeThreshold();
11368 }
11369
11370 override float GetTemperatureThawThreshold()
11371 {
11373 return Liquid.GetThawThreshold(GetLiquidType());
11374
11375 return super.GetTemperatureThawThreshold();
11376 }
11377
11378 override float GetItemOverheatThreshold()
11379 {
11381 return Liquid.GetBoilThreshold(GetLiquidType());
11382
11383 return super.GetItemOverheatThreshold();
11384 }
11385
11386 override float GetTemperatureFreezeTime()
11387 {
11388 if (HasQuantity())
11389 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
11390
11391 return super.GetTemperatureFreezeTime();
11392 }
11393
11394 override float GetTemperatureThawTime()
11395 {
11396 if (HasQuantity())
11397 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
11398
11399 return super.GetTemperatureThawTime();
11400 }
11401
11403 void AffectLiquidContainerOnFill(int liquid_type, float amount);
11405 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
11406
11407 bool IsCargoException4x3(EntityAI item)
11408 {
11409 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
11410 }
11411
11413 {
11414 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
11415 }
11416
11418 void AddLightSourceItem(ItemBase lightsource)
11419 {
11420 m_LightSourceItem = lightsource;
11421 }
11422
11424 {
11425 m_LightSourceItem = null;
11426 }
11427
11429 {
11430 return m_LightSourceItem;
11431 }
11432
11434 array<int> GetValidFinishers()
11435 {
11436 return null;
11437 }
11438
11440 bool GetActionWidgetOverride(out typename name)
11441 {
11442 return false;
11443 }
11444
11445 bool PairWithDevice(notnull ItemBase otherDevice)
11446 {
11447 if (GetGame().IsServer())
11448 {
11449 ItemBase explosive = otherDevice;
11451 if (!trg)
11452 {
11453 trg = RemoteDetonatorTrigger.Cast(otherDevice);
11454 explosive = this;
11455 }
11456
11457 explosive.PairRemote(trg);
11458 trg.SetControlledDevice(explosive);
11459
11460 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
11461 trg.SetPersistentPairID(persistentID);
11462 explosive.SetPersistentPairID(persistentID);
11463
11464 return true;
11465 }
11466 return false;
11467 }
11468
11470 float GetBaitEffectivity()
11471 {
11472 float ret = 1.0;
11473 if (HasQuantity())
11474 ret *= GetQuantityNormalized();
11475 ret *= GetHealth01();
11476
11477 return ret;
11478 }
11479
11480 #ifdef DEVELOPER
11481 override void SetDebugItem()
11482 {
11483 super.SetDebugItem();
11484 _itemBase = this;
11485 }
11486
11487 override string GetDebugText()
11488 {
11489 string text = super.GetDebugText();
11490
11491 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
11492 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
11493
11494 return text;
11495 }
11496 #endif
11497
11498 bool CanBeUsedForSuicide()
11499 {
11500 return true;
11501 }
11502
11504 //DEPRECATED BELOW
11506 // Backwards compatibility
11507 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
11508 {
11509 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
11510 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
11511 }
11512
11513 // replaced by ItemSoundHandler
11514 protected EffectSound m_SoundDeployFinish;
11515 protected EffectSound m_SoundPlace;
11516 protected EffectSound m_DeployLoopSoundEx;
11517 protected EffectSound m_SoundDeploy;
11518 bool m_IsPlaceSound;
11519 bool m_IsDeploySound;
11521
11522 string GetDeployFinishSoundset();
11523 void PlayDeploySound();
11524 void PlayDeployFinishSound();
11525 void PlayPlaceSound();
11526 void PlayDeployLoopSoundEx();
11527 void StopDeployLoopSoundEx();
11528 void SoundSynchRemoteReset();
11529 void SoundSynchRemote();
11530 bool UsesGlobalDeploy(){return false;}
11531 bool CanPlayDeployLoopSound(){return false;}
11533 bool IsPlaceSound(){return m_IsPlaceSound;}
11534 bool IsDeploySound(){return m_IsDeploySound;}
11535 void SetIsPlaceSound(bool is_place_sound);
11536 void SetIsDeploySound(bool is_deploy_sound);
11537}
11538
11539EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
11540{
11541 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
11542 if (entity)
11543 {
11544 bool is_item = entity.IsInherited(ItemBase);
11545 if (is_item && full_quantity)
11546 {
11547 ItemBase item = ItemBase.Cast(entity);
11548 item.SetQuantity(item.GetQuantityInit());
11549 }
11550 }
11551 else
11552 {
11553 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
11554 return NULL;
11555 }
11556 return entity;
11557}
11558
11559void SetupSpawnedItem(ItemBase item, float health, float quantity)
11560{
11561 if (item)
11562 {
11563 if (health > 0)
11564 item.SetHealth("", "", health);
11565
11566 if (item.CanHaveTemperature())
11567 {
11568 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
11569 if (item.CanFreeze())
11570 item.SetFrozen(false);
11571 }
11572
11573 if (item.HasEnergyManager())
11574 {
11575 if (quantity >= 0)
11576 {
11577 item.GetCompEM().SetEnergy0To1(quantity);
11578 }
11579 else
11580 {
11581 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
11582 }
11583 }
11584 else if (item.IsMagazine())
11585 {
11586 Magazine mag = Magazine.Cast(item);
11587 if (quantity >= 0)
11588 {
11589 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
11590 }
11591 else
11592 {
11593 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
11594 }
11595
11596 }
11597 else
11598 {
11599 if (quantity >= 0)
11600 {
11601 item.SetQuantityNormalized(quantity, false);
11602 }
11603 else
11604 {
11605 item.SetQuantity(Math.AbsFloat(quantity));
11606 }
11607
11608 }
11609 }
11610}
11611
11612#ifdef DEVELOPER
11613ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
11614#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::SplitIntoStackMaxToInventoryLocation().