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

◆ SplitIntoStackMaxHandsClient()

void SpawnItemOnLocation::SplitIntoStackMaxHandsClient ( PlayerBase player)
protected

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

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