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

◆ NameToID()

int SpawnItemOnLocation::NameToID ( string name)
protected

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

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