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

◆ SplitItemToInventoryLocation()

void SpawnItemOnLocation::SplitItemToInventoryLocation ( notnull InventoryLocation dst)
protected

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

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