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

◆ SplitIntoStackMaxHands()

void SpawnItemOnLocation::SplitIntoStackMaxHands ( PlayerBase player)
protected

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

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

Используется в InventoryItem::SplitIntoStackMaxHandsClient().