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

◆ IsFacingPlayer()

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

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

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