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

◆ SetQuantityNormalized()

override void SpawnItemOnLocation::SetQuantityNormalized ( float value,
bool destroy_config = true,
bool destroy_forced = false )
protected

Sets 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, setting 0.5 will result in value 2500)

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

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

Используется в FlammableBase::CalculateQuantity(), InventoryItem::ConvertEnergyToQuantity() и InventoryItem::SetCEBasedQuantity().