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

◆ SplitIntoStackMaxToInventoryLocationClient()

void SpawnItemOnLocation::SplitIntoStackMaxToInventoryLocationClient ( notnull InventoryLocation dst)
protected

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

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