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

◆ SplitIntoStackMaxToInventoryLocation()

void SpawnItemOnLocation::SplitIntoStackMaxToInventoryLocation ( notnull InventoryLocation dst)
protected

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

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