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

◆ ToggleDebugActionsMask()

static void SpawnItemOnLocation::ToggleDebugActionsMask ( int mask)
staticprivate

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

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