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

◆ ComputeQuantityUsed()

int SpawnItemOnLocation::ComputeQuantityUsed ( ItemBase other_item,
bool use_stack_max = true )
protected

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

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