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

◆ IsPlayerInside()

bool SpawnItemOnLocation::IsPlayerInside ( PlayerBase player,
string selection )
private

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

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