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

◆ EEDelete()

override void SpawnItemOnLocation::EEDelete ( EntityAI parent)
private

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

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