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

◆ SplitIntoStackMaxCargo()

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

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

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