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

◆ GetLiquidContainerMask()

int SpawnItemOnLocation::GetLiquidContainerMask ( )
private

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

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