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

◆ CombineItems()

void SpawnItemOnLocation::CombineItems ( ItemBase other_item,
bool use_stack_max = true )
protected

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

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