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

◆ IsNVG()

bool SpawnItemOnLocation::IsNVG ( )
private

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

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