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

◆ CanBeSplit()

override bool SpawnItemOnLocation::CanBeSplit ( )
private

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

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