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

◆ SplitIntoStackMaxCargo()

void SpawnItemOnLocation::SplitIntoStackMaxCargo ( EntityAI destination_entity,
int idx,
int row,
int col )
protected

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

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