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

◆ OnSyncVariables()

void SpawnItemOnLocation::OnSyncVariables ( ParamsReadContext ctx)
protected

DEPRECATED (most likely)

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

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