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

◆ OnAction()

override bool SpawnItemOnLocation::OnAction ( int action_id,
Man player,
ParamsReadContext ctx )
protected

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

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