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

◆ SplitItem()

void SpawnItemOnLocation::SplitItem ( PlayerBase player)
protected

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

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

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