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

◆ SetCanBeMovedOverride()

void SpawnItemOnLocation::SetCanBeMovedOverride ( bool setting)
protected

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

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