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

◆ GetFilterDamageRatio()

override float GetFilterDamageRatio ( )
private

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

5538{
5539 override bool CanPutAsAttachment(EntityAI parent)
5540 {
5541 return true;
5542 }
5543};
5544
5545//const bool QUANTITY_DEBUG_REMOVE_ME = false;
5546
5547class ItemBase extends InventoryItem
5548{
5552
5554
5555 static int m_DebugActionsMask;
5557 // ============================================
5558 // Variable Manipulation System
5559 // ============================================
5560 // Quantity
5561
5562 float m_VarQuantity;
5563 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
5565 int m_VarQuantityMin;
5566 int m_VarQuantityMax;
5567 int m_Count;
5568 float m_VarStackMax;
5569 float m_StoreLoadedQuantity = float.LOWEST;
5570 // Wet
5571 float m_VarWet;
5572 float m_VarWetPrev;//for client to know wetness changed during synchronization
5573 float m_VarWetInit;
5574 float m_VarWetMin;
5575 float m_VarWetMax;
5576 // Cleanness
5577 int m_Cleanness;
5578 int m_CleannessInit;
5579 int m_CleannessMin;
5580 int m_CleannessMax;
5581 // impact sounds
5583 bool m_CanPlayImpactSound = true;
5584 float m_ImpactSpeed;
5586 //
5587 float m_HeatIsolation;
5588 float m_ItemModelLength;
5589 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
5591 int m_VarLiquidType;
5592 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
5593 int m_QuickBarBonus;
5594 bool m_IsBeingPlaced;
5595 bool m_IsHologram;
5596 bool m_IsTakeable;
5597 bool m_ThrowItemOnDrop;
5600 bool m_FixDamageSystemInit = false; //can be changed on storage version check
5601 bool can_this_be_combined; //Check if item can be combined
5602 bool m_CanThisBeSplit; //Check if item can be split
5603 bool m_IsStoreLoad = false;
5604 bool m_CanShowQuantity;
5605 bool m_HasQuantityBar;
5606 protected bool m_CanBeDigged;
5607 protected bool m_IsResultOfSplit
5608
5609 string m_SoundAttType;
5610 // items color variables
5615 //-------------------------------------------------------
5616
5617 // light source managing
5619
5623
5624 //==============================================
5625 // agent system
5626 private int m_AttachedAgents;
5627
5629 void TransferModifiers(PlayerBase reciever);
5630
5631
5632 // Weapons & suppressors particle effects
5637 static int m_LastRegisteredWeaponID = 0;
5638
5639 // Overheating effects
5641 float m_OverheatingShots;
5642 ref Timer m_CheckOverheating;
5643 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
5644 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
5645 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
5646 ref array <ref OverheatingParticle> m_OverheatingParticles;
5647
5649 protected bool m_HideSelectionsBySlot;
5650
5651 // Admin Log
5652 PluginAdminLog m_AdminLog;
5653
5654 // misc
5655 ref Timer m_PhysDropTimer;
5656
5657 // Attachment Locking variables
5658 ref array<int> m_CompatibleLocks;
5659 protected int m_LockType;
5660 protected ref EffectSound m_LockingSound;
5661 protected string m_LockSoundSet;
5662
5663 // ItemSoundHandler
5664 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
5665 protected int m_SoundSyncPlay; // id for sound to play
5666 protected int m_SoundSyncStop; // id for sound to stop
5668
5669 //temperature
5670 private float m_TemperaturePerQuantityWeight;
5671
5672 // -------------------------------------------------------------------------
5673 void ItemBase()
5674 {
5675 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
5679
5680 if (!GetGame().IsDedicatedServer())
5681 {
5682 if (HasMuzzle())
5683 {
5685
5687 {
5689 }
5690 }
5691
5693 m_ActionsInitialize = false;
5694 }
5695
5696 m_OldLocation = null;
5697
5698 if (GetGame().IsServer())
5699 {
5700 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
5701 }
5702
5703 if (ConfigIsExisting("headSelectionsToHide"))
5704 {
5706 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
5707 }
5708
5709 m_HideSelectionsBySlot = false;
5710 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
5711 {
5712 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
5713 }
5714
5715 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
5716
5717 m_IsResultOfSplit = false;
5718
5720 }
5721
5722 override void InitItemVariables()
5723 {
5724 super.InitItemVariables();
5725
5726 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
5727 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
5728 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
5729 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
5730 m_VarStackMax = ConfigGetFloat("varStackMax");
5731 m_Count = ConfigGetInt("count");
5732
5733 m_CanShowQuantity = ConfigGetBool("quantityShow");
5734 m_HasQuantityBar = ConfigGetBool("quantityBar");
5735
5736 m_CleannessInit = ConfigGetInt("varCleannessInit");
5738 m_CleannessMin = ConfigGetInt("varCleannessMin");
5739 m_CleannessMax = ConfigGetInt("varCleannessMax");
5740
5741 m_WantPlayImpactSound = false;
5742 m_ImpactSpeed = 0.0;
5743
5744 m_VarWetInit = ConfigGetFloat("varWetInit");
5746 m_VarWetMin = ConfigGetFloat("varWetMin");
5747 m_VarWetMax = ConfigGetFloat("varWetMax");
5748
5749 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
5750 if (IsLiquidContainer() && GetQuantity() != 0)
5752 m_IsBeingPlaced = false;
5753 m_IsHologram = false;
5754 m_IsTakeable = true;
5755 m_CanBeMovedOverride = false;
5759 m_CanBeDigged = ConfigGetBool("canBeDigged");
5760
5761 m_CompatibleLocks = new array<int>();
5762 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
5763 m_LockType = ConfigGetInt("lockType");
5764
5765 //Define if item can be split and set ability to be combined accordingly
5766 m_CanThisBeSplit = false;
5767 can_this_be_combined = false;
5768 if (ConfigIsExisting("canBeSplit"))
5769 {
5770 can_this_be_combined = ConfigGetBool("canBeSplit");
5772 }
5773
5774 m_ItemBehaviour = -1;
5775 if (ConfigIsExisting("itemBehaviour"))
5776 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
5777
5778 //RegisterNetSyncVariableInt("m_VariablesMask");
5779 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
5780 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
5781 RegisterNetSyncVariableInt("m_VarLiquidType");
5782 RegisterNetSyncVariableInt("m_Cleanness",0,1);
5783
5784 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
5785 RegisterNetSyncVariableFloat("m_ImpactSpeed");
5786 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
5787
5788 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
5789 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
5790 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
5791 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
5792
5793 RegisterNetSyncVariableBool("m_IsBeingPlaced");
5794 RegisterNetSyncVariableBool("m_IsTakeable");
5795 RegisterNetSyncVariableBool("m_IsHologram");
5796
5797 InitItemSounds();
5799 {
5800 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
5801 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
5802 }
5803
5804 m_LockSoundSet = ConfigGetString("lockSoundSet");
5805
5807 if (ConfigIsExisting("temperaturePerQuantityWeight"))
5808 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
5809
5810 }
5811
5812 override int GetQuickBarBonus()
5813 {
5814 return m_QuickBarBonus;
5815 }
5816
5817 void InitializeActions()
5818 {
5820 if (!m_InputActionMap)
5821 {
5823 m_InputActionMap = iam;
5824 SetActions();
5826 }
5827 }
5828
5829 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
5830 {
5832 {
5833 m_ActionsInitialize = true;
5835 }
5836
5837 actions = m_InputActionMap.Get(action_input_type);
5838 }
5839
5840 void SetActions()
5841 {
5842 AddAction(ActionTakeItem);
5843 AddAction(ActionTakeItemToHands);
5844 AddAction(ActionWorldCraft);
5846 AddAction(ActionAttachWithSwitch);
5847 }
5848
5849 void SetActionAnimOverrides(); // Override action animation for specific item
5850
5851 void AddAction(typename actionName)
5852 {
5853 ActionBase action = ActionManagerBase.GetAction(actionName);
5854
5855 if (!action)
5856 {
5857 Debug.LogError("Action " + actionName + " dosn't exist!");
5858 return;
5859 }
5860
5861 typename ai = action.GetInputType();
5862 if (!ai)
5863 {
5864 m_ActionsInitialize = false;
5865 return;
5866 }
5867
5868 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
5869 if (!action_array)
5870 {
5871 action_array = new array<ActionBase_Basic>;
5872 m_InputActionMap.Insert(ai, action_array);
5873 }
5874 if (LogManager.IsActionLogEnable())
5875 {
5876 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
5877 }
5878
5879 if (action_array.Find(action) != -1)
5880 {
5881 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
5882 }
5883 else
5884 {
5885 action_array.Insert(action);
5886 }
5887 }
5888
5889 void RemoveAction(typename actionName)
5890 {
5891 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
5892 ActionBase action = player.GetActionManager().GetAction(actionName);
5893 typename ai = action.GetInputType();
5894 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
5895
5896 if (action_array)
5897 {
5898 action_array.RemoveItem(action);
5899 }
5900 }
5901
5902 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
5903 // Set -1 for params which should stay in default state
5904 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
5905 {
5906 ActionOverrideData overrideData = new ActionOverrideData();
5907 overrideData.m_CommandUID = commandUID;
5908 overrideData.m_CommandUIDProne = commandUIDProne;
5909 overrideData.m_StanceMask = stanceMask;
5910
5911 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
5912 if (!actionMap) // create new map of action > overidables map
5913 {
5914 actionMap = new TActionAnimOverrideMap();
5915 m_ItemActionOverrides.Insert(action, actionMap);
5916 }
5917
5918 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
5919
5920 }
5921
5922 void OnItemInHandsPlayerSwimStart(PlayerBase player);
5923
5924 ScriptedLightBase GetLight();
5925
5926 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
5927 void LoadParticleConfigOnFire(int id)
5928 {
5929 if (!m_OnFireEffect)
5931
5934
5935 string config_to_search = "CfgVehicles";
5936 string muzzle_owner_config;
5937
5938 if (!m_OnFireEffect.Contains(id))
5939 {
5940 if (IsInherited(Weapon))
5941 config_to_search = "CfgWeapons";
5942
5943 muzzle_owner_config = config_to_search + " " + GetType() + " ";
5944
5945 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
5946
5947 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
5948
5949 if (config_OnFire_subclass_count > 0)
5950 {
5951 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
5952
5953 for (int i = 0; i < config_OnFire_subclass_count; i++)
5954 {
5955 string particle_class = "";
5956 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
5957 string config_OnFire_entry = config_OnFire_class + particle_class;
5958 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
5959 WPOF_array.Insert(WPOF);
5960 }
5961
5962
5963 m_OnFireEffect.Insert(id, WPOF_array);
5964 }
5965 }
5966
5967 if (!m_OnBulletCasingEjectEffect.Contains(id))
5968 {
5969 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
5970 muzzle_owner_config = config_to_search + " " + GetType() + " ";
5971
5972 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
5973
5974 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
5975
5976 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
5977 {
5978 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
5979
5980 for (i = 0; i < config_OnBulletCasingEject_count; i++)
5981 {
5982 string particle_class2 = "";
5983 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
5984 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
5985 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
5986 WPOBE_array.Insert(WPOBE);
5987 }
5988
5989
5990 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
5991 }
5992 }
5993 }
5994
5995 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
5997 {
6000
6001 if (!m_OnOverheatingEffect.Contains(id))
6002 {
6003 string config_to_search = "CfgVehicles";
6004
6005 if (IsInherited(Weapon))
6006 config_to_search = "CfgWeapons";
6007
6008 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
6009 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
6010
6011 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
6012 {
6013
6014 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
6015
6017 {
6018 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
6019 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
6020 Error(error);
6021 return;
6022 }
6023
6024 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
6025 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
6026
6027
6028
6029 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
6030 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
6031
6032 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
6033 {
6034 string particle_class = "";
6035 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
6036 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
6037 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
6038
6039 if (entry_type == CT_CLASS)
6040 {
6041 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
6042 WPOOH_array.Insert(WPOF);
6043 }
6044 }
6045
6046
6047 m_OnOverheatingEffect.Insert(id, WPOOH_array);
6048 }
6049 }
6050 }
6051
6052 float GetOverheatingValue()
6053 {
6054 return m_OverheatingShots;
6055 }
6056
6057 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
6058 {
6059 if (m_MaxOverheatingValue > 0)
6060 {
6062
6063 if (!m_CheckOverheating)
6065
6067 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
6068
6069 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6070 }
6071 }
6072
6073 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6074 {
6076 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6077
6079 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6080
6082 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6083
6085 {
6087 }
6088 }
6089
6091 {
6093 }
6094
6095 void OnOverheatingDecay()
6096 {
6097 if (m_MaxOverheatingValue > 0)
6098 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
6099 else
6101
6102 if (m_OverheatingShots <= 0)
6103 {
6106 }
6107 else
6108 {
6109 if (!m_CheckOverheating)
6111
6113 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
6114 }
6115
6116 CheckOverheating(this, "", this);
6117 }
6118
6119 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6120 {
6122 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
6123 }
6124
6125 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6126 {
6128 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
6130 }
6131
6132 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6133 {
6135 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6136 }
6137
6138 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
6139 {
6141 m_OverheatingParticles = new array<ref OverheatingParticle>;
6142
6143 OverheatingParticle OP = new OverheatingParticle();
6144 OP.RegisterParticle(p);
6145 OP.SetOverheatingLimitMin(min_heat_coef);
6146 OP.SetOverheatingLimitMax(max_heat_coef);
6147 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
6148
6149 m_OverheatingParticles.Insert(OP);
6150 }
6151
6152 float GetOverheatingCoef()
6153 {
6154 if (m_MaxOverheatingValue > 0)
6156
6157 return -1;
6158 }
6159
6161 {
6163 {
6164 float overheat_coef = GetOverheatingCoef();
6165 int count = m_OverheatingParticles.Count();
6166
6167 for (int i = count; i > 0; --i)
6168 {
6169 int id = i - 1;
6170 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6171 Particle p = OP.GetParticle();
6172
6173 float overheat_min = OP.GetOverheatingLimitMin();
6174 float overheat_max = OP.GetOverheatingLimitMax();
6175
6176 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
6177 {
6178 if (p)
6179 {
6180 p.Stop();
6181 OP.RegisterParticle(null);
6182 }
6183 }
6184 }
6185 }
6186 }
6187
6189 {
6191 {
6192 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
6193 {
6194 int id = i - 1;
6195 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6196
6197 if (OP)
6198 {
6199 Particle p = OP.GetParticle();
6200
6201 if (p)
6202 {
6203 p.Stop();
6204 }
6205
6206 delete OP;
6207 }
6208 }
6209
6210 m_OverheatingParticles.Clear();
6212 }
6213 }
6214
6216 float GetInfectionChance(int system = 0, Param param = null)
6217 {
6218 return 0.0;
6219 }
6220
6221
6222 float GetDisinfectQuantity(int system = 0, Param param1 = null)
6223 {
6224 return 250;//default value
6225 }
6226
6227 float GetFilterDamageRatio()
6228 {
6229 return 0;
6230 }
6231
6233 bool HasMuzzle()
6234 {
6235 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
6236 return true;
6237
6238 return false;
6239 }
6240
6242 int GetMuzzleID()
6243 {
6244 if (!m_WeaponTypeToID)
6246
6247 if (m_WeaponTypeToID.Contains(GetType()))
6248 {
6249 return m_WeaponTypeToID.Get(GetType());
6250 }
6251 else
6252 {
6253 // Register new weapon ID
6255 }
6256
6258 }
6259
6266 {
6267 return -1;
6268 }
6269
6270
6271
6272 // -------------------------------------------------------------------------
6273 void ~ItemBase()
6274 {
6275 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
6276 {
6277 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
6278 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
6279
6280 if (r_index >= 0)
6281 {
6282 InventoryLocation r_il = new InventoryLocation;
6283 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
6284
6285 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
6286 int r_type = r_il.GetType();
6287 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
6288 {
6289 r_il.GetParent().GetOnReleaseLock().Invoke(this);
6290 }
6291 else if (r_type == InventoryLocationType.ATTACHMENT)
6292 {
6293 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
6294 }
6295
6296 }
6297
6298 player.GetHumanInventory().ClearUserReservedLocation(this);
6299 }
6300
6301 if (m_LockingSound)
6302 SEffectManager.DestroyEffect(m_LockingSound);
6303 }
6304
6305
6306
6307 // -------------------------------------------------------------------------
6308 static int GetDebugActionsMask()
6309 {
6310 return ItemBase.m_DebugActionsMask;
6311 }
6312
6313 static bool HasDebugActionsMask(int mask)
6314 {
6315 return ItemBase.m_DebugActionsMask & mask;
6316 }
6317
6318 static void SetDebugActionsMask(int mask)
6319 {
6320 ItemBase.m_DebugActionsMask = mask;
6321 }
6322
6323 static void AddDebugActionsMask(int mask)
6324 {
6325 ItemBase.m_DebugActionsMask |= mask;
6326 }
6327
6328 static void RemoveDebugActionsMask(int mask)
6329 {
6330 ItemBase.m_DebugActionsMask &= ~mask;
6331 }
6332
6333 static void ToggleDebugActionsMask(int mask)
6334 {
6335 if (HasDebugActionsMask(mask))
6336 {
6338 }
6339 else
6340 {
6341 AddDebugActionsMask(mask);
6342 }
6343 }
6344
6345 // -------------------------------------------------------------------------
6346 void SetCEBasedQuantity()
6347 {
6348 if (GetEconomyProfile())
6349 {
6350 float q_max = GetEconomyProfile().GetQuantityMax();
6351 if (q_max > 0)
6352 {
6353 float q_min = GetEconomyProfile().GetQuantityMin();
6354 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
6355
6356 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
6357 {
6358 ComponentEnergyManager comp = GetCompEM();
6359 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
6360 {
6361 comp.SetEnergy0To1(quantity_randomized);
6362 }
6363 }
6364 else if (HasQuantity())
6365 {
6366 SetQuantityNormalized(quantity_randomized, false);
6367 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
6368 }
6369
6370 }
6371 }
6372 }
6373
6375 void LockToParent()
6376 {
6377 EntityAI parent = GetHierarchyParent();
6378
6379 if (parent)
6380 {
6381 InventoryLocation inventory_location_to_lock = new InventoryLocation;
6382 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
6383 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
6384 }
6385 }
6386
6388 void UnlockFromParent()
6389 {
6390 EntityAI parent = GetHierarchyParent();
6391
6392 if (parent)
6393 {
6394 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
6395 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
6396 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
6397 }
6398 }
6399
6400 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
6401 {
6402 /*
6403 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
6404 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
6405 */
6406 ItemBase item2 = ItemBase.Cast(entity2);
6407
6408 if (GetGame().IsClient())
6409 {
6410 if (ScriptInputUserData.CanStoreInputUserData())
6411 {
6412 ScriptInputUserData ctx = new ScriptInputUserData;
6414 ctx.Write(-1);
6415 ItemBase i1 = this; // @NOTE: workaround for correct serialization
6416 ctx.Write(i1);
6417 ctx.Write(item2);
6418 ctx.Write(use_stack_max);
6419 ctx.Write(-1);
6420 ctx.Send();
6421
6422 if (IsCombineAll(item2, use_stack_max))
6423 {
6424 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
6425 }
6426 }
6427 }
6428 else if (!GetGame().IsMultiplayer())
6429 {
6430 CombineItems(item2, use_stack_max);
6431 }
6432 }
6433
6434 bool IsLiquidPresent()
6435 {
6436 return (GetLiquidType() != 0 && HasQuantity());
6437 }
6438
6439 bool IsLiquidContainer()
6440 {
6441 return m_LiquidContainerMask != 0;
6442 }
6443
6445 {
6446 return m_LiquidContainerMask;
6447 }
6448
6449 bool IsBloodContainer()
6450 {
6451 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
6452 return false;
6453 }
6454
6455 bool IsNVG()
6456 {
6457 return false;
6458 }
6459
6462 bool IsExplosive()
6463 {
6464 return false;
6465 }
6466
6468 {
6469 return "";
6470 }
6471
6473
6474 bool IsLightSource()
6475 {
6476 return false;
6477 }
6478
6480 {
6481 return true;
6482 }
6483
6484 //--- ACTION CONDITIONS
6485 //direction
6486 bool IsFacingPlayer(PlayerBase player, string selection)
6487 {
6488 return true;
6489 }
6490
6491 bool IsPlayerInside(PlayerBase player, string selection)
6492 {
6493 return true;
6494 }
6495
6496 override bool CanObstruct()
6497 {
6498 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
6499 return !player || !IsPlayerInside(player, "");
6500 }
6501
6502 override bool IsBeingPlaced()
6503 {
6504 return m_IsBeingPlaced;
6505 }
6506
6507 void SetIsBeingPlaced(bool is_being_placed)
6508 {
6509 m_IsBeingPlaced = is_being_placed;
6510 if (!is_being_placed)
6512 SetSynchDirty();
6513 }
6514
6515 //server-side
6516 void OnEndPlacement() {}
6517
6518 override bool IsHologram()
6519 {
6520 return m_IsHologram;
6521 }
6522
6523 bool CanBeDigged()
6524 {
6525 return m_CanBeDigged;
6526 }
6527
6529 {
6530 return 1;
6531 }
6532
6533 bool CanMakeGardenplot()
6534 {
6535 return false;
6536 }
6537
6538 void SetIsHologram(bool is_hologram)
6539 {
6540 m_IsHologram = is_hologram;
6541 SetSynchDirty();
6542 }
6543 /*
6544 protected float GetNutritionalEnergy()
6545 {
6546 Edible_Base edible = Edible_Base.Cast(this);
6547 return edible.GetFoodEnergy();
6548 }
6549
6550 protected float GetNutritionalWaterContent()
6551 {
6552 Edible_Base edible = Edible_Base.Cast(this);
6553 return edible.GetFoodWater();
6554 }
6555
6556 protected float GetNutritionalIndex()
6557 {
6558 Edible_Base edible = Edible_Base.Cast(this);
6559 return edible.GetFoodNutritionalIndex();
6560 }
6561
6562 protected float GetNutritionalFullnessIndex()
6563 {
6564 Edible_Base edible = Edible_Base.Cast(this);
6565 return edible.GetFoodTotalVolume();
6566 }
6567
6568 protected float GetNutritionalToxicity()
6569 {
6570 Edible_Base edible = Edible_Base.Cast(this);
6571 return edible.GetFoodToxicity();
6572
6573 }
6574 */
6575
6576
6577 // -------------------------------------------------------------------------
6578 override void OnMovedInsideCargo(EntityAI container)
6579 {
6580 super.OnMovedInsideCargo(container);
6581
6582 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
6583 }
6584
6585 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
6586 {
6587 super.EEItemLocationChanged(oldLoc,newLoc);
6588
6589 PlayerBase new_player = null;
6590 PlayerBase old_player = null;
6591
6592 if (newLoc.GetParent())
6593 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
6594
6595 if (oldLoc.GetParent())
6596 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
6597
6598 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
6599 {
6600 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
6601
6602 if (r_index >= 0)
6603 {
6604 InventoryLocation r_il = new InventoryLocation;
6605 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
6606
6607 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
6608 int r_type = r_il.GetType();
6609 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
6610 {
6611 r_il.GetParent().GetOnReleaseLock().Invoke(this);
6612 }
6613 else if (r_type == InventoryLocationType.ATTACHMENT)
6614 {
6615 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
6616 }
6617
6618 }
6619 }
6620
6621 if (newLoc.GetType() == InventoryLocationType.HANDS)
6622 {
6623 if (new_player)
6624 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
6625
6626 if (new_player == old_player)
6627 {
6628
6629 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
6630 {
6631 if (oldLoc.GetType() == InventoryLocationType.CARGO)
6632 {
6633 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
6634 {
6635 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
6636 }
6637 }
6638 else
6639 {
6640 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
6641 }
6642 }
6643
6644 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
6645 {
6646 int type = oldLoc.GetType();
6647 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
6648 {
6649 oldLoc.GetParent().GetOnSetLock().Invoke(this);
6650 }
6651 else if (type == InventoryLocationType.ATTACHMENT)
6652 {
6653 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
6654 }
6655 }
6656 if (!m_OldLocation)
6657 {
6658 m_OldLocation = new InventoryLocation;
6659 }
6660 m_OldLocation.Copy(oldLoc);
6661 }
6662 else
6663 {
6664 if (m_OldLocation)
6665 {
6666 m_OldLocation.Reset();
6667 }
6668 }
6669
6671 }
6672 else
6673 {
6674 if (new_player)
6675 {
6676 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
6677 if (res_index >= 0)
6678 {
6679 InventoryLocation il = new InventoryLocation;
6680 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
6681 ItemBase it = ItemBase.Cast(il.GetItem());
6682 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
6683 int rel_type = il.GetType();
6684 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
6685 {
6686 il.GetParent().GetOnReleaseLock().Invoke(it);
6687 }
6688 else if (rel_type == InventoryLocationType.ATTACHMENT)
6689 {
6690 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
6691 }
6692 //it.GetOnReleaseLock().Invoke(it);
6693 }
6694 }
6695 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
6696 {
6697 //ThrowPhysically(old_player, vector.Zero);
6698 m_ThrowItemOnDrop = false;
6699 }
6700
6701 if (m_OldLocation)
6702 {
6703 m_OldLocation.Reset();
6704 }
6705 }
6706 }
6707
6708 override void EOnContact(IEntity other, Contact extra)
6709 {
6711 {
6712 int liquidType = -1;
6713 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
6714 if (impactSpeed > 0.0)
6715 {
6716 m_ImpactSpeed = impactSpeed;
6717 #ifndef SERVER
6718 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
6719 #else
6720 m_WantPlayImpactSound = true;
6721 SetSynchDirty();
6722 #endif
6723 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
6724 }
6725 }
6726
6727 #ifdef SERVER
6728 if (GetCompEM() && GetCompEM().IsPlugged())
6729 {
6730 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
6731 GetCompEM().UnplugThis();
6732 }
6733 #endif
6734 }
6735
6736 void RefreshPhysics();
6737
6738 override void OnCreatePhysics()
6739 {
6741 }
6742
6743 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
6744 {
6745
6746 }
6747 // -------------------------------------------------------------------------
6748 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
6749 {
6750 super.OnItemLocationChanged(old_owner, new_owner);
6751
6752 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
6753 PlayerBase playerNew = PlayerBase.Cast(new_owner);
6754
6755 if (!relatedPlayer && playerNew)
6756 relatedPlayer = playerNew;
6757
6758 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
6759 {
6760 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
6761 if (actionMgr)
6762 {
6763 ActionBase currentAction = actionMgr.GetRunningAction();
6764 if (currentAction)
6765 currentAction.OnItemLocationChanged(this);
6766 }
6767 }
6768
6769 Man ownerPlayerOld = null;
6770 Man ownerPlayerNew = null;
6771
6772 if (old_owner)
6773 {
6774 if (old_owner.IsMan())
6775 {
6776 ownerPlayerOld = Man.Cast(old_owner);
6777 }
6778 else
6779 {
6780 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
6781 }
6782 }
6783 else
6784 {
6785 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
6786 {
6787 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
6788
6789 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
6790 {
6791 GetCompEM().UnplugThis();
6792 }
6793 }
6794 }
6795
6796 if (new_owner)
6797 {
6798 if (new_owner.IsMan())
6799 {
6800 ownerPlayerNew = Man.Cast(new_owner);
6801 }
6802 else
6803 {
6804 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
6805 }
6806 }
6807
6808 if (ownerPlayerOld != ownerPlayerNew)
6809 {
6810 if (ownerPlayerOld)
6811 {
6812 array<EntityAI> subItemsExit = new array<EntityAI>;
6813 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
6814 for (int i = 0; i < subItemsExit.Count(); i++)
6815 {
6816 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
6817 itemExit.OnInventoryExit(ownerPlayerOld);
6818 }
6819 }
6820
6821 if (ownerPlayerNew)
6822 {
6823 array<EntityAI> subItemsEnter = new array<EntityAI>;
6824 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
6825 for (int j = 0; j < subItemsEnter.Count(); j++)
6826 {
6827 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
6828 itemEnter.OnInventoryEnter(ownerPlayerNew);
6829 }
6830 }
6831 }
6832 else if (ownerPlayerNew != null)
6833 {
6834 PlayerBase nplayer;
6835 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
6836 {
6837 array<EntityAI> subItemsUpdate = new array<EntityAI>;
6838 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
6839 for (int k = 0; k < subItemsUpdate.Count(); k++)
6840 {
6841 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
6842 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
6843 }
6844 }
6845 }
6846
6847 if (old_owner)
6848 old_owner.OnChildItemRemoved(this);
6849 if (new_owner)
6850 new_owner.OnChildItemReceived(this);
6851 }
6852
6853 // -------------------------------------------------------------------------------
6854 override void EEDelete(EntityAI parent)
6855 {
6856 super.EEDelete(parent);
6857 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
6858 if (player)
6859 {
6860 OnInventoryExit(player);
6861
6862 if (player.IsAlive())
6863 {
6864 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
6865 if (r_index >= 0)
6866 {
6867 InventoryLocation r_il = new InventoryLocation;
6868 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
6869
6870 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
6871 int r_type = r_il.GetType();
6872 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
6873 {
6874 r_il.GetParent().GetOnReleaseLock().Invoke(this);
6875 }
6876 else if (r_type == InventoryLocationType.ATTACHMENT)
6877 {
6878 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
6879 }
6880
6881 }
6882
6883 player.RemoveQuickBarEntityShortcut(this);
6884 }
6885 }
6886 }
6887 // -------------------------------------------------------------------------------
6888 override void EEKilled(Object killer)
6889 {
6890 super.EEKilled(killer);
6891
6893 if (killer && killer.IsFireplace() && CanExplodeInFire())
6894 {
6895 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
6896 {
6897 if (IsMagazine())
6898 {
6899 if (Magazine.Cast(this).GetAmmoCount() > 0)
6900 {
6901 ExplodeAmmo();
6902 }
6903 }
6904 else
6905 {
6906 Explode(DamageType.EXPLOSION);
6907 }
6908 }
6909 }
6910 }
6911
6912 override void OnWasAttached(EntityAI parent, int slot_id)
6913 {
6914 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
6915
6916 super.OnWasAttached(parent, slot_id);
6917
6918 if (HasQuantity())
6919 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
6920
6921 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
6922 }
6923
6924 override void OnWasDetached(EntityAI parent, int slot_id)
6925 {
6926 super.OnWasDetached(parent, slot_id);
6927
6928 if (HasQuantity())
6929 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
6930 }
6931
6932 override string ChangeIntoOnAttach(string slot)
6933 {
6934 int idx;
6935 TStringArray inventory_slots = new TStringArray;
6936 TStringArray attach_types = new TStringArray;
6937
6938 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
6939 if (inventory_slots.Count() < 1) //is string
6940 {
6941 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
6942 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
6943 }
6944 else //is array
6945 {
6946 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
6947 }
6948
6949 idx = inventory_slots.Find(slot);
6950 if (idx < 0)
6951 return "";
6952
6953 return attach_types.Get(idx);
6954 }
6955
6956 override string ChangeIntoOnDetach()
6957 {
6958 int idx = -1;
6959 string slot;
6960
6961 TStringArray inventory_slots = new TStringArray;
6962 TStringArray detach_types = new TStringArray;
6963
6964 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
6965 if (inventory_slots.Count() < 1) //is string
6966 {
6967 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
6968 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
6969 }
6970 else //is array
6971 {
6972 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
6973 if (detach_types.Count() < 1)
6974 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
6975 }
6976
6977 for (int i = 0; i < inventory_slots.Count(); i++)
6978 {
6979 slot = inventory_slots.Get(i);
6980 }
6981
6982 if (slot != "")
6983 {
6984 if (detach_types.Count() == 1)
6985 idx = 0;
6986 else
6987 idx = inventory_slots.Find(slot);
6988 }
6989 if (idx < 0)
6990 return "";
6991
6992 return detach_types.Get(idx);
6993 }
6994
6995 void ExplodeAmmo()
6996 {
6997 //timer
6998 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
6999
7000 //min/max time
7001 float min_time = 1;
7002 float max_time = 3;
7003 float delay = Math.RandomFloat(min_time, max_time);
7004
7005 explode_timer.Run(delay, this, "DoAmmoExplosion");
7006 }
7007
7008 void DoAmmoExplosion()
7009 {
7010 Magazine magazine = Magazine.Cast(this);
7011 int pop_sounds_count = 6;
7012 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
7013
7014 //play sound
7015 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
7016 string sound_name = pop_sounds[ sound_idx ];
7017 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
7018
7019 //remove ammo count
7020 magazine.ServerAddAmmoCount(-1);
7021
7022 //if condition then repeat -> ExplodeAmmo
7023 float min_temp_to_explode = 100; //min temperature for item to explode
7024
7025 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
7026 {
7027 ExplodeAmmo();
7028 }
7029 }
7030
7031 // -------------------------------------------------------------------------------
7032 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
7033 {
7034 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
7035
7036 const int CHANCE_DAMAGE_CARGO = 4;
7037 const int CHANCE_DAMAGE_ATTACHMENT = 1;
7038 const int CHANCE_DAMAGE_NOTHING = 2;
7039
7040 if (IsClothing() || IsContainer() || IsItemTent())
7041 {
7042 float dmg = damageResult.GetDamage("","Health") * -0.5;
7043 int chances;
7044 int rnd;
7045
7046 if (GetInventory().GetCargo())
7047 {
7048 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
7049 rnd = Math.RandomInt(0,chances);
7050
7051 if (rnd < CHANCE_DAMAGE_CARGO)
7052 {
7053 DamageItemInCargo(dmg);
7054 }
7055 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
7056 {
7058 }
7059 }
7060 else
7061 {
7062 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
7063 rnd = Math.RandomInt(0,chances);
7064
7065 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
7066 {
7068 }
7069 }
7070 }
7071 }
7072
7073 bool DamageItemInCargo(float damage)
7074 {
7075 if (GetInventory().GetCargo())
7076 {
7077 int item_count = GetInventory().GetCargo().GetItemCount();
7078 if (item_count > 0)
7079 {
7080 int random_pick = Math.RandomInt(0, item_count);
7081 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
7082 if (!item.IsExplosive())
7083 {
7084 item.AddHealth("","",damage);
7085 return true;
7086 }
7087 }
7088 }
7089 return false;
7090 }
7091
7092 bool DamageItemAttachments(float damage)
7093 {
7094 int attachment_count = GetInventory().AttachmentCount();
7095 if (attachment_count > 0)
7096 {
7097 int random_pick = Math.RandomInt(0, attachment_count);
7098 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
7099 if (!attachment.IsExplosive())
7100 {
7101 attachment.AddHealth("","",damage);
7102 return true;
7103 }
7104 }
7105 return false;
7106 }
7107
7108 override bool IsSplitable()
7109 {
7110 return m_CanThisBeSplit;
7111 }
7112 //----------------
7113 override bool CanBeSplit()
7114 {
7115 if (IsSplitable() && (GetQuantity() > 1))
7116 return GetInventory().CanRemoveEntity();
7117
7118 return false;
7119 }
7120
7121 protected bool ShouldSplitQuantity(float quantity)
7122 {
7123 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
7124 if (!IsSplitable())
7125 return false;
7126
7127 // nothing to split?
7128 if (GetQuantity() <= 1)
7129 return false;
7130
7131 // check if we should re-use the item instead of creating a new copy?
7132 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
7133 int delta = GetQuantity() - quantity;
7134 if (delta == 0)
7135 return false;
7136
7137 // valid to split
7138 return true;
7139 }
7140
7141 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
7142 {
7143 if (GetGame().IsClient())
7144 {
7145 if (ScriptInputUserData.CanStoreInputUserData())
7146 {
7147 ScriptInputUserData ctx = new ScriptInputUserData;
7149 ctx.Write(1);
7150 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7151 ctx.Write(i1);
7152 ctx.Write(destination_entity);
7153 ctx.Write(true);
7154 ctx.Write(slot_id);
7155 ctx.Send();
7156 }
7157 }
7158 else if (!GetGame().IsMultiplayer())
7159 {
7160 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
7161 }
7162 }
7163
7164 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
7165 {
7166 float split_quantity_new;
7167 ItemBase new_item;
7168 float quantity = GetQuantity();
7169 float stack_max = GetTargetQuantityMax(slot_id);
7170 InventoryLocation loc = new InventoryLocation;
7171
7172 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7173 {
7174 if (stack_max <= GetQuantity())
7175 split_quantity_new = stack_max;
7176 else
7177 split_quantity_new = GetQuantity();
7178
7179 if (ShouldSplitQuantity(split_quantity_new))
7180 {
7181 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7182 if (new_item)
7183 {
7184 new_item.SetResultOfSplit(true);
7185 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7186 AddQuantity(-split_quantity_new, false, true);
7187 new_item.SetQuantity(split_quantity_new, false, true);
7188 }
7189 }
7190 }
7191 else if (destination_entity && slot_id == -1)
7192 {
7193 if (quantity > stack_max)
7194 split_quantity_new = stack_max;
7195 else
7196 split_quantity_new = quantity;
7197
7198 if (ShouldSplitQuantity(split_quantity_new))
7199 {
7200 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
7201 {
7202 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
7203 new_item = ItemBase.Cast(o);
7204 }
7205
7206 if (new_item)
7207 {
7208 new_item.SetResultOfSplit(true);
7209 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7210 AddQuantity(-split_quantity_new, false, true);
7211 new_item.SetQuantity(split_quantity_new, false, true);
7212 }
7213 }
7214 }
7215 else
7216 {
7217 if (stack_max != 0)
7218 {
7219 if (stack_max < GetQuantity())
7220 {
7221 split_quantity_new = GetQuantity() - stack_max;
7222 }
7223
7224 if (split_quantity_new == 0)
7225 {
7226 if (!GetGame().IsMultiplayer())
7227 player.PhysicalPredictiveDropItem(this);
7228 else
7229 player.ServerDropEntity(this);
7230 return;
7231 }
7232
7233 if (ShouldSplitQuantity(split_quantity_new))
7234 {
7235 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
7236
7237 if (new_item)
7238 {
7239 new_item.SetResultOfSplit(true);
7240 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7241 SetQuantity(split_quantity_new, false, true);
7242 new_item.SetQuantity(stack_max, false, true);
7243 new_item.PlaceOnSurface();
7244 }
7245 }
7246 }
7247 }
7248 }
7249
7250 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
7251 {
7252 float split_quantity_new;
7253 ItemBase new_item;
7254 float quantity = GetQuantity();
7255 float stack_max = GetTargetQuantityMax(slot_id);
7256 InventoryLocation loc = new InventoryLocation;
7257
7258 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7259 {
7260 if (stack_max <= GetQuantity())
7261 split_quantity_new = stack_max;
7262 else
7263 split_quantity_new = GetQuantity();
7264
7265 if (ShouldSplitQuantity(split_quantity_new))
7266 {
7267 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7268 if (new_item)
7269 {
7270 new_item.SetResultOfSplit(true);
7271 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7272 AddQuantity(-split_quantity_new, false, true);
7273 new_item.SetQuantity(split_quantity_new, false, true);
7274 }
7275 }
7276 }
7277 else if (destination_entity && slot_id == -1)
7278 {
7279 if (quantity > stack_max)
7280 split_quantity_new = stack_max;
7281 else
7282 split_quantity_new = quantity;
7283
7284 if (ShouldSplitQuantity(split_quantity_new))
7285 {
7286 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
7287 {
7288 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
7289 new_item = ItemBase.Cast(o);
7290 }
7291
7292 if (new_item)
7293 {
7294 new_item.SetResultOfSplit(true);
7295 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7296 AddQuantity(-split_quantity_new, false, true);
7297 new_item.SetQuantity(split_quantity_new, false, true);
7298 }
7299 }
7300 }
7301 else
7302 {
7303 if (stack_max != 0)
7304 {
7305 if (stack_max < GetQuantity())
7306 {
7307 split_quantity_new = GetQuantity() - stack_max;
7308 }
7309
7310 if (ShouldSplitQuantity(split_quantity_new))
7311 {
7312 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
7313
7314 if (new_item)
7315 {
7316 new_item.SetResultOfSplit(true);
7317 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7318 SetQuantity(split_quantity_new, false, true);
7319 new_item.SetQuantity(stack_max, false, true);
7320 new_item.PlaceOnSurface();
7321 }
7322 }
7323 }
7324 }
7325 }
7326
7327 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
7328 {
7329 if (GetGame().IsClient())
7330 {
7331 if (ScriptInputUserData.CanStoreInputUserData())
7332 {
7333 ScriptInputUserData ctx = new ScriptInputUserData;
7335 ctx.Write(4);
7336 ItemBase thiz = this; // @NOTE: workaround for correct serialization
7337 ctx.Write(thiz);
7338 dst.WriteToContext(ctx);
7339 ctx.Send();
7340 }
7341 }
7342 else if (!GetGame().IsMultiplayer())
7343 {
7345 }
7346 }
7347
7348 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
7349 {
7350 if (GetGame().IsClient())
7351 {
7352 if (ScriptInputUserData.CanStoreInputUserData())
7353 {
7354 ScriptInputUserData ctx = new ScriptInputUserData;
7356 ctx.Write(2);
7357 ItemBase dummy = this; // @NOTE: workaround for correct serialization
7358 ctx.Write(dummy);
7359 ctx.Write(destination_entity);
7360 ctx.Write(true);
7361 ctx.Write(idx);
7362 ctx.Write(row);
7363 ctx.Write(col);
7364 ctx.Send();
7365 }
7366 }
7367 else if (!GetGame().IsMultiplayer())
7368 {
7369 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
7370 }
7371 }
7372
7373 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
7374 {
7376 }
7377
7378 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
7379 {
7380 float quantity = GetQuantity();
7381 float split_quantity_new;
7382 ItemBase new_item;
7383 if (dst.IsValid())
7384 {
7385 int slot_id = dst.GetSlot();
7386 float stack_max = GetTargetQuantityMax(slot_id);
7387
7388 if (quantity > stack_max)
7389 split_quantity_new = stack_max;
7390 else
7391 split_quantity_new = quantity;
7392
7393 if (ShouldSplitQuantity(split_quantity_new))
7394 {
7395 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
7396
7397 if (new_item)
7398 {
7399 new_item.SetResultOfSplit(true);
7400 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7401 AddQuantity(-split_quantity_new, false, true);
7402 new_item.SetQuantity(split_quantity_new, false, true);
7403 }
7404
7405 return new_item;
7406 }
7407 }
7408
7409 return null;
7410 }
7411
7412 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
7413 {
7414 float quantity = GetQuantity();
7415 float split_quantity_new;
7416 ItemBase new_item;
7417 if (destination_entity)
7418 {
7419 float stackable = GetTargetQuantityMax();
7420 if (quantity > stackable)
7421 split_quantity_new = stackable;
7422 else
7423 split_quantity_new = quantity;
7424
7425 if (ShouldSplitQuantity(split_quantity_new))
7426 {
7427 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
7428 if (new_item)
7429 {
7430 new_item.SetResultOfSplit(true);
7431 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7432 AddQuantity(-split_quantity_new, false, true);
7433 new_item.SetQuantity(split_quantity_new, false, true);
7434 }
7435 }
7436 }
7437 }
7438
7439 void SplitIntoStackMaxHandsClient(PlayerBase player)
7440 {
7441 if (GetGame().IsClient())
7442 {
7443 if (ScriptInputUserData.CanStoreInputUserData())
7444 {
7445 ScriptInputUserData ctx = new ScriptInputUserData;
7447 ctx.Write(3);
7448 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7449 ctx.Write(i1);
7450 ItemBase destination_entity = this;
7451 ctx.Write(destination_entity);
7452 ctx.Write(true);
7453 ctx.Write(0);
7454 ctx.Send();
7455 }
7456 }
7457 else if (!GetGame().IsMultiplayer())
7458 {
7459 SplitIntoStackMaxHands(player);
7460 }
7461 }
7462
7463 void SplitIntoStackMaxHands(PlayerBase player)
7464 {
7465 float quantity = GetQuantity();
7466 float split_quantity_new;
7467 ref ItemBase new_item;
7468 if (player)
7469 {
7470 float stackable = GetTargetQuantityMax();
7471 if (quantity > stackable)
7472 split_quantity_new = stackable;
7473 else
7474 split_quantity_new = quantity;
7475
7476 if (ShouldSplitQuantity(split_quantity_new))
7477 {
7478 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
7479 new_item = ItemBase.Cast(in_hands);
7480 if (new_item)
7481 {
7482 new_item.SetResultOfSplit(true);
7483 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7484 AddQuantity(-split_quantity_new, false, true);
7485 new_item.SetQuantity(split_quantity_new, false, true);
7486 }
7487 }
7488 }
7489 }
7490
7491 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
7492 {
7493 float quantity = GetQuantity();
7494 float split_quantity_new = Math.Floor(quantity * 0.5);
7495
7496 if (!ShouldSplitQuantity(split_quantity_new))
7497 return;
7498
7499 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
7500
7501 if (new_item)
7502 {
7503 if (new_item.GetQuantityMax() < split_quantity_new)
7504 {
7505 split_quantity_new = new_item.GetQuantityMax();
7506 }
7507
7508 new_item.SetResultOfSplit(true);
7509 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7510
7511 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
7512 {
7513 AddQuantity(-1, false, true);
7514 new_item.SetQuantity(1, false, true);
7515 }
7516 else
7517 {
7518 AddQuantity(-split_quantity_new, false, true);
7519 new_item.SetQuantity(split_quantity_new, false, true);
7520 }
7521 }
7522 }
7523
7524 void SplitItem(PlayerBase player)
7525 {
7526 float quantity = GetQuantity();
7527 float split_quantity_new = Math.Floor(quantity / 2);
7528
7529 if (!ShouldSplitQuantity(split_quantity_new))
7530 return;
7531
7532 InventoryLocation invloc = new InventoryLocation;
7533 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
7534
7535 ItemBase new_item;
7536 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
7537
7538 if (new_item)
7539 {
7540 if (new_item.GetQuantityMax() < split_quantity_new)
7541 {
7542 split_quantity_new = new_item.GetQuantityMax();
7543 }
7544 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
7545 {
7546 AddQuantity(-1, false, true);
7547 new_item.SetQuantity(1, false, true);
7548 }
7549 else if (split_quantity_new > 1)
7550 {
7551 AddQuantity(-split_quantity_new, false, true);
7552 new_item.SetQuantity(split_quantity_new, false, true);
7553 }
7554 }
7555 }
7556
7558 void OnQuantityChanged(float delta)
7559 {
7560 SetWeightDirty();
7561 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
7562
7563 if (parent)
7564 parent.OnAttachmentQuantityChangedEx(this, delta);
7565
7566 if (IsLiquidContainer())
7567 {
7568 if (GetQuantityNormalized() <= 0.0)
7569 {
7571 }
7572 else if (GetLiquidType() == LIQUID_NONE)
7573 {
7574 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
7576 }
7577 }
7578
7579 }
7580
7583 {
7584 // insert code here
7585 }
7586
7588 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
7589 {
7591 }
7592
7593 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
7594 {
7595 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
7596
7597 if (GetGame().IsServer())
7598 {
7599 if (newLevel == GameConstants.STATE_RUINED)
7600 {
7602 EntityAI parent = GetHierarchyParent();
7603 if (parent && parent.IsFireplace())
7604 {
7605 CargoBase cargo = GetInventory().GetCargo();
7606 if (cargo)
7607 {
7608 for (int i = 0; i < cargo.GetItemCount(); ++i)
7609 {
7610 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
7611 }
7612 }
7613 }
7614 }
7615
7616 if (IsResultOfSplit())
7617 {
7618 // reset the splitting result flag, return to normal item behavior
7619 SetResultOfSplit(false);
7620 return;
7621 }
7622
7623 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
7624 {
7625 SetCleanness(0);//unclean the item upon damage dealt
7626 }
7627 }
7628 }
7629
7630 // just the split? TODO: verify
7631 override void OnRightClick()
7632 {
7633 super.OnRightClick();
7634
7635 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
7636 {
7637 if (GetGame().IsClient())
7638 {
7639 if (ScriptInputUserData.CanStoreInputUserData())
7640 {
7641 EntityAI root = GetHierarchyRoot();
7642 Man playerOwner = GetHierarchyRootPlayer();
7643 InventoryLocation dst = new InventoryLocation;
7644
7645 // 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
7646 if (!playerOwner && root && root == this)
7647 {
7649 }
7650 else
7651 {
7652 // 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
7653 GetInventory().GetCurrentInventoryLocation(dst);
7654 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
7655 {
7656 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
7657 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
7658 {
7660 }
7661 else
7662 {
7663 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
7664 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
7665 this shouldnt cause issues within this scope*/
7666 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
7667 {
7669 }
7670 else
7671 {
7672 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
7673 }
7674 }
7675 }
7676 }
7677
7678 ScriptInputUserData ctx = new ScriptInputUserData;
7680 ctx.Write(4);
7681 ItemBase thiz = this; // @NOTE: workaround for correct serialization
7682 ctx.Write(thiz);
7683 dst.WriteToContext(ctx);
7684 ctx.Write(true); // dummy
7685 ctx.Send();
7686 }
7687 }
7688 else if (!GetGame().IsMultiplayer())
7689 {
7690 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
7691 }
7692 }
7693 }
7694
7695 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
7696 {
7697 if (root)
7698 {
7699 vector m4[4];
7700 root.GetTransform(m4);
7701 dst.SetGround(this, m4);
7702 }
7703 else
7704 {
7705 GetInventory().GetCurrentInventoryLocation(dst);
7706 }
7707 }
7708
7709 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
7710 {
7711 //TODO: delete check zero quantity check after fix double posts hands fsm events
7712 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
7713 return false;
7714
7715 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
7716 return false;
7717
7718 //can_this_be_combined = ConfigGetBool("canBeSplit");
7720 return false;
7721
7722
7723 Magazine mag = Magazine.Cast(this);
7724 if (mag)
7725 {
7726 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
7727 return false;
7728
7729 if (stack_max_limit)
7730 {
7731 Magazine other_mag = Magazine.Cast(other_item);
7732 if (other_item)
7733 {
7734 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
7735 return false;
7736 }
7737
7738 }
7739 }
7740 else
7741 {
7742 //TODO: delete check zero quantity check after fix double posts hands fsm events
7743 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
7744 return false;
7745
7746 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
7747 return false;
7748 }
7749
7750 PlayerBase player = null;
7751 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
7752 {
7753 if (player.GetInventory().HasAttachment(this))
7754 return false;
7755
7756 if (player.IsItemsToDelete())
7757 return false;
7758 }
7759
7760 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
7761 return false;
7762
7763 int slotID;
7764 string slotName;
7765 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
7766 return false;
7767
7768 return true;
7769 }
7770
7771 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
7772 {
7773 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
7774 }
7775
7776 bool IsResultOfSplit()
7777 {
7778 return m_IsResultOfSplit;
7779 }
7780
7781 void SetResultOfSplit(bool value)
7782 {
7783 m_IsResultOfSplit = value;
7784 }
7785
7786 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
7787 {
7788 return ComputeQuantityUsedEx(other_item, use_stack_max);
7789 }
7790
7791 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
7792 {
7793 float other_item_quantity = other_item.GetQuantity();
7794 float this_free_space;
7795
7796 float stack_max = GetQuantityMax();
7797
7798 this_free_space = stack_max - GetQuantity();
7799
7800 if (other_item_quantity > this_free_space)
7801 {
7802 return this_free_space;
7803 }
7804 else
7805 {
7806 return other_item_quantity;
7807 }
7808 }
7809
7810 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
7811 {
7812 CombineItems(ItemBase.Cast(entity2),use_stack_max);
7813 }
7814
7815 void CombineItems(ItemBase other_item, bool use_stack_max = true)
7816 {
7817 if (!CanBeCombined(other_item, false))
7818 return;
7819
7820 if (!IsMagazine() && other_item)
7821 {
7822 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
7823 if (quantity_used != 0)
7824 {
7825 float hp1 = GetHealth01("","");
7826 float hp2 = other_item.GetHealth01("","");
7827 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
7828 hpResult = hpResult / (GetQuantity() + quantity_used);
7829
7830 hpResult *= GetMaxHealth();
7831 Math.Round(hpResult);
7832 SetHealth("", "Health", hpResult);
7833
7834 AddQuantity(quantity_used);
7835 other_item.AddQuantity(-quantity_used);
7836 }
7837 }
7838 OnCombine(other_item);
7839 }
7840
7841 void OnCombine(ItemBase other_item)
7842 {
7843 #ifdef SERVER
7844 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
7845 GetHierarchyParent().IncreaseLifetimeUp();
7846 #endif
7847 };
7848
7849 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
7850 {
7851 PlayerBase p = PlayerBase.Cast(player);
7852
7853 array<int> recipesIds = p.m_Recipes;
7854 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
7855 if (moduleRecipesManager)
7856 {
7857 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
7858 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
7859 }
7860
7861 for (int i = 0;i < recipesIds.Count(); i++)
7862 {
7863 int key = recipesIds.Get(i);
7864 string recipeName = moduleRecipesManager.GetRecipeName(key);
7865 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
7866 }
7867 }
7868
7869 // -------------------------------------------------------------------------
7870 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
7871 {
7872 super.GetDebugActions(outputList);
7873
7874 //quantity
7875 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
7876 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
7877 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
7878 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
7879 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7880
7881 //health
7882 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
7883 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
7884 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
7885 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7886 //temperature
7887 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
7888 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
7889 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
7890 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7891
7892 //wet
7893 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
7894 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
7895 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7896
7897 //liquidtype
7898 if (IsLiquidContainer())
7899 {
7900 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
7901 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
7902 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7903 }
7904
7905 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
7906 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7907
7908 // watch
7909 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
7910 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
7911 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7912
7913 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
7914
7915 InventoryLocation loc = new InventoryLocation();
7916 GetInventory().GetCurrentInventoryLocation(loc);
7917 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
7918 {
7919 if (Gizmo_IsSupported())
7920 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
7921 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
7922 }
7923
7924 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7925 }
7926
7927 // -------------------------------------------------------------------------
7928 // -------------------------------------------------------------------------
7929 // -------------------------------------------------------------------------
7930 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
7931 {
7932 super.OnAction(action_id, player, ctx);
7933
7934 if (GetGame().IsClient() || !GetGame().IsMultiplayer())
7935 {
7936 switch (action_id)
7937 {
7938 case EActions.GIZMO_OBJECT:
7939 GetGame().GizmoSelectObject(this);
7940 return true;
7941 case EActions.GIZMO_PHYSICS:
7942 GetGame().GizmoSelectPhysics(GetPhysics());
7943 return true;
7944 }
7945 }
7946
7947 if (GetGame().IsServer())
7948 {
7949 switch (action_id)
7950 {
7951 case EActions.DELETE:
7952 Delete();
7953 return true;
7954 }
7955 }
7956
7957 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
7958 {
7959 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
7960 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
7961 PlayerBase p = PlayerBase.Cast(player);
7962 if (EActions.RECIPES_RANGE_START < 1000)
7963 {
7964 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
7965 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
7966 }
7967 }
7968 #ifndef SERVER
7969 else if (action_id == EActions.WATCH_PLAYER)
7970 {
7971 PluginDeveloper.SetDeveloperItemClientEx(player);
7972 }
7973 #endif
7974 if (GetGame().IsServer())
7975 {
7976 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
7977 {
7978 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
7979 OnDebugButtonPressServer(id + 1);
7980 }
7981
7982 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
7983 {
7984 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
7985 InsertAgent(agent_id,100);
7986 }
7987
7988 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
7989 {
7990 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
7991 RemoveAgent(agent_id2);
7992 }
7993
7994 else if (action_id == EActions.ADD_QUANTITY)
7995 {
7996 if (IsMagazine())
7997 {
7998 Magazine mag = Magazine.Cast(this);
7999 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
8000 }
8001 else
8002 {
8003 AddQuantity(GetQuantityMax() * 0.2);
8004 }
8005
8006 if (m_EM)
8007 {
8008 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
8009 }
8010 //PrintVariables();
8011 }
8012
8013 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
8014 {
8015 if (IsMagazine())
8016 {
8017 Magazine mag2 = Magazine.Cast(this);
8018 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
8019 }
8020 else
8021 {
8022 AddQuantity(- GetQuantityMax() * 0.2);
8023 }
8024 if (m_EM)
8025 {
8026 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
8027 }
8028 //PrintVariables();
8029 }
8030
8031 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
8032 {
8033 SetQuantity(0);
8034
8035 if (m_EM)
8036 {
8037 m_EM.SetEnergy(0);
8038 }
8039 }
8040
8041 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
8042 {
8044
8045 if (m_EM)
8046 {
8047 m_EM.SetEnergy(m_EM.GetEnergyMax());
8048 }
8049 }
8050
8051 else if (action_id == EActions.ADD_HEALTH)
8052 {
8053 AddHealth("","",GetMaxHealth("","Health")/5);
8054 }
8055 else if (action_id == EActions.REMOVE_HEALTH)
8056 {
8057 AddHealth("","",-GetMaxHealth("","Health")/5);
8058 }
8059 else if (action_id == EActions.DESTROY_HEALTH)
8060 {
8061 SetHealth01("","",0);
8062 }
8063 else if (action_id == EActions.WATCH_ITEM)
8064 {
8066 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
8067 #ifdef DEVELOPER
8068 SetDebugDeveloper_item(this);
8069 #endif
8070 }
8071
8072 else if (action_id == EActions.ADD_TEMPERATURE)
8073 {
8074 AddTemperature(20);
8075 //PrintVariables();
8076 }
8077
8078 else if (action_id == EActions.REMOVE_TEMPERATURE)
8079 {
8080 AddTemperature(-20);
8081 //PrintVariables();
8082 }
8083
8084 else if (action_id == EActions.FLIP_FROZEN)
8085 {
8086 SetFrozen(!GetIsFrozen());
8087 //PrintVariables();
8088 }
8089
8090 else if (action_id == EActions.ADD_WETNESS)
8091 {
8092 AddWet(GetWetMax()/5);
8093 //PrintVariables();
8094 }
8095
8096 else if (action_id == EActions.REMOVE_WETNESS)
8097 {
8098 AddWet(-GetWetMax()/5);
8099 //PrintVariables();
8100 }
8101
8102 else if (action_id == EActions.LIQUIDTYPE_UP)
8103 {
8104 int curr_type = GetLiquidType();
8105 SetLiquidType(curr_type * 2);
8106 //AddWet(1);
8107 //PrintVariables();
8108 }
8109
8110 else if (action_id == EActions.LIQUIDTYPE_DOWN)
8111 {
8112 int curr_type2 = GetLiquidType();
8113 SetLiquidType(curr_type2 / 2);
8114 }
8115
8116 else if (action_id == EActions.MAKE_SPECIAL)
8117 {
8118 auto debugParams = DebugSpawnParams.WithPlayer(player);
8119 OnDebugSpawnEx(debugParams);
8120 }
8121
8122 }
8123
8124
8125 return false;
8126 }
8127
8128 // -------------------------------------------------------------------------
8129
8130
8133 void OnActivatedByTripWire();
8134
8136 void OnActivatedByItem(notnull ItemBase item);
8137
8138 //----------------------------------------------------------------
8139 //returns true if item is able to explode when put in fire
8140 bool CanExplodeInFire()
8141 {
8142 return false;
8143 }
8144
8145 //----------------------------------------------------------------
8146 bool CanEat()
8147 {
8148 return true;
8149 }
8150
8151 //----------------------------------------------------------------
8152 override bool IsIgnoredByConstruction()
8153 {
8154 return true;
8155 }
8156
8157 //----------------------------------------------------------------
8158 //has FoodStages in config?
8159 bool HasFoodStage()
8160 {
8161 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
8162 return GetGame().ConfigIsExisting(config_path);
8163 }
8164
8166 FoodStage GetFoodStage()
8167 {
8168 return null;
8169 }
8170
8171 bool CanBeCooked()
8172 {
8173 return false;
8174 }
8175
8176 bool CanBeCookedOnStick()
8177 {
8178 return false;
8179 }
8180
8182 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
8184
8185 //----------------------------------------------------------------
8186 bool CanRepair(ItemBase item_repair_kit)
8187 {
8188 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8189 return module_repairing.CanRepair(this, item_repair_kit);
8190 }
8191
8192 //----------------------------------------------------------------
8193 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
8194 {
8195 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8196 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
8197 }
8198
8199 //----------------------------------------------------------------
8200 int GetItemSize()
8201 {
8202 /*
8203 vector v_size = this.ConfigGetVector("itemSize");
8204 int v_size_x = v_size[0];
8205 int v_size_y = v_size[1];
8206 int size = v_size_x * v_size_y;
8207 return size;
8208 */
8209
8210 return 1;
8211 }
8212
8213 //----------------------------------------------------------------
8214 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
8215 bool CanBeMovedOverride()
8216 {
8217 return m_CanBeMovedOverride;
8218 }
8219
8220 //----------------------------------------------------------------
8221 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
8222 void SetCanBeMovedOverride(bool setting)
8223 {
8224 m_CanBeMovedOverride = setting;
8225 }
8226
8227 //----------------------------------------------------------------
8235 void MessageToOwnerStatus(string text)
8236 {
8237 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8238
8239 if (player)
8240 {
8241 player.MessageStatus(text);
8242 }
8243 }
8244
8245 //----------------------------------------------------------------
8253 void MessageToOwnerAction(string text)
8254 {
8255 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8256
8257 if (player)
8258 {
8259 player.MessageAction(text);
8260 }
8261 }
8262
8263 //----------------------------------------------------------------
8271 void MessageToOwnerFriendly(string text)
8272 {
8273 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8274
8275 if (player)
8276 {
8277 player.MessageFriendly(text);
8278 }
8279 }
8280
8281 //----------------------------------------------------------------
8289 void MessageToOwnerImportant(string text)
8290 {
8291 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8292
8293 if (player)
8294 {
8295 player.MessageImportant(text);
8296 }
8297 }
8298
8299 override bool IsItemBase()
8300 {
8301 return true;
8302 }
8303
8304 // Checks if item is of questioned kind
8305 override bool KindOf(string tag)
8306 {
8307 bool found = false;
8308 string item_name = this.GetType();
8309 ref TStringArray item_tag_array = new TStringArray;
8310 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
8311
8312 int array_size = item_tag_array.Count();
8313 for (int i = 0; i < array_size; i++)
8314 {
8315 if (item_tag_array.Get(i) == tag)
8316 {
8317 found = true;
8318 break;
8319 }
8320 }
8321 return found;
8322 }
8323
8324
8325 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
8326 {
8327 //Debug.Log("OnRPC called");
8328 super.OnRPC(sender, rpc_type,ctx);
8329
8330 //Play soundset for attachment locking (ActionLockAttachment.c)
8331 switch (rpc_type)
8332 {
8333 #ifndef SERVER
8334 case ERPCs.RPC_SOUND_LOCK_ATTACH:
8335 Param2<bool, string> p = new Param2<bool, string>(false, "");
8336
8337 if (!ctx.Read(p))
8338 return;
8339
8340 bool play = p.param1;
8341 string soundSet = p.param2;
8342
8343 if (play)
8344 {
8345 if (m_LockingSound)
8346 {
8348 {
8349 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
8350 }
8351 }
8352 else
8353 {
8354 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
8355 }
8356 }
8357 else
8358 {
8359 SEffectManager.DestroyEffect(m_LockingSound);
8360 }
8361
8362 break;
8363 #endif
8364
8365 }
8366
8367 if (GetWrittenNoteData())
8368 {
8369 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
8370 }
8371 }
8372
8373 //-----------------------------
8374 // VARIABLE MANIPULATION SYSTEM
8375 //-----------------------------
8376 int NameToID(string name)
8377 {
8378 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
8379 return plugin.GetID(name);
8380 }
8381
8382 string IDToName(int id)
8383 {
8384 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
8385 return plugin.GetName(id);
8386 }
8387
8389 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
8390 {
8391 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
8392 //read the flags
8393 int varFlags;
8394 if (!ctx.Read(varFlags))
8395 return;
8396
8397 if (varFlags & ItemVariableFlags.FLOAT)
8398 {
8399 ReadVarsFromCTX(ctx);
8400 }
8401 }
8402
8403 override void SerializeNumericalVars(array<float> floats_out)
8404 {
8405 //some variables handled on EntityAI level already!
8406 super.SerializeNumericalVars(floats_out);
8407
8408 // the order of serialization must be the same as the order of de-serialization
8409 //--------------------------------------------
8410 if (IsVariableSet(VARIABLE_QUANTITY))
8411 {
8412 floats_out.Insert(m_VarQuantity);
8413 }
8414 //--------------------------------------------
8415 if (IsVariableSet(VARIABLE_WET))
8416 {
8417 floats_out.Insert(m_VarWet);
8418 }
8419 //--------------------------------------------
8420 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
8421 {
8422 floats_out.Insert(m_VarLiquidType);
8423 }
8424 //--------------------------------------------
8425 if (IsVariableSet(VARIABLE_COLOR))
8426 {
8427 floats_out.Insert(m_ColorComponentR);
8428 floats_out.Insert(m_ColorComponentG);
8429 floats_out.Insert(m_ColorComponentB);
8430 floats_out.Insert(m_ColorComponentA);
8431 }
8432 //--------------------------------------------
8433 if (IsVariableSet(VARIABLE_CLEANNESS))
8434 {
8435 floats_out.Insert(m_Cleanness);
8436 }
8437 }
8438
8439 override void DeSerializeNumericalVars(array<float> floats)
8440 {
8441 //some variables handled on EntityAI level already!
8442 super.DeSerializeNumericalVars(floats);
8443
8444 // the order of serialization must be the same as the order of de-serialization
8445 int index = 0;
8446 int mask = Math.Round(floats.Get(index));
8447
8448 index++;
8449 //--------------------------------------------
8450 if (mask & VARIABLE_QUANTITY)
8451 {
8452 if (m_IsStoreLoad)
8453 {
8454 SetStoreLoadedQuantity(floats.Get(index));
8455 }
8456 else
8457 {
8458 float quantity = floats.Get(index);
8459 SetQuantity(quantity, true, false, false, false);
8460 }
8461 index++;
8462 }
8463 //--------------------------------------------
8464 if (mask & VARIABLE_WET)
8465 {
8466 float wet = floats.Get(index);
8467 SetWet(wet);
8468 index++;
8469 }
8470 //--------------------------------------------
8471 if (mask & VARIABLE_LIQUIDTYPE)
8472 {
8473 int liquidtype = Math.Round(floats.Get(index));
8474 SetLiquidType(liquidtype);
8475 index++;
8476 }
8477 //--------------------------------------------
8478 if (mask & VARIABLE_COLOR)
8479 {
8480 m_ColorComponentR = Math.Round(floats.Get(index));
8481 index++;
8482 m_ColorComponentG = Math.Round(floats.Get(index));
8483 index++;
8484 m_ColorComponentB = Math.Round(floats.Get(index));
8485 index++;
8486 m_ColorComponentA = Math.Round(floats.Get(index));
8487 index++;
8488 }
8489 //--------------------------------------------
8490 if (mask & VARIABLE_CLEANNESS)
8491 {
8492 int cleanness = Math.Round(floats.Get(index));
8493 SetCleanness(cleanness);
8494 index++;
8495 }
8496 }
8497
8498 override void WriteVarsToCTX(ParamsWriteContext ctx)
8499 {
8500 super.WriteVarsToCTX(ctx);
8501
8502 //--------------------------------------------
8503 if (IsVariableSet(VARIABLE_QUANTITY))
8504 {
8505 ctx.Write(GetQuantity());
8506 }
8507 //--------------------------------------------
8508 if (IsVariableSet(VARIABLE_WET))
8509 {
8510 ctx.Write(GetWet());
8511 }
8512 //--------------------------------------------
8513 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
8514 {
8515 ctx.Write(GetLiquidType());
8516 }
8517 //--------------------------------------------
8518 if (IsVariableSet(VARIABLE_COLOR))
8519 {
8520 int r,g,b,a;
8521 GetColor(r,g,b,a);
8522 ctx.Write(r);
8523 ctx.Write(g);
8524 ctx.Write(b);
8525 ctx.Write(a);
8526 }
8527 //--------------------------------------------
8528 if (IsVariableSet(VARIABLE_CLEANNESS))
8529 {
8530 ctx.Write(GetCleanness());
8531 }
8532 }
8533
8534 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
8535 {
8536 if (!super.ReadVarsFromCTX(ctx,version))
8537 return false;
8538
8539 int intValue;
8540 float value;
8541
8542 if (version < 140)
8543 {
8544 if (!ctx.Read(intValue))
8545 return false;
8546
8547 m_VariablesMask = intValue;
8548 }
8549
8550 if (m_VariablesMask & VARIABLE_QUANTITY)
8551 {
8552 if (!ctx.Read(value))
8553 return false;
8554
8555 if (IsStoreLoad())
8556 {
8558 }
8559 else
8560 {
8561 SetQuantity(value, true, false, false, false);
8562 }
8563 }
8564 //--------------------------------------------
8565 if (version < 140)
8566 {
8567 if (m_VariablesMask & VARIABLE_TEMPERATURE)
8568 {
8569 if (!ctx.Read(value))
8570 return false;
8571 SetTemperatureDirect(value);
8572 }
8573 }
8574 //--------------------------------------------
8575 if (m_VariablesMask & VARIABLE_WET)
8576 {
8577 if (!ctx.Read(value))
8578 return false;
8579 SetWet(value);
8580 }
8581 //--------------------------------------------
8582 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
8583 {
8584 if (!ctx.Read(intValue))
8585 return false;
8586 SetLiquidType(intValue);
8587 }
8588 //--------------------------------------------
8589 if (m_VariablesMask & VARIABLE_COLOR)
8590 {
8591 int r,g,b,a;
8592 if (!ctx.Read(r))
8593 return false;
8594 if (!ctx.Read(g))
8595 return false;
8596 if (!ctx.Read(b))
8597 return false;
8598 if (!ctx.Read(a))
8599 return false;
8600
8601 SetColor(r,g,b,a);
8602 }
8603 //--------------------------------------------
8604 if (m_VariablesMask & VARIABLE_CLEANNESS)
8605 {
8606 if (!ctx.Read(intValue))
8607 return false;
8608 SetCleanness(intValue);
8609 }
8610 //--------------------------------------------
8611 if (version >= 138 && version < 140)
8612 {
8613 if (m_VariablesMask & VARIABLE_TEMPERATURE)
8614 {
8615 if (!ctx.Read(intValue))
8616 return false;
8617 SetFrozen(intValue);
8618 }
8619 }
8620
8621 return true;
8622 }
8623
8624 //----------------------------------------------------------------
8625 override bool OnStoreLoad(ParamsReadContext ctx, int version)
8626 {
8627 m_IsStoreLoad = true;
8629 {
8630 m_FixDamageSystemInit = true;
8631 }
8632
8633 if (!super.OnStoreLoad(ctx, version))
8634 {
8635 m_IsStoreLoad = false;
8636 return false;
8637 }
8638
8639 if (version >= 114)
8640 {
8641 bool hasQuickBarIndexSaved;
8642
8643 if (!ctx.Read(hasQuickBarIndexSaved))
8644 {
8645 m_IsStoreLoad = false;
8646 return false;
8647 }
8648
8649 if (hasQuickBarIndexSaved)
8650 {
8651 int itmQBIndex;
8652
8653 //Load quickbar item bind
8654 if (!ctx.Read(itmQBIndex))
8655 {
8656 m_IsStoreLoad = false;
8657 return false;
8658 }
8659
8660 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
8661 if (itmQBIndex != -1 && parentPlayer)
8662 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
8663 }
8664 }
8665 else
8666 {
8667 // Backup of how it used to be
8668 PlayerBase player;
8669 int itemQBIndex;
8670 if (version == int.MAX)
8671 {
8672 if (!ctx.Read(itemQBIndex))
8673 {
8674 m_IsStoreLoad = false;
8675 return false;
8676 }
8677 }
8678 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
8679 {
8680 //Load quickbar item bind
8681 if (!ctx.Read(itemQBIndex))
8682 {
8683 m_IsStoreLoad = false;
8684 return false;
8685 }
8686 if (itemQBIndex != -1 && player)
8687 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
8688 }
8689 }
8690
8691 if (version < 140)
8692 {
8693 // variable management system
8694 if (!LoadVariables(ctx, version))
8695 {
8696 m_IsStoreLoad = false;
8697 return false;
8698 }
8699 }
8700
8701 //agent trasmission system
8702 if (!LoadAgents(ctx, version))
8703 {
8704 m_IsStoreLoad = false;
8705 return false;
8706 }
8707 if (version >= 132)
8708 {
8709 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
8710 if (raib)
8711 {
8712 if (!raib.OnStoreLoad(ctx,version))
8713 {
8714 m_IsStoreLoad = false;
8715 return false;
8716 }
8717 }
8718 }
8719
8720 m_IsStoreLoad = false;
8721 return true;
8722 }
8723
8724 //----------------------------------------------------------------
8725
8726 override void OnStoreSave(ParamsWriteContext ctx)
8727 {
8728 super.OnStoreSave(ctx);
8729
8730 PlayerBase player;
8731 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
8732 {
8733 ctx.Write(true); // Keep track of if we should actually read this in or not
8734 //Save quickbar item bind
8735 int itemQBIndex = -1;
8736 itemQBIndex = player.FindQuickBarEntityIndex(this);
8737 ctx.Write(itemQBIndex);
8738 }
8739 else
8740 {
8741 ctx.Write(false); // Keep track of if we should actually read this in or not
8742 }
8743
8744 SaveAgents(ctx);//agent trasmission system
8745
8746 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
8747 if (raib)
8748 {
8749 raib.OnStoreSave(ctx);
8750 }
8751 }
8752 //----------------------------------------------------------------
8753
8754 override void AfterStoreLoad()
8755 {
8756 super.AfterStoreLoad();
8757
8759 {
8761 }
8762
8763 if (GetStoreLoadedQuantity() != float.LOWEST)
8764 {
8766 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
8767 }
8768 }
8769
8770 override void EEOnAfterLoad()
8771 {
8772 super.EEOnAfterLoad();
8773
8775 {
8776 m_FixDamageSystemInit = false;
8777 }
8778
8781 }
8782
8783 bool CanBeDisinfected()
8784 {
8785 return false;
8786 }
8787
8788
8789 //----------------------------------------------------------------
8790 override void OnVariablesSynchronized()
8791 {
8792 if (m_Initialized)
8793 {
8794 #ifdef PLATFORM_CONSOLE
8795 //bruteforce it is
8796 if (IsSplitable())
8797 {
8798 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
8799 if (menu)
8800 {
8801 menu.Refresh();
8802 }
8803 }
8804 #endif
8805 }
8806
8808 {
8809 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
8810 m_WantPlayImpactSound = false;
8811 }
8812
8814 {
8815 SetWeightDirty();
8817 }
8818 if (m_VarWet != m_VarWetPrev)
8819 {
8822 }
8823
8824 if (m_SoundSyncPlay != 0)
8825 {
8826 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
8827 m_SoundSyncPlay = 0;
8828 }
8829 if (m_SoundSyncStop != 0)
8830 {
8831 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
8832 m_SoundSyncStop = 0;
8833 }
8834
8835 super.OnVariablesSynchronized();
8836 }
8837
8838 //------------------------- Quantity
8839 //----------------------------------------------------------------
8841 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
8842 {
8843 if (!IsServerCheck(allow_client))
8844 return false;
8845
8846 if (!HasQuantity())
8847 return false;
8848
8849 float min = GetQuantityMin();
8850 float max = GetQuantityMax();
8851
8852 if (value <= (min + 0.001))
8853 value = min;
8854
8855 if (value == min)
8856 {
8857 if (destroy_config)
8858 {
8859 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
8860 if (dstr)
8861 {
8862 m_VarQuantity = Math.Clamp(value, min, max);
8863 this.Delete();
8864 return true;
8865 }
8866 }
8867 else if (destroy_forced)
8868 {
8869 m_VarQuantity = Math.Clamp(value, min, max);
8870 this.Delete();
8871 return true;
8872 }
8873 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
8874 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
8875 }
8876
8877 float delta = m_VarQuantity;
8878 m_VarQuantity = Math.Clamp(value, min, max);
8879
8880 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
8881 {
8882 delta = m_VarQuantity - delta;
8883
8884 if (delta)
8885 OnQuantityChanged(delta);
8886 }
8887
8888 SetVariableMask(VARIABLE_QUANTITY);
8889
8890 return false;
8891 }
8892
8893 //----------------------------------------------------------------
8895 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
8896 {
8897 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
8898 }
8899 //----------------------------------------------------------------
8900 void SetQuantityMax()
8901 {
8902 float max = GetQuantityMax();
8903 SetQuantity(max);
8904 }
8905
8906 override void SetQuantityToMinimum()
8907 {
8908 float min = GetQuantityMin();
8909 SetQuantity(min);
8910 }
8911 //----------------------------------------------------------------
8913 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
8914 {
8915 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
8916 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
8917 SetQuantity(result, destroy_config, destroy_forced);
8918 }
8919
8920 //----------------------------------------------------------------
8922 override float GetQuantityNormalized()
8923 {
8924 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
8925 }
8926
8928 {
8929 return GetQuantityNormalized();
8930 }
8931
8932 /*void SetAmmoNormalized(float value)
8933 {
8934 float value_clamped = Math.Clamp(value, 0, 1);
8935 Magazine this_mag = Magazine.Cast(this);
8936 int max_rounds = this_mag.GetAmmoMax();
8937 int result = value * max_rounds;//can the rounded if higher precision is required
8938 this_mag.SetAmmoCount(result);
8939 }*/
8940 //----------------------------------------------------------------
8941 override int GetQuantityMax()
8942 {
8943 int slot = -1;
8944 if (GetInventory())
8945 {
8946 InventoryLocation il = new InventoryLocation;
8947 GetInventory().GetCurrentInventoryLocation(il);
8948 slot = il.GetSlot();
8949 }
8950
8951 return GetTargetQuantityMax(slot);
8952 }
8953
8954 override int GetTargetQuantityMax(int attSlotID = -1)
8955 {
8956 float quantity_max = 0;
8957
8958 if (IsSplitable()) //only stackable/splitable items can check for stack size
8959 {
8960 if (attSlotID != -1)
8961 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
8962
8963 if (quantity_max <= 0)
8964 quantity_max = m_VarStackMax;
8965 }
8966
8967 if (quantity_max <= 0)
8968 quantity_max = m_VarQuantityMax;
8969
8970 return quantity_max;
8971 }
8972 //----------------------------------------------------------------
8973 override int GetQuantityMin()
8974 {
8975 return m_VarQuantityMin;
8976 }
8977 //----------------------------------------------------------------
8978 int GetQuantityInit()
8979 {
8980 return m_VarQuantityInit;
8981 }
8982
8983 //----------------------------------------------------------------
8984 override bool HasQuantity()
8985 {
8986 return !(GetQuantityMax() - GetQuantityMin() == 0);
8987 }
8988
8989 override float GetQuantity()
8990 {
8991 return m_VarQuantity;
8992 }
8993
8994 bool IsFullQuantity()
8995 {
8996 return GetQuantity() >= GetQuantityMax();
8997 }
8998
8999 //Calculates weight of single item without attachments and cargo
9000 override float GetSingleInventoryItemWeightEx()
9001 {
9002 //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
9003 float weightEx = GetWeightEx();//overall weight of the item
9004 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
9005 return weightEx - special;
9006 }
9007
9008 // Obsolete, use GetSingleInventoryItemWeightEx() instead
9010 {
9012 }
9013
9014 override protected float GetWeightSpecialized(bool forceRecalc = false)
9015 {
9016 if (IsSplitable()) //quantity determines size of the stack
9017 {
9018 #ifdef DEVELOPER
9019 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9020 {
9021 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
9022 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
9023 }
9024 #endif
9025
9026 return GetQuantity() * GetConfigWeightModified();
9027 }
9028 else if (HasEnergyManager())// items with energy manager
9029 {
9030 #ifdef DEVELOPER
9031 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9032 {
9033 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
9034 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
9035 }
9036 #endif
9037 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
9038 }
9039 else//everything else
9040 {
9041 #ifdef DEVELOPER
9042 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9043 {
9044 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
9045 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
9046 }
9047 #endif
9048 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
9049 }
9050 }
9051
9053 int GetNumberOfItems()
9054 {
9055 int item_count = 0;
9056 ItemBase item;
9057
9058 if (GetInventory().GetCargo() != NULL)
9059 {
9060 item_count = GetInventory().GetCargo().GetItemCount();
9061 }
9062
9063 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
9064 {
9065 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
9066 if (item)
9067 item_count += item.GetNumberOfItems();
9068 }
9069 return item_count;
9070 }
9071
9073 float GetUnitWeight(bool include_wetness = true)
9074 {
9075 float weight = 0;
9076 float wetness = 1;
9077 if (include_wetness)
9078 wetness += GetWet();
9079 if (IsSplitable()) //quantity determines size of the stack
9080 {
9081 weight = wetness * m_ConfigWeight;
9082 }
9083 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
9084 {
9085 weight = 1;
9086 }
9087 return weight;
9088 }
9089
9090 //-----------------------------------------------------------------
9091
9092 override void ClearInventory()
9093 {
9094 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
9095 {
9096 GameInventory inv = GetInventory();
9097 array<EntityAI> items = new array<EntityAI>;
9098 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
9099 for (int i = 0; i < items.Count(); i++)
9100 {
9101 ItemBase item = ItemBase.Cast(items.Get(i));
9102 if (item)
9103 {
9104 GetGame().ObjectDelete(item);
9105 }
9106 }
9107 }
9108 }
9109
9110 //------------------------- Energy
9111
9112 //----------------------------------------------------------------
9113 float GetEnergy()
9114 {
9115 float energy = 0;
9116 if (HasEnergyManager())
9117 {
9118 energy = GetCompEM().GetEnergy();
9119 }
9120 return energy;
9121 }
9122
9123
9124 override void OnEnergyConsumed()
9125 {
9126 super.OnEnergyConsumed();
9127
9129 }
9130
9131 override void OnEnergyAdded()
9132 {
9133 super.OnEnergyAdded();
9134
9136 }
9137
9138 // Converts energy (from Energy Manager) to quantity, if enabled.
9140 {
9141 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
9142 {
9143 if (HasQuantity())
9144 {
9145 float energy_0to1 = GetCompEM().GetEnergy0To1();
9146 SetQuantityNormalized(energy_0to1);
9147 }
9148 }
9149 }
9150
9151 //----------------------------------------------------------------
9152 float GetHeatIsolationInit()
9153 {
9154 return ConfigGetFloat("heatIsolation");
9155 }
9156
9157 float GetHeatIsolation()
9158 {
9159 return m_HeatIsolation;
9160 }
9161
9162 float GetDryingIncrement(string pIncrementName)
9163 {
9164 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
9165 if (GetGame().ConfigIsExisting(paramPath))
9166 return GetGame().ConfigGetFloat(paramPath);
9167
9168 return 0.0;
9169 }
9170
9171 float GetSoakingIncrement(string pIncrementName)
9172 {
9173 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
9174 if (GetGame().ConfigIsExisting(paramPath))
9175 return GetGame().ConfigGetFloat(paramPath);
9176
9177 return 0.0;
9178 }
9179 //----------------------------------------------------------------
9180 override void SetWet(float value, bool allow_client = false)
9181 {
9182 if (!IsServerCheck(allow_client))
9183 return;
9184
9185 float min = GetWetMin();
9186 float max = GetWetMax();
9187
9188 float previousValue = m_VarWet;
9189
9190 m_VarWet = Math.Clamp(value, min, max);
9191
9192 if (previousValue != m_VarWet)
9193 {
9194 SetVariableMask(VARIABLE_WET);
9195 OnWetChanged(m_VarWet, previousValue);
9196 }
9197 }
9198 //----------------------------------------------------------------
9199 override void AddWet(float value)
9200 {
9201 SetWet(GetWet() + value);
9202 }
9203 //----------------------------------------------------------------
9204 override void SetWetMax()
9205 {
9207 }
9208 //----------------------------------------------------------------
9209 override float GetWet()
9210 {
9211 return m_VarWet;
9212 }
9213 //----------------------------------------------------------------
9214 override float GetWetMax()
9215 {
9216 return m_VarWetMax;
9217 }
9218 //----------------------------------------------------------------
9219 override float GetWetMin()
9220 {
9221 return m_VarWetMin;
9222 }
9223 //----------------------------------------------------------------
9224 override float GetWetInit()
9225 {
9226 return m_VarWetInit;
9227 }
9228 //----------------------------------------------------------------
9229 override void OnWetChanged(float newVal, float oldVal)
9230 {
9231 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
9232 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
9233 if (newLevel != oldLevel)
9234 {
9235 OnWetLevelChanged(newLevel,oldLevel);
9236 }
9237 }
9238
9239 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
9240 {
9241 SetWeightDirty();
9242 }
9243
9244 override EWetnessLevel GetWetLevel()
9245 {
9246 return GetWetLevelInternal(m_VarWet);
9247 }
9248
9249 //----------------------------------------------------------------
9250
9251 override void SetStoreLoad(bool value)
9252 {
9253 m_IsStoreLoad = value;
9254 }
9255
9256 override bool IsStoreLoad()
9257 {
9258 return m_IsStoreLoad;
9259 }
9260
9261 override void SetStoreLoadedQuantity(float value)
9262 {
9263 m_StoreLoadedQuantity = value;
9264 }
9265
9266 override float GetStoreLoadedQuantity()
9267 {
9268 return m_StoreLoadedQuantity;
9269 }
9270
9271 //----------------------------------------------------------------
9272
9273 float GetItemModelLength()
9274 {
9275 if (ConfigIsExisting("itemModelLength"))
9276 {
9277 return ConfigGetFloat("itemModelLength");
9278 }
9279 return 0;
9280 }
9281
9282 float GetItemAttachOffset()
9283 {
9284 if (ConfigIsExisting("itemAttachOffset"))
9285 {
9286 return ConfigGetFloat("itemAttachOffset");
9287 }
9288 return 0;
9289 }
9290
9291 override void SetCleanness(int value, bool allow_client = false)
9292 {
9293 if (!IsServerCheck(allow_client))
9294 return;
9295
9296 int previousValue = m_Cleanness;
9297
9298 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
9299
9300 if (previousValue != m_Cleanness)
9301 SetVariableMask(VARIABLE_CLEANNESS);
9302 }
9303
9304 override int GetCleanness()
9305 {
9306 return m_Cleanness;
9307 }
9308
9310 {
9311 return true;
9312 }
9313
9314 //----------------------------------------------------------------
9315 // ATTACHMENT LOCKING
9316 // Getters relevant to generic ActionLockAttachment
9317 int GetLockType()
9318 {
9319 return m_LockType;
9320 }
9321
9322 string GetLockSoundSet()
9323 {
9324 return m_LockSoundSet;
9325 }
9326
9327 //----------------------------------------------------------------
9328 //------------------------- Color
9329 // sets items color variable given color components
9330 override void SetColor(int r, int g, int b, int a)
9331 {
9336 SetVariableMask(VARIABLE_COLOR);
9337 }
9339 override void GetColor(out int r,out int g,out int b,out int a)
9340 {
9345 }
9346
9347 bool IsColorSet()
9348 {
9349 return IsVariableSet(VARIABLE_COLOR);
9350 }
9351
9353 string GetColorString()
9354 {
9355 int r,g,b,a;
9356 GetColor(r,g,b,a);
9357 r = r/255;
9358 g = g/255;
9359 b = b/255;
9360 a = a/255;
9361 return MiscGameplayFunctions.GetColorString(r, g, b, a);
9362 }
9363 //----------------------------------------------------------------
9364 //------------------------- LiquidType
9365
9366 override void SetLiquidType(int value, bool allow_client = false)
9367 {
9368 if (!IsServerCheck(allow_client))
9369 return;
9370
9371 int old = m_VarLiquidType;
9372 m_VarLiquidType = value;
9373 OnLiquidTypeChanged(old,value);
9374 SetVariableMask(VARIABLE_LIQUIDTYPE);
9375 }
9376
9377 int GetLiquidTypeInit()
9378 {
9379 return ConfigGetInt("varLiquidTypeInit");
9380 }
9381
9382 override int GetLiquidType()
9383 {
9384 return m_VarLiquidType;
9385 }
9386
9387 protected void OnLiquidTypeChanged(int oldType, int newType)
9388 {
9389 if (newType == LIQUID_NONE && GetIsFrozen())
9390 SetFrozen(false);
9391 }
9392
9394 void UpdateQuickbarShortcutVisibility(PlayerBase player)
9395 {
9396 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
9397 }
9398
9399 // -------------------------------------------------------------------------
9401 void OnInventoryEnter(Man player)
9402 {
9403 PlayerBase nplayer;
9404 if (PlayerBase.CastTo(nplayer, player))
9405 {
9406 m_CanPlayImpactSound = true;
9407 //nplayer.OnItemInventoryEnter(this);
9408 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
9409 }
9410 }
9411
9412 // -------------------------------------------------------------------------
9414 void OnInventoryExit(Man player)
9415 {
9416 PlayerBase nplayer;
9417 if (PlayerBase.CastTo(nplayer,player))
9418 {
9419 //nplayer.OnItemInventoryExit(this);
9420 nplayer.SetEnableQuickBarEntityShortcut(this,false);
9421
9422 }
9423
9424 //if (!GetGame().IsDedicatedServer())
9425 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
9426
9427
9428 if (HasEnergyManager())
9429 {
9430 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
9431 }
9432 }
9433
9434 // ADVANCED PLACEMENT EVENTS
9435 override void OnPlacementStarted(Man player)
9436 {
9437 super.OnPlacementStarted(player);
9438
9439 SetTakeable(false);
9440 }
9441
9442 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
9443 {
9444 if (m_AdminLog)
9445 {
9446 m_AdminLog.OnPlacementComplete(player, this);
9447 }
9448
9449 super.OnPlacementComplete(player, position, orientation);
9450 }
9451
9452 //-----------------------------
9453 // AGENT SYSTEM
9454 //-----------------------------
9455 //--------------------------------------------------------------------------
9456 bool ContainsAgent(int agent_id)
9457 {
9458 if (agent_id & m_AttachedAgents)
9459 {
9460 return true;
9461 }
9462 else
9463 {
9464 return false;
9465 }
9466 }
9467
9468 //--------------------------------------------------------------------------
9469 override void RemoveAgent(int agent_id)
9470 {
9471 if (ContainsAgent(agent_id))
9472 {
9473 m_AttachedAgents = ~agent_id & m_AttachedAgents;
9474 }
9475 }
9476
9477 //--------------------------------------------------------------------------
9478 override void RemoveAllAgents()
9479 {
9480 m_AttachedAgents = 0;
9481 }
9482 //--------------------------------------------------------------------------
9483 override void RemoveAllAgentsExcept(int agent_to_keep)
9484 {
9485 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
9486 }
9487 // -------------------------------------------------------------------------
9488 override void InsertAgent(int agent, float count = 1)
9489 {
9490 if (count < 1)
9491 return;
9492 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
9494 }
9495
9497 void TransferAgents(int agents)
9498 {
9500 }
9501
9502 // -------------------------------------------------------------------------
9503 override int GetAgents()
9504 {
9505 return m_AttachedAgents;
9506 }
9507 //----------------------------------------------------------------------
9508
9509 /*int GetContaminationType()
9510 {
9511 int contamination_type;
9512
9513 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
9514 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
9515 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
9516 const int DIRTY_MASK = eAgents.WOUND_AGENT;
9517
9518 Edible_Base edible = Edible_Base.Cast(this);
9519 int agents = GetAgents();
9520 if (edible)
9521 {
9522 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
9523 if (profile)
9524 {
9525 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
9526 }
9527 }
9528 if (agents & CONTAMINATED_MASK)
9529 {
9530 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
9531 }
9532 if (agents & POISONED_MASK)
9533 {
9534 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
9535 }
9536 if (agents & NERVE_GAS_MASK)
9537 {
9538 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
9539 }
9540 if (agents & DIRTY_MASK)
9541 {
9542 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
9543 }
9544
9545 return agents;
9546 }*/
9547
9548 // -------------------------------------------------------------------------
9549 bool LoadAgents(ParamsReadContext ctx, int version)
9550 {
9551 if (!ctx.Read(m_AttachedAgents))
9552 return false;
9553 return true;
9554 }
9555 // -------------------------------------------------------------------------
9557 {
9558
9560 }
9561 // -------------------------------------------------------------------------
9562
9564 override void CheckForRoofLimited(float timeTresholdMS = 3000)
9565 {
9566 super.CheckForRoofLimited(timeTresholdMS);
9567
9568 float time = GetGame().GetTime();
9569 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
9570 {
9571 m_PreviousRoofTestTime = time;
9572 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
9573 }
9574 }
9575
9576 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
9577 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
9578 {
9579 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
9580 {
9581 return 0;
9582 }
9583
9584 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
9585 {
9586 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
9587 if (filter)
9588 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
9589 else
9590 return 0;//otherwise return 0 when no filter attached
9591 }
9592
9593 string subclassPath, entryName;
9594
9595 switch (type)
9596 {
9597 case DEF_BIOLOGICAL:
9598 entryName = "biological";
9599 break;
9600 case DEF_CHEMICAL:
9601 entryName = "chemical";
9602 break;
9603 default:
9604 entryName = "biological";
9605 break;
9606 }
9607
9608 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
9609
9610 return GetGame().ConfigGetFloat(subclassPath + entryName);
9611 }
9612
9613
9614
9616 override void EEOnCECreate()
9617 {
9618 if (!IsMagazine())
9620
9622 }
9623
9624
9625 //-------------------------
9626 // OPEN/CLOSE USER ACTIONS
9627 //-------------------------
9629 void Open();
9630 void Close();
9631 bool IsOpen()
9632 {
9633 return true;
9634 }
9635
9636 override bool CanDisplayCargo()
9637 {
9638 return IsOpen();
9639 }
9640
9641
9642 // ------------------------------------------------------------
9643 // CONDITIONS
9644 // ------------------------------------------------------------
9645 override bool CanPutInCargo(EntityAI parent)
9646 {
9647 if (parent)
9648 {
9649 if (parent.IsInherited(DayZInfected))
9650 return true;
9651
9652 if (!parent.IsRuined())
9653 return true;
9654 }
9655
9656 return true;
9657 }
9658
9659 override bool CanPutAsAttachment(EntityAI parent)
9660 {
9661 if (!super.CanPutAsAttachment(parent))
9662 {
9663 return false;
9664 }
9665
9666 if (!IsRuined() && !parent.IsRuined())
9667 {
9668 return true;
9669 }
9670
9671 return false;
9672 }
9673
9674 override bool CanReceiveItemIntoCargo(EntityAI item)
9675 {
9676 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9677 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9678 // return false;
9679
9680 return super.CanReceiveItemIntoCargo(item);
9681 }
9682
9683 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
9684 {
9685 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9686 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9687 // return false;
9688
9689 GameInventory attachmentInv = attachment.GetInventory();
9690 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
9691 {
9692 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
9693 return false;
9694 }
9695
9696 InventoryLocation loc = new InventoryLocation();
9697 attachment.GetInventory().GetCurrentInventoryLocation(loc);
9698 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
9699 return false;
9700
9701 return super.CanReceiveAttachment(attachment, slotId);
9702 }
9703
9704 override bool CanReleaseAttachment(EntityAI attachment)
9705 {
9706 if (!super.CanReleaseAttachment(attachment))
9707 return false;
9708
9709 return GetInventory().AreChildrenAccessible();
9710 }
9711
9712 /*override bool CanLoadAttachment(EntityAI attachment)
9713 {
9714 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9715 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9716 // return false;
9717
9718 GameInventory attachmentInv = attachment.GetInventory();
9719 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
9720 {
9721 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
9722 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
9723
9724 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
9725 return false;
9726 }
9727
9728 return super.CanLoadAttachment(attachment);
9729 }*/
9730
9731 // Plays muzzle flash particle effects
9732 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9733 {
9734 int id = muzzle_owner.GetMuzzleID();
9735 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
9736
9737 if (WPOF_array)
9738 {
9739 for (int i = 0; i < WPOF_array.Count(); i++)
9740 {
9741 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
9742
9743 if (WPOF)
9744 {
9745 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
9746 }
9747 }
9748 }
9749 }
9750
9751 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
9752 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9753 {
9754 int id = muzzle_owner.GetMuzzleID();
9755 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
9756
9757 if (WPOBE_array)
9758 {
9759 for (int i = 0; i < WPOBE_array.Count(); i++)
9760 {
9761 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
9762
9763 if (WPOBE)
9764 {
9765 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
9766 }
9767 }
9768 }
9769 }
9770
9771 // Plays all weapon overheating particles
9772 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9773 {
9774 int id = muzzle_owner.GetMuzzleID();
9775 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
9776
9777 if (WPOOH_array)
9778 {
9779 for (int i = 0; i < WPOOH_array.Count(); i++)
9780 {
9781 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
9782
9783 if (WPOOH)
9784 {
9785 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
9786 }
9787 }
9788 }
9789 }
9790
9791 // Updates all weapon overheating particles
9792 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9793 {
9794 int id = muzzle_owner.GetMuzzleID();
9795 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
9796
9797 if (WPOOH_array)
9798 {
9799 for (int i = 0; i < WPOOH_array.Count(); i++)
9800 {
9801 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
9802
9803 if (WPOOH)
9804 {
9805 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9806 }
9807 }
9808 }
9809 }
9810
9811 // Stops overheating particles
9812 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9813 {
9814 int id = muzzle_owner.GetMuzzleID();
9815 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
9816
9817 if (WPOOH_array)
9818 {
9819 for (int i = 0; i < WPOOH_array.Count(); i++)
9820 {
9821 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
9822
9823 if (WPOOH)
9824 {
9825 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9826 }
9827 }
9828 }
9829 }
9830
9831 //----------------------------------------------------------------
9832 //Item Behaviour - unified approach
9833 override bool IsHeavyBehaviour()
9834 {
9835 if (m_ItemBehaviour == 0)
9836 {
9837 return true;
9838 }
9839
9840 return false;
9841 }
9842
9843 override bool IsOneHandedBehaviour()
9844 {
9845 if (m_ItemBehaviour == 1)
9846 {
9847 return true;
9848 }
9849
9850 return false;
9851 }
9852
9853 override bool IsTwoHandedBehaviour()
9854 {
9855 if (m_ItemBehaviour == 2)
9856 {
9857 return true;
9858 }
9859
9860 return false;
9861 }
9862
9863 bool IsDeployable()
9864 {
9865 return false;
9866 }
9867
9869 float GetDeployTime()
9870 {
9871 return UATimeSpent.DEFAULT_DEPLOY;
9872 }
9873
9874
9875 //----------------------------------------------------------------
9876 // Item Targeting (User Actions)
9877 override void SetTakeable(bool pState)
9878 {
9879 m_IsTakeable = pState;
9880 SetSynchDirty();
9881 }
9882
9883 override bool IsTakeable()
9884 {
9885 return m_IsTakeable;
9886 }
9887
9888 // For cases where we want to show object widget which cant be taken to hands
9890 {
9891 return false;
9892 }
9893
9895 protected void PreLoadSoundAttachmentType()
9896 {
9897 string att_type = "None";
9898
9899 if (ConfigIsExisting("soundAttType"))
9900 {
9901 att_type = ConfigGetString("soundAttType");
9902 }
9903
9904 m_SoundAttType = att_type;
9905 }
9906
9907 override string GetAttachmentSoundType()
9908 {
9909 return m_SoundAttType;
9910 }
9911
9912 //----------------------------------------------------------------
9913 //SOUNDS - ItemSoundHandler
9914 //----------------------------------------------------------------
9915
9916 string GetPlaceSoundset(); // played when deploy starts
9917 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
9918 string GetDeploySoundset(); // played when deploy sucessfully finishes
9919 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
9920 string GetFoldSoundset(); // played when fold sucessfully finishes
9921
9923 {
9924 if (!m_ItemSoundHandler)
9926
9927 return m_ItemSoundHandler;
9928 }
9929
9930 // override to initialize sounds
9931 protected void InitItemSounds()
9932 {
9933 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
9934 return;
9935
9937
9938 if (GetPlaceSoundset() != string.Empty)
9939 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
9940
9941 if (GetDeploySoundset() != string.Empty)
9942 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
9943
9944 SoundParameters params = new SoundParameters();
9945 params.m_Loop = true;
9946 if (GetLoopDeploySoundset() != string.Empty)
9947 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
9948 }
9949
9950 // Start sound using ItemSoundHandler
9951 void StartItemSoundServer(int id)
9952 {
9953 if (!GetGame().IsServer())
9954 return;
9955
9956 m_SoundSyncPlay = id;
9957 SetSynchDirty();
9958
9959 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
9961 }
9962
9963 // Stop sound using ItemSoundHandler
9964 void StopItemSoundServer(int id)
9965 {
9966 if (!GetGame().IsServer())
9967 return;
9968
9969 m_SoundSyncStop = id;
9970 SetSynchDirty();
9971
9972 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
9974 }
9975
9976 protected void ClearStartItemSoundServer()
9977 {
9978 m_SoundSyncPlay = 0;
9979 }
9980
9981 protected void ClearStopItemSoundServer()
9982 {
9983 m_SoundSyncStop = 0;
9984 }
9985
9987 void PlayAttachSound(string slot_type)
9988 {
9989 if (!GetGame().IsDedicatedServer())
9990 {
9991 if (ConfigIsExisting("attachSoundSet"))
9992 {
9993 string cfg_path = "";
9994 string soundset = "";
9995 string type_name = GetType();
9996
9997 TStringArray cfg_soundset_array = new TStringArray;
9998 TStringArray cfg_slot_array = new TStringArray;
9999 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
10000 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
10001
10002 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
10003 {
10004 for (int i = 0; i < cfg_soundset_array.Count(); i++)
10005 {
10006 if (cfg_slot_array[i] == slot_type)
10007 {
10008 soundset = cfg_soundset_array[i];
10009 break;
10010 }
10011 }
10012 }
10013
10014 if (soundset != "")
10015 {
10016 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
10017 sound.SetAutodestroy(true);
10018 }
10019 }
10020 }
10021 }
10022
10023 void PlayDetachSound(string slot_type)
10024 {
10025 //TODO - evaluate if needed and devise universal config structure if so
10026 }
10027
10028 void OnApply(PlayerBase player);
10029
10031 {
10032 return 1.0;
10033 };
10034 //returns applicable selection
10035 array<string> GetHeadHidingSelection()
10036 {
10038 }
10039
10041 {
10043 }
10044
10045 WrittenNoteData GetWrittenNoteData() {};
10046
10048 {
10049 SetDynamicPhysicsLifeTime(0.01);
10050 m_ItemBeingDroppedPhys = false;
10051 }
10052
10054 {
10055 array<string> zone_names = new array<string>;
10056 GetDamageZones(zone_names);
10057 for (int i = 0; i < zone_names.Count(); i++)
10058 {
10059 SetHealthMax(zone_names.Get(i),"Health");
10060 }
10061 SetHealthMax("","Health");
10062 }
10063
10065 void SetZoneDamageCEInit()
10066 {
10067 float global_health = GetHealth01("","Health");
10068 array<string> zones = new array<string>;
10069 GetDamageZones(zones);
10070 //set damage of all zones to match global health level
10071 for (int i = 0; i < zones.Count(); i++)
10072 {
10073 SetHealth01(zones.Get(i),"Health",global_health);
10074 }
10075 }
10076
10078 bool IsCoverFaceForShave(string slot_name)
10079 {
10080 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
10081 }
10082
10083 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10084 {
10085 if (!hasRootAsPlayer)
10086 {
10087 if (refParentIB)
10088 {
10089 // parent is wet
10090 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
10091 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
10092 // parent has liquid inside
10093 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
10094 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
10095 // drying
10096 else if (m_VarWet > m_VarWetMin)
10097 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
10098 }
10099 else
10100 {
10101 // drying on ground or inside non-itembase (car, ...)
10102 if (m_VarWet > m_VarWetMin)
10103 AddWet(-1 * delta * GetDryingIncrement("ground"));
10104 }
10105 }
10106 }
10107
10108 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10109 {
10111 {
10112 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
10113 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
10114 {
10115 float heatPermCoef = 1.0;
10116 EntityAI ent = this;
10117 while (ent)
10118 {
10119 heatPermCoef *= ent.GetHeatPermeabilityCoef();
10120 ent = ent.GetHierarchyParent();
10121 }
10122
10123 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
10124 }
10125 }
10126 }
10127
10128 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
10129 {
10130 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
10131 EntityAI parent = GetHierarchyParent();
10132 if (!parent)
10133 {
10134 hasParent = false;
10135 hasRootAsPlayer = false;
10136 }
10137 else
10138 {
10139 hasParent = true;
10140 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
10141 refParentIB = ItemBase.Cast(parent);
10142 }
10143 }
10144
10145 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
10146 {
10147 // this is stub, implemented on Edible_Base
10148 }
10149
10150 bool CanDecay()
10151 {
10152 // return true used on selected food clases so they can decay
10153 return false;
10154 }
10155
10156 protected bool CanProcessDecay()
10157 {
10158 // this is stub, implemented on Edible_Base class
10159 // used to determine whether it is still necessary for the food to decay
10160 return false;
10161 }
10162
10163 protected bool CanHaveWetness()
10164 {
10165 // return true used on selected items that have a wetness effect
10166 return false;
10167 }
10168
10170 bool CanBeConsumed(ConsumeConditionData data = null)
10171 {
10172 return !GetIsFrozen() && IsOpen();
10173 }
10174
10175 override void ProcessVariables()
10176 {
10177 bool hasParent = false, hasRootAsPlayer = false;
10178 ItemBase refParentIB;
10179
10180 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
10181 bool foodDecay = g_Game.IsFoodDecayEnabled();
10182
10183 if (wwtu || foodDecay)
10184 {
10185 bool processWetness = wwtu && CanHaveWetness();
10186 bool processTemperature = wwtu && CanHaveTemperature();
10187 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
10188
10189 if (processWetness || processTemperature || processDecay)
10190 {
10191 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
10192
10193 if (processWetness)
10194 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10195
10196 if (processTemperature)
10197 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10198
10199 if (processDecay)
10200 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
10201 }
10202 }
10203 }
10204
10207 {
10208 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
10209 }
10210
10211 override float GetTemperatureFreezeThreshold()
10212 {
10214 return Liquid.GetFreezeThreshold(GetLiquidType());
10215
10216 return super.GetTemperatureFreezeThreshold();
10217 }
10218
10219 override float GetTemperatureThawThreshold()
10220 {
10222 return Liquid.GetThawThreshold(GetLiquidType());
10223
10224 return super.GetTemperatureThawThreshold();
10225 }
10226
10227 override float GetItemOverheatThreshold()
10228 {
10230 return Liquid.GetBoilThreshold(GetLiquidType());
10231
10232 return super.GetItemOverheatThreshold();
10233 }
10234
10235 override float GetTemperatureFreezeTime()
10236 {
10237 if (HasQuantity())
10238 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
10239
10240 return super.GetTemperatureFreezeTime();
10241 }
10242
10243 override float GetTemperatureThawTime()
10244 {
10245 if (HasQuantity())
10246 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
10247
10248 return super.GetTemperatureThawTime();
10249 }
10250
10252 void AffectLiquidContainerOnFill(int liquid_type, float amount);
10254 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
10255
10256 bool IsCargoException4x3(EntityAI item)
10257 {
10258 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
10259 }
10260
10262 {
10263 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
10264 }
10265
10267 void AddLightSourceItem(ItemBase lightsource)
10268 {
10269 m_LightSourceItem = lightsource;
10270 }
10271
10273 {
10274 m_LightSourceItem = null;
10275 }
10276
10278 {
10279 return m_LightSourceItem;
10280 }
10281
10283 array<int> GetValidFinishers()
10284 {
10285 return null;
10286 }
10287
10289 bool GetActionWidgetOverride(out typename name)
10290 {
10291 return false;
10292 }
10293
10294 bool PairWithDevice(notnull ItemBase otherDevice)
10295 {
10296 if (GetGame().IsServer())
10297 {
10298 ItemBase explosive = otherDevice;
10300 if (!trg)
10301 {
10302 trg = RemoteDetonatorTrigger.Cast(otherDevice);
10303 explosive = this;
10304 }
10305
10306 explosive.PairRemote(trg);
10307 trg.SetControlledDevice(explosive);
10308
10309 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
10310 trg.SetPersistentPairID(persistentID);
10311 explosive.SetPersistentPairID(persistentID);
10312
10313 return true;
10314 }
10315 return false;
10316 }
10317
10319 float GetBaitEffectivity()
10320 {
10321 float ret = 1.0;
10322 if (HasQuantity())
10323 ret *= GetQuantityNormalized();
10324 ret *= GetHealth01();
10325
10326 return ret;
10327 }
10328
10329 #ifdef DEVELOPER
10330 override void SetDebugItem()
10331 {
10332 super.SetDebugItem();
10333 _itemBase = this;
10334 }
10335
10336 override string GetDebugText()
10337 {
10338 string text = super.GetDebugText();
10339
10340 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
10341 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
10342
10343 return text;
10344 }
10345 #endif
10346
10347 bool CanBeUsedForSuicide()
10348 {
10349 return true;
10350 }
10351
10353 //DEPRECATED BELOW
10355 // Backwards compatibility
10356 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10357 {
10358 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
10359 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
10360 }
10361
10362 // replaced by ItemSoundHandler
10363 protected EffectSound m_SoundDeployFinish;
10364 protected EffectSound m_SoundPlace;
10365 protected EffectSound m_DeployLoopSoundEx;
10366 protected EffectSound m_SoundDeploy;
10367 bool m_IsPlaceSound;
10368 bool m_IsDeploySound;
10370
10371 string GetDeployFinishSoundset();
10372 void PlayDeploySound();
10373 void PlayDeployFinishSound();
10374 void PlayPlaceSound();
10375 void PlayDeployLoopSoundEx();
10376 void StopDeployLoopSoundEx();
10377 void SoundSynchRemoteReset();
10378 void SoundSynchRemote();
10379 bool UsesGlobalDeploy(){return false;}
10380 bool CanPlayDeployLoopSound(){return false;}
10382 bool IsPlaceSound(){return m_IsPlaceSound;}
10383 bool IsDeploySound(){return m_IsDeploySound;}
10384 void SetIsPlaceSound(bool is_place_sound);
10385 void SetIsDeploySound(bool is_deploy_sound);
10386}
10387
10388EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
10389{
10390 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
10391 if (entity)
10392 {
10393 bool is_item = entity.IsInherited(ItemBase);
10394 if (is_item && full_quantity)
10395 {
10396 ItemBase item = ItemBase.Cast(entity);
10397 item.SetQuantity(item.GetQuantityInit());
10398 }
10399 }
10400 else
10401 {
10402 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
10403 return NULL;
10404 }
10405 return entity;
10406}
10407
10408void SetupSpawnedItem(ItemBase item, float health, float quantity)
10409{
10410 if (item)
10411 {
10412 if (health > 0)
10413 item.SetHealth("", "", health);
10414
10415 if (item.CanHaveTemperature())
10416 {
10417 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
10418 if (item.CanFreeze())
10419 item.SetFrozen(false);
10420 }
10421
10422 if (item.HasEnergyManager())
10423 {
10424 if (quantity >= 0)
10425 {
10426 item.GetCompEM().SetEnergy0To1(quantity);
10427 }
10428 else
10429 {
10430 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
10431 }
10432 }
10433 else if (item.IsMagazine())
10434 {
10435 Magazine mag = Magazine.Cast(item);
10436 if (quantity >= 0)
10437 {
10438 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
10439 }
10440 else
10441 {
10442 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
10443 }
10444
10445 }
10446 else
10447 {
10448 if (quantity >= 0)
10449 {
10450 item.SetQuantityNormalized(quantity, false);
10451 }
10452 else
10453 {
10454 item.SetQuantity(Math.AbsFloat(quantity));
10455 }
10456
10457 }
10458 }
10459}
10460
10461#ifdef DEVELOPER
10462ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
10463#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()