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

◆ GetExplosiveTriggerSlotName()

string SpawnItemOnLocation::GetExplosiveTriggerSlotName ( )
private

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

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