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

◆ GetQuantity()

override float SpawnItemOnLocation::GetQuantity ( )
protected

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

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

Используется в InventoryItem::AddQuantity(), InventoryItem::CanBeCombined(), InventoryItem::CanBeSplit(), ItemBase::CanIgniteItem(), Clothing::CanPutAsAttachment(), ItemBase::CanPutAsAttachment(), InventoryItem::CombineItems(), InventoryItem::ComputeQuantityUsedEx(), Mask_Base::ConsumeQuantity(), Barrel_ColorBase::DetermineAction(), Mask_Base::GetFilterQuantity(), Mask_Base::GetFilterQuantity01(), InventoryItem::GetProtectionLevel(), FlammableBase::GetRagQuantity(), InventoryItem::GetWeightSpecialized(), Mask_Base::HasValidFilter(), InventoryItem::InitItemVariables(), LargeGasCanister::IsDestructionBehaviour(), MediumGasCanister::IsDestructionBehaviour(), SmallGasCanister::IsDestructionBehaviour(), InventoryItem::IsFullQuantity(), ItemBase::RemovePlanks(), InventoryItem::ShouldSplitQuantity(), InventoryItem::SplitIntoStackMax(), InventoryItem::SplitIntoStackMaxCargo(), InventoryItem::SplitIntoStackMaxEx(), InventoryItem::SplitIntoStackMaxHands(), InventoryItem::SplitIntoStackMaxToInventoryLocationEx(), InventoryItem::SplitItem(), InventoryItem::SplitItemToInventoryLocation(), FlammableBase::UpdateLight(), BroomBase::UpdateParticle(), FlammableBase::UpdateParticle(), ItemBase::UpdateSelections() и InventoryItem::WriteVarsToCTX().