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

◆ OnMovedInsideCargo()

override void SpawnItemOnLocation::OnMovedInsideCargo ( EntityAI container)
private

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

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