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

◆ ComputeQuantityUsed()

int SpawnItemOnLocation::ComputeQuantityUsed ( ItemBase other_item,
bool use_stack_max = true )
protected

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

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

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