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

◆ CanObstruct()

override bool SpawnItemOnLocation::CanObstruct ( )
private

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

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