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

◆ ComputeQuantityUsedEx()

float SpawnItemOnLocation::ComputeQuantityUsedEx ( ItemBase other_item,
bool use_stack_max = true )
protected

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

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

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