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

◆ IsResultOfSplit()

bool SpawnItemOnLocation::IsResultOfSplit ( )
protected

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

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