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

◆ IDToName()

string SpawnItemOnLocation::IDToName ( int id)
protected

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

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