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

◆ CanBeCombined()

override bool SpawnItemOnLocation::CanBeCombined ( EntityAI other_item,
bool reservation_check = true,
bool stack_max_limit = false )
protected

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

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