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

◆ SplitItemToInventoryLocation()

void SpawnItemOnLocation::SplitItemToInventoryLocation ( notnull InventoryLocation dst)
protected

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

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