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

◆ SplitIntoStackMaxToInventoryLocationClient()

void SpawnItemOnLocation::SplitIntoStackMaxToInventoryLocationClient ( notnull InventoryLocation dst)
protected

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

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