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

◆ SplitIntoStackMaxEx()

override void SpawnItemOnLocation::SplitIntoStackMaxEx ( EntityAI destination_entity,
int slot_id )
protected

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

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