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

◆ ReadVarsFromCTX()

override bool SpawnItemOnLocation::ReadVarsFromCTX ( ParamsReadContext ctx,
int version = -1 )
protected

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

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

Используется в Entity::LoadVariables() и InventoryItem::OnSyncVariables().