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

◆ GetMuzzleID()

int SpawnItemOnLocation::GetMuzzleID ( )
private

Returns global muzzle ID. If not found, then it gets automatically registered.

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

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

Используется в InventoryItem::ItemBase().