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

◆ DamageItemInCargo()

bool SpawnItemOnLocation::DamageItemInCargo ( float damage)
private

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

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

Используется в InventoryItem::EEHitBy().