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

◆ DeSerializeNumericalVars()

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

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

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

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