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

◆ SplitIntoStackMax()

void SpawnItemOnLocation::SplitIntoStackMax ( EntityAI destination_entity,
int slot_id,
PlayerBase player )
protected

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

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

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