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

◆ EOnContact()

override void SpawnItemOnLocation::EOnContact ( IEntity other,
Contact extra )
private

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

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