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

◆ LockToParent()

void SpawnItemOnLocation::LockToParent ( )
private

Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible in inventory over this item.

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

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