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

◆ EEHealthLevelChanged()

override void SpawnItemOnLocation::EEHealthLevelChanged ( int oldLevel,
int newLevel,
string zone )
protected

drops content of container when ruined in fireplace

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

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