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

◆ IDToName()

string SpawnItemOnLocation::IDToName ( int id)
protected

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

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