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

◆ GetEnergy()

float SpawnItemOnLocation::GetEnergy ( )
protected

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

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

Используется в ItemBase::CanAddFuel(), FlammableBase::CanBeIgnitedBy(), BroomBase::CanTransformIntoStick(), ItemBase::GetFuel(), InventoryItem::GetWeightSpecialized(), FlammableBase::OnWork(), Chemlight_ColorBase::OnWorkStop(), FlammableBase::OnWorkStop() и Roadflare::OnWorkStop().