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

◆ GetQuantityNormalized()

override float SpawnItemOnLocation::GetQuantityNormalized ( )
private

Gets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config(for Min 0 and Max 5000, value 2500 will result in 0.5)

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

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

Используется в InventoryItem::GetBaitEffectivity(), InventoryItem::GetQuantityNormalizedScripted() и InventoryItem::OnQuantityChanged().