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

◆ CanBeCombined()

override bool SpawnItemOnLocation::CanBeCombined ( EntityAI other_item,
bool reservation_check = true,
bool stack_max_limit = false )
protected

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

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