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

◆ SplitIntoStackMaxEx()

override void SpawnItemOnLocation::SplitIntoStackMaxEx ( EntityAI destination_entity,
int slot_id )
protected

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

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