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

◆ ComputeQuantityUsedEx()

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

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

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

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