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

◆ SplitIntoStackMaxCargoClient()

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

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

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