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

◆ SetInventoryLocationToVicinityOrCurrent()

void SpawnItemOnLocation::SetInventoryLocationToVicinityOrCurrent ( EntityAI root,
inout InventoryLocation dst )
protected

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

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

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