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

◆ IsIgnoredByConstruction()

override bool SpawnItemOnLocation::IsIgnoredByConstruction ( )
protected

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

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