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

◆ SplitIntoStackMaxCargoClient()

void SpawnItemOnLocation::SplitIntoStackMaxCargoClient ( EntityAI destination_entity,
int idx,
int row,
int col )
protected

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

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