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

◆ SplitIntoStackMaxClient()

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

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

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