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

◆ IsHologram()

override bool SpawnItemOnLocation::IsHologram ( )
private

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

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

Используется в ItemBase::AssembleKit(), IEntity::CanBeActionTarget(), Entity::CanPutAsAttachment(), Entity::CanPutInCargo(), Entity::CanPutIntoHands(), KitBase::DisassembleKit(), ItemBase::EOnInit(), ItemBase::Pack(), RefreshFireplaceVisuals() и ItemBase::UpdateAllSelections().