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

◆ SplitIntoStackMaxToInventoryLocationEx()

ItemBase SpawnItemOnLocation::SplitIntoStackMaxToInventoryLocationEx ( notnull InventoryLocation dst)
protected

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

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

Используется в InventoryItem::SplitIntoStackMaxToInventoryLocation().