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

◆ IsSplitable()

override bool SpawnItemOnLocation::IsSplitable ( )
private

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

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

Используется в InventoryItem::CanBeSplit(), InventoryItem::GetTargetQuantityMax(), InventoryItem::GetUnitWeight(), InventoryItem::GetWeightSpecialized(), InventoryItem::OnVariablesSynchronized() и InventoryItem::ShouldSplitQuantity().