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

◆ DeSerializeNumericalVars()

override void SpawnItemOnLocation::DeSerializeNumericalVars ( array< float > floats)
protected

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

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

Используется в Entity::TransferVariablesFloat().