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

◆ SplitIntoStackMaxToInventoryLocation()

void SpawnItemOnLocation::SplitIntoStackMaxToInventoryLocation ( notnull InventoryLocation dst)
protected

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

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