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

◆ GetMuzzleID()

int SpawnItemOnLocation::GetMuzzleID ( )
private

Returns global muzzle ID. If not found, then it gets automatically registered.

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

5614{
5615 override bool CanPutAsAttachment(EntityAI parent)
5616 {
5617 return true;
5618 }
5619};
5620
5622{
5623
5624};
5625
5626//const bool QUANTITY_DEBUG_REMOVE_ME = false;
5627
5628class ItemBase extends InventoryItem
5629{
5633
5635
5636 static int m_DebugActionsMask;
5638 // ============================================
5639 // Variable Manipulation System
5640 // ============================================
5641 // Quantity
5642
5643 float m_VarQuantity;
5644 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
5646 int m_VarQuantityMin;
5647 int m_VarQuantityMax;
5648 int m_Count;
5649 float m_VarStackMax;
5650 float m_StoreLoadedQuantity = float.LOWEST;
5651 // Wet
5652 float m_VarWet;
5653 float m_VarWetPrev;//for client to know wetness changed during synchronization
5654 float m_VarWetInit;
5655 float m_VarWetMin;
5656 float m_VarWetMax;
5657 // Cleanness
5658 int m_Cleanness;
5659 int m_CleannessInit;
5660 int m_CleannessMin;
5661 int m_CleannessMax;
5662 // impact sounds
5664 bool m_CanPlayImpactSound = true;
5665 float m_ImpactSpeed;
5667 //
5668 float m_HeatIsolation;
5669 float m_ItemModelLength;
5670 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
5672 int m_VarLiquidType;
5673 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
5674 int m_QuickBarBonus;
5675 bool m_IsBeingPlaced;
5676 bool m_IsHologram;
5677 bool m_IsTakeable;
5678 bool m_ThrowItemOnDrop;
5681 bool m_FixDamageSystemInit = false; //can be changed on storage version check
5682 bool can_this_be_combined; //Check if item can be combined
5683 bool m_CanThisBeSplit; //Check if item can be split
5684 bool m_IsStoreLoad = false;
5685 bool m_CanShowQuantity;
5686 bool m_HasQuantityBar;
5687 protected bool m_CanBeDigged;
5688 protected bool m_IsResultOfSplit
5689
5690 string m_SoundAttType;
5691 // items color variables
5696 //-------------------------------------------------------
5697
5698 // light source managing
5700
5704
5705 //==============================================
5706 // agent system
5707 private int m_AttachedAgents;
5708
5710 void TransferModifiers(PlayerBase reciever);
5711
5712
5713 // Weapons & suppressors particle effects
5717 ref static map<string, int> m_WeaponTypeToID;
5718 static int m_LastRegisteredWeaponID = 0;
5719
5720 // Overheating effects
5722 float m_OverheatingShots;
5723 ref Timer m_CheckOverheating;
5724 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
5725 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
5726 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
5727 ref array <ref OverheatingParticle> m_OverheatingParticles;
5728
5730 protected bool m_HideSelectionsBySlot;
5731
5732 // Admin Log
5733 PluginAdminLog m_AdminLog;
5734
5735 // misc
5736 ref Timer m_PhysDropTimer;
5737
5738 // Attachment Locking variables
5739 ref array<int> m_CompatibleLocks;
5740 protected int m_LockType;
5741 protected ref EffectSound m_LockingSound;
5742 protected string m_LockSoundSet;
5743
5744 // ItemSoundHandler variables
5745 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
5746 protected int m_SoundSyncPlay; // id for sound to play
5747 protected int m_SoundSyncStop; // id for sound to stop
5748 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
5749
5751
5752 //temperature
5753 private float m_TemperaturePerQuantityWeight;
5754
5755 // -------------------------------------------------------------------------
5756 void ItemBase()
5757 {
5758 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
5762
5763 if (!g_Game.IsDedicatedServer())
5764 {
5765 if (HasMuzzle())
5766 {
5768
5770 {
5772 }
5773 }
5774
5776 m_ActionsInitialize = false;
5777 }
5778
5779 m_OldLocation = null;
5780
5781 if (g_Game.IsServer())
5782 {
5783 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
5784 }
5785
5786 if (ConfigIsExisting("headSelectionsToHide"))
5787 {
5789 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
5790 }
5791
5792 m_HideSelectionsBySlot = false;
5793 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
5794 {
5795 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
5796 }
5797
5798 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
5799
5800 m_IsResultOfSplit = false;
5801
5803 }
5804
5805 override void InitItemVariables()
5806 {
5807 super.InitItemVariables();
5808
5809 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
5810 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
5811 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
5812 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
5813 m_VarStackMax = ConfigGetFloat("varStackMax");
5814 m_Count = ConfigGetInt("count");
5815
5816 m_CanShowQuantity = ConfigGetBool("quantityShow");
5817 m_HasQuantityBar = ConfigGetBool("quantityBar");
5818
5819 m_CleannessInit = ConfigGetInt("varCleannessInit");
5821 m_CleannessMin = ConfigGetInt("varCleannessMin");
5822 m_CleannessMax = ConfigGetInt("varCleannessMax");
5823
5824 m_WantPlayImpactSound = false;
5825 m_ImpactSpeed = 0.0;
5826
5827 m_VarWetInit = ConfigGetFloat("varWetInit");
5829 m_VarWetMin = ConfigGetFloat("varWetMin");
5830 m_VarWetMax = ConfigGetFloat("varWetMax");
5831
5832 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
5833 if (IsLiquidContainer() && GetQuantity() != 0)
5835 m_IsBeingPlaced = false;
5836 m_IsHologram = false;
5837 m_IsTakeable = true;
5838 m_CanBeMovedOverride = false;
5842 m_CanBeDigged = ConfigGetBool("canBeDigged");
5843
5844 m_CompatibleLocks = new array<int>();
5845 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
5846 m_LockType = ConfigGetInt("lockType");
5847
5848 //Define if item can be split and set ability to be combined accordingly
5849 m_CanThisBeSplit = false;
5850 can_this_be_combined = false;
5851 if (ConfigIsExisting("canBeSplit"))
5852 {
5853 can_this_be_combined = ConfigGetBool("canBeSplit");
5855 }
5856
5857 m_ItemBehaviour = -1;
5858 if (ConfigIsExisting("itemBehaviour"))
5859 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
5860
5861 //RegisterNetSyncVariableInt("m_VariablesMask");
5862 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
5863 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
5864 RegisterNetSyncVariableInt("m_VarLiquidType");
5865 RegisterNetSyncVariableInt("m_Cleanness",0,1);
5866
5867 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
5868 RegisterNetSyncVariableFloat("m_ImpactSpeed");
5869 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
5870
5871 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
5872 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
5873 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
5874 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
5875
5876 RegisterNetSyncVariableBool("m_IsBeingPlaced");
5877 RegisterNetSyncVariableBool("m_IsTakeable");
5878 RegisterNetSyncVariableBool("m_IsHologram");
5879
5882 {
5883 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
5884 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
5885 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
5886 }
5887
5888 m_LockSoundSet = ConfigGetString("lockSoundSet");
5889
5891 if (ConfigIsExisting("temperaturePerQuantityWeight"))
5892 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
5893
5894 m_SoundSyncSlotID = -1;
5895 }
5896
5897 override int GetQuickBarBonus()
5898 {
5899 return m_QuickBarBonus;
5900 }
5901
5902 void InitializeActions()
5903 {
5905 if (!m_InputActionMap)
5906 {
5908 m_InputActionMap = iam;
5909 SetActions();
5911 }
5912 }
5913
5914 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
5915 {
5917 {
5918 m_ActionsInitialize = true;
5920 }
5921
5922 actions = m_InputActionMap.Get(action_input_type);
5923 }
5924
5925 void SetActions()
5926 {
5927 AddAction(ActionTakeItem);
5928 AddAction(ActionTakeItemToHands);
5929 AddAction(ActionWorldCraft);
5931 AddAction(ActionAttachWithSwitch);
5932 }
5933
5934 void SetActionAnimOverrides(); // Override action animation for specific item
5935
5936 void AddAction(typename actionName)
5937 {
5938 ActionBase action = ActionManagerBase.GetAction(actionName);
5939
5940 if (!action)
5941 {
5942 Debug.LogError("Action " + actionName + " dosn't exist!");
5943 return;
5944 }
5945
5946 typename ai = action.GetInputType();
5947 if (!ai)
5948 {
5949 m_ActionsInitialize = false;
5950 return;
5951 }
5952
5953 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
5954 if (!action_array)
5955 {
5956 action_array = new array<ActionBase_Basic>;
5957 m_InputActionMap.Insert(ai, action_array);
5958 }
5959 if (LogManager.IsActionLogEnable())
5960 {
5961 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
5962 }
5963
5964 if (action_array.Find(action) != -1)
5965 {
5966 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
5967 }
5968 else
5969 {
5970 action_array.Insert(action);
5971 }
5972 }
5973
5974 void RemoveAction(typename actionName)
5975 {
5976 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
5977 ActionBase action = player.GetActionManager().GetAction(actionName);
5978 typename ai = action.GetInputType();
5979 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
5980
5981 if (action_array)
5982 {
5983 action_array.RemoveItem(action);
5984 }
5985 }
5986
5987 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
5988 // Set -1 for params which should stay in default state
5989 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
5990 {
5991 ActionOverrideData overrideData = new ActionOverrideData();
5992 overrideData.m_CommandUID = commandUID;
5993 overrideData.m_CommandUIDProne = commandUIDProne;
5994 overrideData.m_StanceMask = stanceMask;
5995
5996 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
5997 if (!actionMap) // create new map of action > overidables map
5998 {
5999 actionMap = new TActionAnimOverrideMap();
6000 m_ItemActionOverrides.Insert(action, actionMap);
6001 }
6002
6003 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
6004
6005 }
6006
6007 void OnItemInHandsPlayerSwimStart(PlayerBase player);
6008
6009 ScriptedLightBase GetLight();
6010
6011 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
6012 void LoadParticleConfigOnFire(int id)
6013 {
6014 if (!m_OnFireEffect)
6016
6019
6020 string config_to_search = "CfgVehicles";
6021 string muzzle_owner_config;
6022
6023 if (!m_OnFireEffect.Contains(id))
6024 {
6025 if (IsInherited(Weapon))
6026 config_to_search = "CfgWeapons";
6027
6028 muzzle_owner_config = config_to_search + " " + GetType() + " ";
6029
6030 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
6031
6032 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
6033
6034 if (config_OnFire_subclass_count > 0)
6035 {
6036 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
6037
6038 for (int i = 0; i < config_OnFire_subclass_count; i++)
6039 {
6040 string particle_class = "";
6041 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
6042 string config_OnFire_entry = config_OnFire_class + particle_class;
6043 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
6044 WPOF_array.Insert(WPOF);
6045 }
6046
6047
6048 m_OnFireEffect.Insert(id, WPOF_array);
6049 }
6050 }
6051
6052 if (!m_OnBulletCasingEjectEffect.Contains(id))
6053 {
6054 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
6055 muzzle_owner_config = config_to_search + " " + GetType() + " ";
6056
6057 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
6058
6059 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
6060
6061 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
6062 {
6063 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
6064
6065 for (i = 0; i < config_OnBulletCasingEject_count; i++)
6066 {
6067 string particle_class2 = "";
6068 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
6069 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
6070 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
6071 WPOBE_array.Insert(WPOBE);
6072 }
6073
6074
6075 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
6076 }
6077 }
6078 }
6079
6080 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
6082 {
6085
6086 if (!m_OnOverheatingEffect.Contains(id))
6087 {
6088 string config_to_search = "CfgVehicles";
6089
6090 if (IsInherited(Weapon))
6091 config_to_search = "CfgWeapons";
6092
6093 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
6094 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
6095
6096 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
6097 {
6098
6099 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
6100
6102 {
6103 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
6104 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
6105 Error(error);
6106 return;
6107 }
6108
6109 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
6110 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
6111
6112
6113
6114 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
6115 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
6116
6117 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
6118 {
6119 string particle_class = "";
6120 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
6121 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
6122 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
6123
6124 if (entry_type == CT_CLASS)
6125 {
6126 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
6127 WPOOH_array.Insert(WPOF);
6128 }
6129 }
6130
6131
6132 m_OnOverheatingEffect.Insert(id, WPOOH_array);
6133 }
6134 }
6135 }
6136
6137 float GetOverheatingValue()
6138 {
6139 return m_OverheatingShots;
6140 }
6141
6142 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
6143 {
6144 if (m_MaxOverheatingValue > 0)
6145 {
6147
6148 if (!m_CheckOverheating)
6150
6152 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
6153
6154 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6155 }
6156 }
6157
6158 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6159 {
6161 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6162
6164 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6165
6167 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6168
6170 {
6172 }
6173 }
6174
6176 {
6178 }
6179
6180 void OnOverheatingDecay()
6181 {
6182 if (m_MaxOverheatingValue > 0)
6183 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
6184 else
6186
6187 if (m_OverheatingShots <= 0)
6188 {
6191 }
6192 else
6193 {
6194 if (!m_CheckOverheating)
6196
6198 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
6199 }
6200
6201 CheckOverheating(this, "", this);
6202 }
6203
6204 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6205 {
6207 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
6208 }
6209
6210 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6211 {
6213 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
6215 }
6216
6217 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6218 {
6220 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6221 }
6222
6223 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
6224 {
6226 m_OverheatingParticles = new array<ref OverheatingParticle>;
6227
6228 OverheatingParticle OP = new OverheatingParticle();
6229 OP.RegisterParticle(p);
6230 OP.SetOverheatingLimitMin(min_heat_coef);
6231 OP.SetOverheatingLimitMax(max_heat_coef);
6232 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
6233
6234 m_OverheatingParticles.Insert(OP);
6235 }
6236
6237 float GetOverheatingCoef()
6238 {
6239 if (m_MaxOverheatingValue > 0)
6241
6242 return -1;
6243 }
6244
6246 {
6248 {
6249 float overheat_coef = GetOverheatingCoef();
6250 int count = m_OverheatingParticles.Count();
6251
6252 for (int i = count; i > 0; --i)
6253 {
6254 int id = i - 1;
6255 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6256 Particle p = OP.GetParticle();
6257
6258 float overheat_min = OP.GetOverheatingLimitMin();
6259 float overheat_max = OP.GetOverheatingLimitMax();
6260
6261 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
6262 {
6263 if (p)
6264 {
6265 p.Stop();
6266 OP.RegisterParticle(null);
6267 }
6268 }
6269 }
6270 }
6271 }
6272
6274 {
6276 {
6277 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
6278 {
6279 int id = i - 1;
6280 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6281
6282 if (OP)
6283 {
6284 Particle p = OP.GetParticle();
6285
6286 if (p)
6287 {
6288 p.Stop();
6289 }
6290
6291 delete OP;
6292 }
6293 }
6294
6295 m_OverheatingParticles.Clear();
6297 }
6298 }
6299
6301 float GetInfectionChance(int system = 0, Param param = null)
6302 {
6303 return 0.0;
6304 }
6305
6306
6307 float GetDisinfectQuantity(int system = 0, Param param1 = null)
6308 {
6309 return 250;//default value
6310 }
6311
6312 float GetFilterDamageRatio()
6313 {
6314 return 0;
6315 }
6316
6318 bool HasMuzzle()
6319 {
6320 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
6321 return true;
6322
6323 return false;
6324 }
6325
6327 int GetMuzzleID()
6328 {
6329 if (!m_WeaponTypeToID)
6330 m_WeaponTypeToID = new map<string, int>;
6331
6332 if (m_WeaponTypeToID.Contains(GetType()))
6333 {
6334 return m_WeaponTypeToID.Get(GetType());
6335 }
6336 else
6337 {
6338 // Register new weapon ID
6340 }
6341
6343 }
6344
6351 {
6352 return -1;
6353 }
6354
6355
6356
6357 // -------------------------------------------------------------------------
6358 void ~ItemBase()
6359 {
6360 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
6361 {
6362 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
6363 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
6364
6365 if (r_index >= 0)
6366 {
6367 InventoryLocation r_il = new InventoryLocation;
6368 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
6369
6370 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
6371 int r_type = r_il.GetType();
6372 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
6373 {
6374 r_il.GetParent().GetOnReleaseLock().Invoke(this);
6375 }
6376 else if (r_type == InventoryLocationType.ATTACHMENT)
6377 {
6378 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
6379 }
6380
6381 }
6382
6383 player.GetHumanInventory().ClearUserReservedLocation(this);
6384 }
6385
6386 if (m_LockingSound)
6387 SEffectManager.DestroyEffect(m_LockingSound);
6388 }
6389
6390
6391
6392 // -------------------------------------------------------------------------
6393 static int GetDebugActionsMask()
6394 {
6395 return ItemBase.m_DebugActionsMask;
6396 }
6397
6398 static bool HasDebugActionsMask(int mask)
6399 {
6400 return ItemBase.m_DebugActionsMask & mask;
6401 }
6402
6403 static void SetDebugActionsMask(int mask)
6404 {
6405 ItemBase.m_DebugActionsMask = mask;
6406 }
6407
6408 static void AddDebugActionsMask(int mask)
6409 {
6410 ItemBase.m_DebugActionsMask |= mask;
6411 }
6412
6413 static void RemoveDebugActionsMask(int mask)
6414 {
6415 ItemBase.m_DebugActionsMask &= ~mask;
6416 }
6417
6418 static void ToggleDebugActionsMask(int mask)
6419 {
6420 if (HasDebugActionsMask(mask))
6421 {
6423 }
6424 else
6425 {
6426 AddDebugActionsMask(mask);
6427 }
6428 }
6429
6430 // -------------------------------------------------------------------------
6431 void SetCEBasedQuantity()
6432 {
6433 if (GetEconomyProfile())
6434 {
6435 float q_max = GetEconomyProfile().GetQuantityMax();
6436 if (q_max > 0)
6437 {
6438 float q_min = GetEconomyProfile().GetQuantityMin();
6439 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
6440
6441 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
6442 {
6443 ComponentEnergyManager comp = GetCompEM();
6444 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
6445 {
6446 comp.SetEnergy0To1(quantity_randomized);
6447 }
6448 }
6449 else if (HasQuantity())
6450 {
6451 SetQuantityNormalized(quantity_randomized, false);
6452 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
6453 }
6454
6455 }
6456 }
6457 }
6458
6460 void LockToParent()
6461 {
6462 EntityAI parent = GetHierarchyParent();
6463
6464 if (parent)
6465 {
6466 InventoryLocation inventory_location_to_lock = new InventoryLocation;
6467 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
6468 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
6469 }
6470 }
6471
6473 void UnlockFromParent()
6474 {
6475 EntityAI parent = GetHierarchyParent();
6476
6477 if (parent)
6478 {
6479 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
6480 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
6481 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
6482 }
6483 }
6484
6485 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
6486 {
6487 /*
6488 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
6489 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
6490 */
6491 ItemBase item2 = ItemBase.Cast(entity2);
6492
6493 if (g_Game.IsClient())
6494 {
6495 if (ScriptInputUserData.CanStoreInputUserData())
6496 {
6497 ScriptInputUserData ctx = new ScriptInputUserData;
6499 ctx.Write(-1);
6500 ItemBase i1 = this; // @NOTE: workaround for correct serialization
6501 ctx.Write(i1);
6502 ctx.Write(item2);
6503 ctx.Write(use_stack_max);
6504 ctx.Write(-1);
6505 ctx.Send();
6506
6507 if (IsCombineAll(item2, use_stack_max))
6508 {
6509 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
6510 }
6511 }
6512 }
6513 else if (!g_Game.IsMultiplayer())
6514 {
6515 CombineItems(item2, use_stack_max);
6516 }
6517 }
6518
6519 bool IsLiquidPresent()
6520 {
6521 return (GetLiquidType() != 0 && HasQuantity());
6522 }
6523
6524 bool IsLiquidContainer()
6525 {
6526 return m_LiquidContainerMask != 0;
6527 }
6528
6530 {
6531 return m_LiquidContainerMask;
6532 }
6533
6534 bool IsBloodContainer()
6535 {
6536 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
6537 return false;
6538 }
6539
6540 bool IsNVG()
6541 {
6542 return false;
6543 }
6544
6547 bool IsExplosive()
6548 {
6549 return false;
6550 }
6551
6553 {
6554 return "";
6555 }
6556
6558
6559 bool IsLightSource()
6560 {
6561 return false;
6562 }
6563
6565 {
6566 return true;
6567 }
6568
6569 //--- ACTION CONDITIONS
6570 //direction
6571 bool IsFacingPlayer(PlayerBase player, string selection)
6572 {
6573 return true;
6574 }
6575
6576 bool IsPlayerInside(PlayerBase player, string selection)
6577 {
6578 return true;
6579 }
6580
6581 override bool CanObstruct()
6582 {
6583 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
6584 return !player || !IsPlayerInside(player, "");
6585 }
6586
6587 override bool IsBeingPlaced()
6588 {
6589 return m_IsBeingPlaced;
6590 }
6591
6592 void SetIsBeingPlaced(bool is_being_placed)
6593 {
6594 m_IsBeingPlaced = is_being_placed;
6595 if (!is_being_placed)
6597 SetSynchDirty();
6598 }
6599
6600 //server-side
6601 void OnEndPlacement() {}
6602
6603 override bool IsHologram()
6604 {
6605 return m_IsHologram;
6606 }
6607
6608 bool CanBeDigged()
6609 {
6610 return m_CanBeDigged;
6611 }
6612
6614 {
6615 return 1;
6616 }
6617
6618 bool CanMakeGardenplot()
6619 {
6620 return false;
6621 }
6622
6623 void SetIsHologram(bool is_hologram)
6624 {
6625 m_IsHologram = is_hologram;
6626 SetSynchDirty();
6627 }
6628 /*
6629 protected float GetNutritionalEnergy()
6630 {
6631 Edible_Base edible = Edible_Base.Cast(this);
6632 return edible.GetFoodEnergy();
6633 }
6634
6635 protected float GetNutritionalWaterContent()
6636 {
6637 Edible_Base edible = Edible_Base.Cast(this);
6638 return edible.GetFoodWater();
6639 }
6640
6641 protected float GetNutritionalIndex()
6642 {
6643 Edible_Base edible = Edible_Base.Cast(this);
6644 return edible.GetFoodNutritionalIndex();
6645 }
6646
6647 protected float GetNutritionalFullnessIndex()
6648 {
6649 Edible_Base edible = Edible_Base.Cast(this);
6650 return edible.GetFoodTotalVolume();
6651 }
6652
6653 protected float GetNutritionalToxicity()
6654 {
6655 Edible_Base edible = Edible_Base.Cast(this);
6656 return edible.GetFoodToxicity();
6657
6658 }
6659 */
6660
6661
6662 // -------------------------------------------------------------------------
6663 override void OnMovedInsideCargo(EntityAI container)
6664 {
6665 super.OnMovedInsideCargo(container);
6666
6667 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
6668 }
6669
6670 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
6671 {
6672 super.EEItemLocationChanged(oldLoc, newLoc);
6673
6674 PlayerBase newPlayer = null;
6675 PlayerBase oldPlayer = null;
6676
6677 if (newLoc.GetParent())
6678 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
6679
6680 if (oldLoc.GetParent())
6681 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
6682
6683 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
6684 {
6685 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
6686
6687 if (rIndex >= 0)
6688 {
6689 InventoryLocation rIl = new InventoryLocation;
6690 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
6691
6692 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
6693 int rType = rIl.GetType();
6694 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
6695 {
6696 rIl.GetParent().GetOnReleaseLock().Invoke(this);
6697 }
6698 else if (rType == InventoryLocationType.ATTACHMENT)
6699 {
6700 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
6701 }
6702
6703 }
6704 }
6705
6706 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
6707 {
6708 if (newPlayer)
6709 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
6710
6711 if (newPlayer == oldPlayer)
6712 {
6713 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
6714 {
6715 if (oldLoc.GetType() == InventoryLocationType.CARGO)
6716 {
6717 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
6718 {
6719 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
6720 }
6721 }
6722 else
6723 {
6724 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
6725 }
6726 }
6727
6728 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
6729 {
6730 int type = oldLoc.GetType();
6731 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
6732 {
6733 oldLoc.GetParent().GetOnSetLock().Invoke(this);
6734 }
6735 else if (type == InventoryLocationType.ATTACHMENT)
6736 {
6737 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
6738 }
6739 }
6740 if (!m_OldLocation)
6741 {
6742 m_OldLocation = new InventoryLocation;
6743 }
6744 m_OldLocation.Copy(oldLoc);
6745 }
6746 else
6747 {
6748 if (m_OldLocation)
6749 {
6750 m_OldLocation.Reset();
6751 }
6752 }
6753
6754 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
6755 }
6756 else
6757 {
6758 if (newPlayer)
6759 {
6760 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
6761 if (resIndex >= 0)
6762 {
6763 InventoryLocation il = new InventoryLocation;
6764 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
6765 ItemBase it = ItemBase.Cast(il.GetItem());
6766 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
6767 int rel_type = il.GetType();
6768 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
6769 {
6770 il.GetParent().GetOnReleaseLock().Invoke(it);
6771 }
6772 else if (rel_type == InventoryLocationType.ATTACHMENT)
6773 {
6774 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
6775 }
6776 //it.GetOnReleaseLock().Invoke(it);
6777 }
6778 }
6779 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
6780 {
6781 //ThrowPhysically(oldPlayer, vector.Zero);
6782 m_ThrowItemOnDrop = false;
6783 }
6784
6785 if (m_OldLocation)
6786 {
6787 m_OldLocation.Reset();
6788 }
6789 }
6790
6791 if (oldLoc.GetType() == InventoryLocationType.TEMP)
6792 {
6793 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
6794 }
6795
6796 if (newLoc.GetType() == InventoryLocationType.TEMP)
6797 {
6798 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
6799 }
6800 }
6801
6802 override void EOnContact(IEntity other, Contact extra)
6803 {
6805 {
6806 int liquidType = -1;
6807 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
6808 if (impactSpeed > 0.0)
6809 {
6810 m_ImpactSpeed = impactSpeed;
6811 #ifndef SERVER
6812 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
6813 #else
6814 m_WantPlayImpactSound = true;
6815 SetSynchDirty();
6816 #endif
6817 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
6818 }
6819 }
6820
6821 #ifdef SERVER
6822 if (GetCompEM() && GetCompEM().IsPlugged())
6823 {
6824 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
6825 GetCompEM().UnplugThis();
6826 }
6827 #endif
6828 }
6829
6830 void RefreshPhysics();
6831
6832 override void OnCreatePhysics()
6833 {
6835 }
6836
6837 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
6838 {
6839
6840 }
6841 // -------------------------------------------------------------------------
6842 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
6843 {
6844 super.OnItemLocationChanged(old_owner, new_owner);
6845
6846 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
6847 PlayerBase playerNew = PlayerBase.Cast(new_owner);
6848
6849 if (!relatedPlayer && playerNew)
6850 relatedPlayer = playerNew;
6851
6852 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
6853 {
6854 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
6855 if (actionMgr)
6856 {
6857 ActionBase currentAction = actionMgr.GetRunningAction();
6858 if (currentAction)
6859 currentAction.OnItemLocationChanged(this);
6860 }
6861 }
6862
6863 Man ownerPlayerOld = null;
6864 Man ownerPlayerNew = null;
6865
6866 if (old_owner)
6867 {
6868 if (old_owner.IsMan())
6869 {
6870 ownerPlayerOld = Man.Cast(old_owner);
6871 }
6872 else
6873 {
6874 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
6875 }
6876 }
6877 else
6878 {
6879 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
6880 {
6881 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
6882
6883 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
6884 {
6885 GetCompEM().UnplugThis();
6886 }
6887 }
6888 }
6889
6890 if (new_owner)
6891 {
6892 if (new_owner.IsMan())
6893 {
6894 ownerPlayerNew = Man.Cast(new_owner);
6895 }
6896 else
6897 {
6898 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
6899 }
6900 }
6901
6902 if (ownerPlayerOld != ownerPlayerNew)
6903 {
6904 if (ownerPlayerOld)
6905 {
6906 array<EntityAI> subItemsExit = new array<EntityAI>;
6907 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
6908 for (int i = 0; i < subItemsExit.Count(); i++)
6909 {
6910 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
6911 itemExit.OnInventoryExit(ownerPlayerOld);
6912 }
6913 }
6914
6915 if (ownerPlayerNew)
6916 {
6917 array<EntityAI> subItemsEnter = new array<EntityAI>;
6918 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
6919 for (int j = 0; j < subItemsEnter.Count(); j++)
6920 {
6921 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
6922 itemEnter.OnInventoryEnter(ownerPlayerNew);
6923 }
6924 }
6925 }
6926 else if (ownerPlayerNew != null)
6927 {
6928 PlayerBase nplayer;
6929 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
6930 {
6931 array<EntityAI> subItemsUpdate = new array<EntityAI>;
6932 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
6933 for (int k = 0; k < subItemsUpdate.Count(); k++)
6934 {
6935 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
6936 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
6937 }
6938 }
6939 }
6940
6941 if (old_owner)
6942 old_owner.OnChildItemRemoved(this);
6943 if (new_owner)
6944 new_owner.OnChildItemReceived(this);
6945 }
6946
6947 // -------------------------------------------------------------------------------
6948 override void EEDelete(EntityAI parent)
6949 {
6950 super.EEDelete(parent);
6951 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
6952 if (player)
6953 {
6954 OnInventoryExit(player);
6955
6956 if (player.IsAlive())
6957 {
6958 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
6959 if (r_index >= 0)
6960 {
6961 InventoryLocation r_il = new InventoryLocation;
6962 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
6963
6964 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
6965 int r_type = r_il.GetType();
6966 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
6967 {
6968 r_il.GetParent().GetOnReleaseLock().Invoke(this);
6969 }
6970 else if (r_type == InventoryLocationType.ATTACHMENT)
6971 {
6972 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
6973 }
6974
6975 }
6976
6977 player.RemoveQuickBarEntityShortcut(this);
6978 }
6979 }
6980 }
6981 // -------------------------------------------------------------------------------
6982 override void EEKilled(Object killer)
6983 {
6984 super.EEKilled(killer);
6985
6987 if (killer && killer.IsFireplace() && CanExplodeInFire())
6988 {
6989 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
6990 {
6991 if (IsMagazine())
6992 {
6993 if (Magazine.Cast(this).GetAmmoCount() > 0)
6994 {
6995 ExplodeAmmo();
6996 }
6997 }
6998 else
6999 {
7000 Explode(DamageType.EXPLOSION);
7001 }
7002 }
7003 }
7004 }
7005
7006 override void OnWasAttached(EntityAI parent, int slot_id)
7007 {
7008 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
7009
7010 super.OnWasAttached(parent, slot_id);
7011
7012 if (HasQuantity())
7013 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7014
7015 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
7016 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
7017 }
7018
7019 override void OnWasDetached(EntityAI parent, int slot_id)
7020 {
7021 super.OnWasDetached(parent, slot_id);
7022
7023 if (HasQuantity())
7024 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7025
7026 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
7027 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
7028 }
7029
7030 override string ChangeIntoOnAttach(string slot)
7031 {
7032 int idx;
7033 TStringArray inventory_slots = new TStringArray;
7034 TStringArray attach_types = new TStringArray;
7035
7036 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
7037 if (inventory_slots.Count() < 1) //is string
7038 {
7039 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
7040 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
7041 }
7042 else //is array
7043 {
7044 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
7045 }
7046
7047 idx = inventory_slots.Find(slot);
7048 if (idx < 0)
7049 return "";
7050
7051 return attach_types.Get(idx);
7052 }
7053
7054 override string ChangeIntoOnDetach()
7055 {
7056 int idx = -1;
7057 string slot;
7058
7059 TStringArray inventory_slots = new TStringArray;
7060 TStringArray detach_types = new TStringArray;
7061
7062 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
7063 if (inventory_slots.Count() < 1) //is string
7064 {
7065 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
7066 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
7067 }
7068 else //is array
7069 {
7070 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
7071 if (detach_types.Count() < 1)
7072 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
7073 }
7074
7075 for (int i = 0; i < inventory_slots.Count(); i++)
7076 {
7077 slot = inventory_slots.Get(i);
7078 }
7079
7080 if (slot != "")
7081 {
7082 if (detach_types.Count() == 1)
7083 idx = 0;
7084 else
7085 idx = inventory_slots.Find(slot);
7086 }
7087 if (idx < 0)
7088 return "";
7089
7090 return detach_types.Get(idx);
7091 }
7092
7093 void ExplodeAmmo()
7094 {
7095 //timer
7096 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
7097
7098 //min/max time
7099 float min_time = 1;
7100 float max_time = 3;
7101 float delay = Math.RandomFloat(min_time, max_time);
7102
7103 explode_timer.Run(delay, this, "DoAmmoExplosion");
7104 }
7105
7106 void DoAmmoExplosion()
7107 {
7108 Magazine magazine = Magazine.Cast(this);
7109 int pop_sounds_count = 6;
7110 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
7111
7112 //play sound
7113 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
7114 string sound_name = pop_sounds[ sound_idx ];
7115 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
7116
7117 //remove ammo count
7118 magazine.ServerAddAmmoCount(-1);
7119
7120 //if condition then repeat -> ExplodeAmmo
7121 float min_temp_to_explode = 100; //min temperature for item to explode
7122
7123 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
7124 {
7125 ExplodeAmmo();
7126 }
7127 }
7128
7129 // -------------------------------------------------------------------------------
7130 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
7131 {
7132 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
7133
7134 const int CHANCE_DAMAGE_CARGO = 4;
7135 const int CHANCE_DAMAGE_ATTACHMENT = 1;
7136 const int CHANCE_DAMAGE_NOTHING = 2;
7137
7138 if (IsClothing() || IsContainer() || IsItemTent())
7139 {
7140 float dmg = damageResult.GetDamage("","Health") * -0.5;
7141 int chances;
7142 int rnd;
7143
7144 if (GetInventory().GetCargo())
7145 {
7146 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
7147 rnd = Math.RandomInt(0,chances);
7148
7149 if (rnd < CHANCE_DAMAGE_CARGO)
7150 {
7151 DamageItemInCargo(dmg);
7152 }
7153 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
7154 {
7156 }
7157 }
7158 else
7159 {
7160 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
7161 rnd = Math.RandomInt(0,chances);
7162
7163 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
7164 {
7166 }
7167 }
7168 }
7169 }
7170
7171 bool DamageItemInCargo(float damage)
7172 {
7173 CargoBase cargo = GetInventory().GetCargo();
7174 if (cargo)
7175 {
7176 int item_count = cargo.GetItemCount();
7177 if (item_count > 0)
7178 {
7179 int random_pick = Math.RandomInt(0, item_count);
7180 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
7181 if (!item.IsExplosive())
7182 {
7183 item.AddHealth("","",damage);
7184 return true;
7185 }
7186 }
7187 }
7188 return false;
7189 }
7190
7191 bool DamageItemAttachments(float damage)
7192 {
7193 GameInventory inventory = GetInventory();
7194 int attachment_count = inventory.AttachmentCount();
7195 if (attachment_count > 0)
7196 {
7197 int random_pick = Math.RandomInt(0, attachment_count);
7198 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
7199 if (!attachment.IsExplosive())
7200 {
7201 attachment.AddHealth("","",damage);
7202 return true;
7203 }
7204 }
7205 return false;
7206 }
7207
7208 override bool IsSplitable()
7209 {
7210 return m_CanThisBeSplit;
7211 }
7212 //----------------
7213 override bool CanBeSplit()
7214 {
7215 if (IsSplitable() && (GetQuantity() > 1))
7216 return GetInventory().CanRemoveEntity();
7217
7218 return false;
7219 }
7220
7221 protected bool ShouldSplitQuantity(float quantity)
7222 {
7223 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
7224 if (!IsSplitable())
7225 return false;
7226
7227 // nothing to split?
7228 if (GetQuantity() <= 1)
7229 return false;
7230
7231 // check if we should re-use the item instead of creating a new copy?
7232 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
7233 int delta = GetQuantity() - quantity;
7234 if (delta == 0)
7235 return false;
7236
7237 // valid to split
7238 return true;
7239 }
7240
7241 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
7242 {
7243 if (g_Game.IsClient())
7244 {
7245 if (ScriptInputUserData.CanStoreInputUserData())
7246 {
7247 ScriptInputUserData ctx = new ScriptInputUserData;
7249 ctx.Write(1);
7250 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7251 ctx.Write(i1);
7252 ctx.Write(destination_entity);
7253 ctx.Write(true);
7254 ctx.Write(slot_id);
7255 ctx.Send();
7256 }
7257 }
7258 else if (!g_Game.IsMultiplayer())
7259 {
7260 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
7261 }
7262 }
7263
7264 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
7265 {
7266 float split_quantity_new;
7267 ItemBase new_item;
7268 float quantity = GetQuantity();
7269 float stack_max = GetTargetQuantityMax(slot_id);
7270 InventoryLocation loc = new InventoryLocation;
7271
7272 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7273 {
7274 if (stack_max <= GetQuantity())
7275 split_quantity_new = stack_max;
7276 else
7277 split_quantity_new = GetQuantity();
7278
7279 if (ShouldSplitQuantity(split_quantity_new))
7280 {
7281 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7282 if (new_item)
7283 {
7284 new_item.SetResultOfSplit(true);
7285 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7286 AddQuantity(-split_quantity_new, false, true);
7287 new_item.SetQuantity(split_quantity_new, false, true);
7288 }
7289 }
7290 }
7291 else if (destination_entity && slot_id == -1)
7292 {
7293 if (quantity > stack_max)
7294 split_quantity_new = stack_max;
7295 else
7296 split_quantity_new = quantity;
7297
7298 if (ShouldSplitQuantity(split_quantity_new))
7299 {
7300 GameInventory destinationInventory = destination_entity.GetInventory();
7301 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
7302 {
7303 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
7304 new_item = ItemBase.Cast(o);
7305 }
7306
7307 if (new_item)
7308 {
7309 new_item.SetResultOfSplit(true);
7310 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7311 AddQuantity(-split_quantity_new, false, true);
7312 new_item.SetQuantity(split_quantity_new, false, true);
7313 }
7314 }
7315 }
7316 else
7317 {
7318 if (stack_max != 0)
7319 {
7320 if (stack_max < GetQuantity())
7321 {
7322 split_quantity_new = GetQuantity() - stack_max;
7323 }
7324
7325 if (split_quantity_new == 0)
7326 {
7327 if (!g_Game.IsMultiplayer())
7328 player.PhysicalPredictiveDropItem(this);
7329 else
7330 player.ServerDropEntity(this);
7331 return;
7332 }
7333
7334 if (ShouldSplitQuantity(split_quantity_new))
7335 {
7336 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
7337
7338 if (new_item)
7339 {
7340 new_item.SetResultOfSplit(true);
7341 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7342 SetQuantity(split_quantity_new, false, true);
7343 new_item.SetQuantity(stack_max, false, true);
7344 new_item.PlaceOnSurface();
7345 }
7346 }
7347 }
7348 }
7349 }
7350
7351 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
7352 {
7353 float split_quantity_new;
7354 ItemBase new_item;
7355 float quantity = GetQuantity();
7356 float stack_max = GetTargetQuantityMax(slot_id);
7357 InventoryLocation loc = new InventoryLocation;
7358
7359 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7360 {
7361 if (stack_max <= GetQuantity())
7362 split_quantity_new = stack_max;
7363 else
7364 split_quantity_new = GetQuantity();
7365
7366 if (ShouldSplitQuantity(split_quantity_new))
7367 {
7368 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7369 if (new_item)
7370 {
7371 new_item.SetResultOfSplit(true);
7372 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7373 AddQuantity(-split_quantity_new, false, true);
7374 new_item.SetQuantity(split_quantity_new, false, true);
7375 }
7376 }
7377 }
7378 else if (destination_entity && slot_id == -1)
7379 {
7380 if (quantity > stack_max)
7381 split_quantity_new = stack_max;
7382 else
7383 split_quantity_new = quantity;
7384
7385 if (ShouldSplitQuantity(split_quantity_new))
7386 {
7387 GameInventory destinationInventory = destination_entity.GetInventory();
7388 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
7389 {
7390 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
7391 new_item = ItemBase.Cast(o);
7392 }
7393
7394 if (new_item)
7395 {
7396 new_item.SetResultOfSplit(true);
7397 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7398 AddQuantity(-split_quantity_new, false, true);
7399 new_item.SetQuantity(split_quantity_new, false, true);
7400 }
7401 }
7402 }
7403 else
7404 {
7405 if (stack_max != 0)
7406 {
7407 if (stack_max < GetQuantity())
7408 {
7409 split_quantity_new = GetQuantity() - stack_max;
7410 }
7411
7412 if (ShouldSplitQuantity(split_quantity_new))
7413 {
7414 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
7415
7416 if (new_item)
7417 {
7418 new_item.SetResultOfSplit(true);
7419 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7420 SetQuantity(split_quantity_new, false, true);
7421 new_item.SetQuantity(stack_max, false, true);
7422 new_item.PlaceOnSurface();
7423 }
7424 }
7425 }
7426 }
7427 }
7428
7429 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
7430 {
7431 if (g_Game.IsClient())
7432 {
7433 if (ScriptInputUserData.CanStoreInputUserData())
7434 {
7435 ScriptInputUserData ctx = new ScriptInputUserData;
7437 ctx.Write(4);
7438 ItemBase thiz = this; // @NOTE: workaround for correct serialization
7439 ctx.Write(thiz);
7440 dst.WriteToContext(ctx);
7441 ctx.Send();
7442 }
7443 }
7444 else if (!g_Game.IsMultiplayer())
7445 {
7447 }
7448 }
7449
7450 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
7451 {
7452 if (g_Game.IsClient())
7453 {
7454 if (ScriptInputUserData.CanStoreInputUserData())
7455 {
7456 ScriptInputUserData ctx = new ScriptInputUserData;
7458 ctx.Write(2);
7459 ItemBase dummy = this; // @NOTE: workaround for correct serialization
7460 ctx.Write(dummy);
7461 ctx.Write(destination_entity);
7462 ctx.Write(true);
7463 ctx.Write(idx);
7464 ctx.Write(row);
7465 ctx.Write(col);
7466 ctx.Send();
7467 }
7468 }
7469 else if (!g_Game.IsMultiplayer())
7470 {
7471 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
7472 }
7473 }
7474
7475 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
7476 {
7478 }
7479
7480 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
7481 {
7482 float quantity = GetQuantity();
7483 float split_quantity_new;
7484 ItemBase new_item;
7485 if (dst.IsValid())
7486 {
7487 int slot_id = dst.GetSlot();
7488 float stack_max = GetTargetQuantityMax(slot_id);
7489
7490 if (quantity > stack_max)
7491 split_quantity_new = stack_max;
7492 else
7493 split_quantity_new = quantity;
7494
7495 if (ShouldSplitQuantity(split_quantity_new))
7496 {
7497 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
7498
7499 if (new_item)
7500 {
7501 new_item.SetResultOfSplit(true);
7502 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7503 AddQuantity(-split_quantity_new, false, true);
7504 new_item.SetQuantity(split_quantity_new, false, true);
7505 }
7506
7507 return new_item;
7508 }
7509 }
7510
7511 return null;
7512 }
7513
7514 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
7515 {
7516 float quantity = GetQuantity();
7517 float split_quantity_new;
7518 ItemBase new_item;
7519 if (destination_entity)
7520 {
7521 float stackable = GetTargetQuantityMax();
7522 if (quantity > stackable)
7523 split_quantity_new = stackable;
7524 else
7525 split_quantity_new = quantity;
7526
7527 if (ShouldSplitQuantity(split_quantity_new))
7528 {
7529 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
7530 if (new_item)
7531 {
7532 new_item.SetResultOfSplit(true);
7533 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7534 AddQuantity(-split_quantity_new, false, true);
7535 new_item.SetQuantity(split_quantity_new, false, true);
7536 }
7537 }
7538 }
7539 }
7540
7541 void SplitIntoStackMaxHandsClient(PlayerBase player)
7542 {
7543 if (g_Game.IsClient())
7544 {
7545 if (ScriptInputUserData.CanStoreInputUserData())
7546 {
7547 ScriptInputUserData ctx = new ScriptInputUserData;
7549 ctx.Write(3);
7550 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7551 ctx.Write(i1);
7552 ItemBase destination_entity = this;
7553 ctx.Write(destination_entity);
7554 ctx.Write(true);
7555 ctx.Write(0);
7556 ctx.Send();
7557 }
7558 }
7559 else if (!g_Game.IsMultiplayer())
7560 {
7561 SplitIntoStackMaxHands(player);
7562 }
7563 }
7564
7565 void SplitIntoStackMaxHands(PlayerBase player)
7566 {
7567 float quantity = GetQuantity();
7568 float split_quantity_new;
7569 ref ItemBase new_item;
7570 if (player)
7571 {
7572 float stackable = GetTargetQuantityMax();
7573 if (quantity > stackable)
7574 split_quantity_new = stackable;
7575 else
7576 split_quantity_new = quantity;
7577
7578 if (ShouldSplitQuantity(split_quantity_new))
7579 {
7580 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
7581 new_item = ItemBase.Cast(in_hands);
7582 if (new_item)
7583 {
7584 new_item.SetResultOfSplit(true);
7585 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7586 AddQuantity(-split_quantity_new, false, true);
7587 new_item.SetQuantity(split_quantity_new, false, true);
7588 }
7589 }
7590 }
7591 }
7592
7593 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
7594 {
7595 float quantity = GetQuantity();
7596 float split_quantity_new = Math.Floor(quantity * 0.5);
7597
7598 if (!ShouldSplitQuantity(split_quantity_new))
7599 return;
7600
7601 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
7602
7603 if (new_item)
7604 {
7605 if (new_item.GetQuantityMax() < split_quantity_new)
7606 {
7607 split_quantity_new = new_item.GetQuantityMax();
7608 }
7609
7610 new_item.SetResultOfSplit(true);
7611 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7612
7613 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
7614 {
7615 AddQuantity(-1, false, true);
7616 new_item.SetQuantity(1, false, true);
7617 }
7618 else
7619 {
7620 AddQuantity(-split_quantity_new, false, true);
7621 new_item.SetQuantity(split_quantity_new, false, true);
7622 }
7623 }
7624 }
7625
7626 void SplitItem(PlayerBase player)
7627 {
7628 float quantity = GetQuantity();
7629 float split_quantity_new = Math.Floor(quantity / 2);
7630
7631 if (!ShouldSplitQuantity(split_quantity_new))
7632 return;
7633
7634 InventoryLocation invloc = new InventoryLocation;
7635 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
7636
7637 ItemBase new_item;
7638 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
7639
7640 if (new_item)
7641 {
7642 if (new_item.GetQuantityMax() < split_quantity_new)
7643 {
7644 split_quantity_new = new_item.GetQuantityMax();
7645 }
7646 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
7647 {
7648 AddQuantity(-1, false, true);
7649 new_item.SetQuantity(1, false, true);
7650 }
7651 else if (split_quantity_new > 1)
7652 {
7653 AddQuantity(-split_quantity_new, false, true);
7654 new_item.SetQuantity(split_quantity_new, false, true);
7655 }
7656 }
7657 }
7658
7660 void OnQuantityChanged(float delta)
7661 {
7662 SetWeightDirty();
7663 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
7664
7665 if (parent)
7666 parent.OnAttachmentQuantityChangedEx(this, delta);
7667
7668 if (IsLiquidContainer())
7669 {
7670 if (GetQuantityNormalized() <= 0.0)
7671 {
7673 }
7674 else if (GetLiquidType() == LIQUID_NONE)
7675 {
7676 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
7678 }
7679 }
7680 }
7681
7684 {
7685 // insert code here
7686 }
7687
7689 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
7690 {
7692 }
7693
7694 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
7695 {
7696 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
7697
7698 if (g_Game.IsServer())
7699 {
7700 if (newLevel == GameConstants.STATE_RUINED)
7701 {
7703 EntityAI parent = GetHierarchyParent();
7704 if (parent && parent.IsFireplace())
7705 {
7706 CargoBase cargo = GetInventory().GetCargo();
7707 if (cargo)
7708 {
7709 for (int i = 0; i < cargo.GetItemCount(); ++i)
7710 {
7711 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
7712 }
7713 }
7714 }
7715 }
7716
7717 if (IsResultOfSplit())
7718 {
7719 // reset the splitting result flag, return to normal item behavior
7720 SetResultOfSplit(false);
7721 return;
7722 }
7723
7724 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
7725 {
7726 SetCleanness(0);//unclean the item upon damage dealt
7727 }
7728 }
7729 }
7730
7731 // just the split? TODO: verify
7732 override void OnRightClick()
7733 {
7734 super.OnRightClick();
7735
7736 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
7737 {
7738 if (g_Game.IsClient())
7739 {
7740 if (ScriptInputUserData.CanStoreInputUserData())
7741 {
7742 EntityAI root = GetHierarchyRoot();
7743 Man playerOwner = GetHierarchyRootPlayer();
7744 InventoryLocation dst = new InventoryLocation;
7745
7746 // 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
7747 if (!playerOwner && root && root == this)
7748 {
7750 }
7751 else
7752 {
7753 // 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
7754 GetInventory().GetCurrentInventoryLocation(dst);
7755 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
7756 {
7757 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
7758 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
7759 {
7761 }
7762 else
7763 {
7764 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
7765 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
7766 this shouldnt cause issues within this scope*/
7767 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
7768 {
7770 }
7771 else
7772 {
7773 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
7774 }
7775 }
7776 }
7777 }
7778
7779 ScriptInputUserData ctx = new ScriptInputUserData;
7781 ctx.Write(4);
7782 ItemBase thiz = this; // @NOTE: workaround for correct serialization
7783 ctx.Write(thiz);
7784 dst.WriteToContext(ctx);
7785 ctx.Write(true); // dummy
7786 ctx.Send();
7787 }
7788 }
7789 else if (!g_Game.IsMultiplayer())
7790 {
7791 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
7792 }
7793 }
7794 }
7795
7796 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
7797 {
7798 if (root)
7799 {
7800 vector m4[4];
7801 root.GetTransform(m4);
7802 dst.SetGround(this, m4);
7803 }
7804 else
7805 {
7806 GetInventory().GetCurrentInventoryLocation(dst);
7807 }
7808 }
7809
7810 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
7811 {
7812 //TODO: delete check zero quantity check after fix double posts hands fsm events
7813 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
7814 return false;
7815
7816 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
7817 return false;
7818
7819 //can_this_be_combined = ConfigGetBool("canBeSplit");
7821 return false;
7822
7823
7824 Magazine mag = Magazine.Cast(this);
7825 if (mag)
7826 {
7827 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
7828 return false;
7829
7830 if (stack_max_limit)
7831 {
7832 Magazine other_mag = Magazine.Cast(other_item);
7833 if (other_item)
7834 {
7835 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
7836 return false;
7837 }
7838
7839 }
7840 }
7841 else
7842 {
7843 //TODO: delete check zero quantity check after fix double posts hands fsm events
7844 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
7845 return false;
7846
7847 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
7848 return false;
7849 }
7850
7851 PlayerBase player = null;
7852 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
7853 {
7854 if (player.GetInventory().HasAttachment(this))
7855 return false;
7856
7857 if (player.IsItemsToDelete())
7858 return false;
7859 }
7860
7861 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
7862 return false;
7863
7864 int slotID;
7865 string slotName;
7866 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
7867 return false;
7868
7869 return true;
7870 }
7871
7872 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
7873 {
7874 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
7875 }
7876
7877 bool IsResultOfSplit()
7878 {
7879 return m_IsResultOfSplit;
7880 }
7881
7882 void SetResultOfSplit(bool value)
7883 {
7884 m_IsResultOfSplit = value;
7885 }
7886
7887 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
7888 {
7889 return ComputeQuantityUsedEx(other_item, use_stack_max);
7890 }
7891
7892 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
7893 {
7894 float other_item_quantity = other_item.GetQuantity();
7895 float this_free_space;
7896
7897 float stack_max = GetQuantityMax();
7898
7899 this_free_space = stack_max - GetQuantity();
7900
7901 if (other_item_quantity > this_free_space)
7902 {
7903 return this_free_space;
7904 }
7905 else
7906 {
7907 return other_item_quantity;
7908 }
7909 }
7910
7911 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
7912 {
7913 CombineItems(ItemBase.Cast(entity2),use_stack_max);
7914 }
7915
7916 void CombineItems(ItemBase other_item, bool use_stack_max = true)
7917 {
7918 if (!CanBeCombined(other_item, false))
7919 return;
7920
7921 if (!IsMagazine() && other_item)
7922 {
7923 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
7924 if (quantity_used != 0)
7925 {
7926 float hp1 = GetHealth01("","");
7927 float hp2 = other_item.GetHealth01("","");
7928 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
7929 hpResult = hpResult / (GetQuantity() + quantity_used);
7930
7931 hpResult *= GetMaxHealth();
7932 Math.Round(hpResult);
7933 SetHealth("", "Health", hpResult);
7934
7935 AddQuantity(quantity_used);
7936 other_item.AddQuantity(-quantity_used);
7937 }
7938 }
7939 OnCombine(other_item);
7940 }
7941
7942 void OnCombine(ItemBase other_item)
7943 {
7944 #ifdef SERVER
7945 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
7946 GetHierarchyParent().IncreaseLifetimeUp();
7947 #endif
7948 };
7949
7950 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
7951 {
7952 PlayerBase p = PlayerBase.Cast(player);
7953
7954 array<int> recipesIds = p.m_Recipes;
7955 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
7956 if (moduleRecipesManager)
7957 {
7958 EntityAI itemInHands = player.GetEntityInHands();
7959 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
7960 }
7961
7962 for (int i = 0;i < recipesIds.Count(); i++)
7963 {
7964 int key = recipesIds.Get(i);
7965 string recipeName = moduleRecipesManager.GetRecipeName(key);
7966 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
7967 }
7968 }
7969
7970 // -------------------------------------------------------------------------
7971 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
7972 {
7973 super.GetDebugActions(outputList);
7974
7975 //quantity
7976 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
7977 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
7978 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
7979 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
7980 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7981
7982 //health
7983 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
7984 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
7985 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
7986 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7987 //temperature
7988 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
7989 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
7990 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
7991 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7992
7993 //wet
7994 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
7995 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
7996 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7997
7998 //liquidtype
7999 if (IsLiquidContainer())
8000 {
8001 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
8002 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
8003 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8004 }
8005
8006 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
8007 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8008
8009 // watch
8010 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
8011 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
8012 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8013
8014 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
8015
8016 InventoryLocation loc = new InventoryLocation();
8017 GetInventory().GetCurrentInventoryLocation(loc);
8018 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
8019 {
8020 if (Gizmo_IsSupported())
8021 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
8022 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
8023 }
8024
8025 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8026 }
8027
8028 // -------------------------------------------------------------------------
8029 // -------------------------------------------------------------------------
8030 // -------------------------------------------------------------------------
8031 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
8032 {
8033 super.OnAction(action_id, player, ctx);
8034
8035 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
8036 {
8037 switch (action_id)
8038 {
8039 case EActions.GIZMO_OBJECT:
8040 if (GetGizmoApi())
8041 GetGizmoApi().SelectObject(this);
8042 return true;
8043 case EActions.GIZMO_PHYSICS:
8044 if (GetGizmoApi())
8045 GetGizmoApi().SelectPhysics(GetPhysics());
8046 return true;
8047 }
8048 }
8049
8050 if (g_Game.IsServer())
8051 {
8052 switch (action_id)
8053 {
8054 case EActions.DELETE:
8055 Delete();
8056 return true;
8057 }
8058 }
8059
8060 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
8061 {
8062 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
8063 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
8064 PlayerBase p = PlayerBase.Cast(player);
8065 if (EActions.RECIPES_RANGE_START < 1000)
8066 {
8067 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
8068 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
8069 }
8070 }
8071 #ifndef SERVER
8072 else if (action_id == EActions.WATCH_PLAYER)
8073 {
8074 PluginDeveloper.SetDeveloperItemClientEx(player);
8075 }
8076 #endif
8077 if (g_Game.IsServer())
8078 {
8079 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
8080 {
8081 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
8082 OnDebugButtonPressServer(id + 1);
8083 }
8084
8085 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
8086 {
8087 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
8088 InsertAgent(agent_id,100);
8089 }
8090
8091 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
8092 {
8093 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
8094 RemoveAgent(agent_id2);
8095 }
8096
8097 else if (action_id == EActions.ADD_QUANTITY)
8098 {
8099 if (IsMagazine())
8100 {
8101 Magazine mag = Magazine.Cast(this);
8102 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
8103 }
8104 else
8105 {
8106 AddQuantity(GetQuantityMax() * 0.2);
8107 }
8108
8109 if (m_EM)
8110 {
8111 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
8112 }
8113 //PrintVariables();
8114 }
8115
8116 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
8117 {
8118 if (IsMagazine())
8119 {
8120 Magazine mag2 = Magazine.Cast(this);
8121 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
8122 }
8123 else
8124 {
8125 AddQuantity(- GetQuantityMax() * 0.2);
8126 }
8127 if (m_EM)
8128 {
8129 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
8130 }
8131 //PrintVariables();
8132 }
8133
8134 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
8135 {
8136 SetQuantity(0);
8137
8138 if (m_EM)
8139 {
8140 m_EM.SetEnergy(0);
8141 }
8142 }
8143
8144 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
8145 {
8147
8148 if (m_EM)
8149 {
8150 m_EM.SetEnergy(m_EM.GetEnergyMax());
8151 }
8152 }
8153
8154 else if (action_id == EActions.ADD_HEALTH)
8155 {
8156 AddHealth("","",GetMaxHealth("","Health")/5);
8157 }
8158 else if (action_id == EActions.REMOVE_HEALTH)
8159 {
8160 AddHealth("","",-GetMaxHealth("","Health")/5);
8161 }
8162 else if (action_id == EActions.DESTROY_HEALTH)
8163 {
8164 SetHealth01("","",0);
8165 }
8166 else if (action_id == EActions.WATCH_ITEM)
8167 {
8169 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
8170 #ifdef DEVELOPER
8171 SetDebugDeveloper_item(this);
8172 #endif
8173 }
8174
8175 else if (action_id == EActions.ADD_TEMPERATURE)
8176 {
8177 AddTemperature(20);
8178 //PrintVariables();
8179 }
8180
8181 else if (action_id == EActions.REMOVE_TEMPERATURE)
8182 {
8183 AddTemperature(-20);
8184 //PrintVariables();
8185 }
8186
8187 else if (action_id == EActions.FLIP_FROZEN)
8188 {
8189 SetFrozen(!GetIsFrozen());
8190 //PrintVariables();
8191 }
8192
8193 else if (action_id == EActions.ADD_WETNESS)
8194 {
8195 AddWet(GetWetMax()/5);
8196 //PrintVariables();
8197 }
8198
8199 else if (action_id == EActions.REMOVE_WETNESS)
8200 {
8201 AddWet(-GetWetMax()/5);
8202 //PrintVariables();
8203 }
8204
8205 else if (action_id == EActions.LIQUIDTYPE_UP)
8206 {
8207 int curr_type = GetLiquidType();
8208 SetLiquidType(curr_type * 2);
8209 //AddWet(1);
8210 //PrintVariables();
8211 }
8212
8213 else if (action_id == EActions.LIQUIDTYPE_DOWN)
8214 {
8215 int curr_type2 = GetLiquidType();
8216 SetLiquidType(curr_type2 / 2);
8217 }
8218
8219 else if (action_id == EActions.MAKE_SPECIAL)
8220 {
8221 auto debugParams = DebugSpawnParams.WithPlayer(player);
8222 OnDebugSpawnEx(debugParams);
8223 }
8224
8225 }
8226
8227
8228 return false;
8229 }
8230
8231 // -------------------------------------------------------------------------
8232
8233
8236 void OnActivatedByTripWire();
8237
8239 void OnActivatedByItem(notnull ItemBase item);
8240
8241 //----------------------------------------------------------------
8242 //returns true if item is able to explode when put in fire
8243 bool CanExplodeInFire()
8244 {
8245 return false;
8246 }
8247
8248 //----------------------------------------------------------------
8249 bool CanEat()
8250 {
8251 return true;
8252 }
8253
8254 //----------------------------------------------------------------
8255 override bool IsIgnoredByConstruction()
8256 {
8257 return true;
8258 }
8259
8260 //----------------------------------------------------------------
8261 //has FoodStages in config?
8262 bool HasFoodStage()
8263 {
8264 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
8265 return g_Game.ConfigIsExisting(config_path);
8266 }
8267
8269 FoodStage GetFoodStage()
8270 {
8271 return null;
8272 }
8273
8274 bool CanBeCooked()
8275 {
8276 return false;
8277 }
8278
8279 bool CanBeCookedOnStick()
8280 {
8281 return false;
8282 }
8283
8285 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
8287
8288 //----------------------------------------------------------------
8289 bool CanRepair(ItemBase item_repair_kit)
8290 {
8291 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8292 return module_repairing.CanRepair(this, item_repair_kit);
8293 }
8294
8295 //----------------------------------------------------------------
8296 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
8297 {
8298 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8299 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
8300 }
8301
8302 //----------------------------------------------------------------
8303 int GetItemSize()
8304 {
8305 /*
8306 vector v_size = this.ConfigGetVector("itemSize");
8307 int v_size_x = v_size[0];
8308 int v_size_y = v_size[1];
8309 int size = v_size_x * v_size_y;
8310 return size;
8311 */
8312
8313 return 1;
8314 }
8315
8316 //----------------------------------------------------------------
8317 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
8318 bool CanBeMovedOverride()
8319 {
8320 return m_CanBeMovedOverride;
8321 }
8322
8323 //----------------------------------------------------------------
8324 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
8325 void SetCanBeMovedOverride(bool setting)
8326 {
8327 m_CanBeMovedOverride = setting;
8328 }
8329
8330 //----------------------------------------------------------------
8338 void MessageToOwnerStatus(string text)
8339 {
8340 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8341
8342 if (player)
8343 {
8344 player.MessageStatus(text);
8345 }
8346 }
8347
8348 //----------------------------------------------------------------
8356 void MessageToOwnerAction(string text)
8357 {
8358 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8359
8360 if (player)
8361 {
8362 player.MessageAction(text);
8363 }
8364 }
8365
8366 //----------------------------------------------------------------
8374 void MessageToOwnerFriendly(string text)
8375 {
8376 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8377
8378 if (player)
8379 {
8380 player.MessageFriendly(text);
8381 }
8382 }
8383
8384 //----------------------------------------------------------------
8392 void MessageToOwnerImportant(string text)
8393 {
8394 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8395
8396 if (player)
8397 {
8398 player.MessageImportant(text);
8399 }
8400 }
8401
8402 override bool IsItemBase()
8403 {
8404 return true;
8405 }
8406
8407 // Checks if item is of questioned kind
8408 override bool KindOf(string tag)
8409 {
8410 bool found = false;
8411 string item_name = this.GetType();
8412 ref TStringArray item_tag_array = new TStringArray;
8413 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
8414
8415 int array_size = item_tag_array.Count();
8416 for (int i = 0; i < array_size; i++)
8417 {
8418 if (item_tag_array.Get(i) == tag)
8419 {
8420 found = true;
8421 break;
8422 }
8423 }
8424 return found;
8425 }
8426
8427
8428 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
8429 {
8430 //Debug.Log("OnRPC called");
8431 super.OnRPC(sender, rpc_type,ctx);
8432
8433 //Play soundset for attachment locking (ActionLockAttachment.c)
8434 switch (rpc_type)
8435 {
8436 #ifndef SERVER
8437 case ERPCs.RPC_SOUND_LOCK_ATTACH:
8438 Param2<bool, string> p = new Param2<bool, string>(false, "");
8439
8440 if (!ctx.Read(p))
8441 return;
8442
8443 bool play = p.param1;
8444 string soundSet = p.param2;
8445
8446 if (play)
8447 {
8448 if (m_LockingSound)
8449 {
8451 {
8452 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
8453 }
8454 }
8455 else
8456 {
8457 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
8458 }
8459 }
8460 else
8461 {
8462 SEffectManager.DestroyEffect(m_LockingSound);
8463 }
8464
8465 break;
8466 #endif
8467
8468 }
8469
8470 if (GetWrittenNoteData())
8471 {
8472 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
8473 }
8474 }
8475
8476 //-----------------------------
8477 // VARIABLE MANIPULATION SYSTEM
8478 //-----------------------------
8479 int NameToID(string name)
8480 {
8481 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
8482 return plugin.GetID(name);
8483 }
8484
8485 string IDToName(int id)
8486 {
8487 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
8488 return plugin.GetName(id);
8489 }
8490
8492 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
8493 {
8494 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
8495 //read the flags
8496 int varFlags;
8497 if (!ctx.Read(varFlags))
8498 return;
8499
8500 if (varFlags & ItemVariableFlags.FLOAT)
8501 {
8502 ReadVarsFromCTX(ctx);
8503 }
8504 }
8505
8506 override void SerializeNumericalVars(array<float> floats_out)
8507 {
8508 //some variables handled on EntityAI level already!
8509 super.SerializeNumericalVars(floats_out);
8510
8511 // the order of serialization must be the same as the order of de-serialization
8512 //--------------------------------------------
8513 if (IsVariableSet(VARIABLE_QUANTITY))
8514 {
8515 floats_out.Insert(m_VarQuantity);
8516 }
8517 //--------------------------------------------
8518 if (IsVariableSet(VARIABLE_WET))
8519 {
8520 floats_out.Insert(m_VarWet);
8521 }
8522 //--------------------------------------------
8523 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
8524 {
8525 floats_out.Insert(m_VarLiquidType);
8526 }
8527 //--------------------------------------------
8528 if (IsVariableSet(VARIABLE_COLOR))
8529 {
8530 floats_out.Insert(m_ColorComponentR);
8531 floats_out.Insert(m_ColorComponentG);
8532 floats_out.Insert(m_ColorComponentB);
8533 floats_out.Insert(m_ColorComponentA);
8534 }
8535 //--------------------------------------------
8536 if (IsVariableSet(VARIABLE_CLEANNESS))
8537 {
8538 floats_out.Insert(m_Cleanness);
8539 }
8540 }
8541
8542 override void DeSerializeNumericalVars(array<float> floats)
8543 {
8544 //some variables handled on EntityAI level already!
8545 super.DeSerializeNumericalVars(floats);
8546
8547 // the order of serialization must be the same as the order of de-serialization
8548 int index = 0;
8549 int mask = Math.Round(floats.Get(index));
8550
8551 index++;
8552 //--------------------------------------------
8553 if (mask & VARIABLE_QUANTITY)
8554 {
8555 if (m_IsStoreLoad)
8556 {
8557 SetStoreLoadedQuantity(floats.Get(index));
8558 }
8559 else
8560 {
8561 float quantity = floats.Get(index);
8562 SetQuantity(quantity, true, false, false, false);
8563 }
8564 index++;
8565 }
8566 //--------------------------------------------
8567 if (mask & VARIABLE_WET)
8568 {
8569 float wet = floats.Get(index);
8570 SetWet(wet);
8571 index++;
8572 }
8573 //--------------------------------------------
8574 if (mask & VARIABLE_LIQUIDTYPE)
8575 {
8576 int liquidtype = Math.Round(floats.Get(index));
8577 SetLiquidType(liquidtype);
8578 index++;
8579 }
8580 //--------------------------------------------
8581 if (mask & VARIABLE_COLOR)
8582 {
8583 m_ColorComponentR = Math.Round(floats.Get(index));
8584 index++;
8585 m_ColorComponentG = Math.Round(floats.Get(index));
8586 index++;
8587 m_ColorComponentB = Math.Round(floats.Get(index));
8588 index++;
8589 m_ColorComponentA = Math.Round(floats.Get(index));
8590 index++;
8591 }
8592 //--------------------------------------------
8593 if (mask & VARIABLE_CLEANNESS)
8594 {
8595 int cleanness = Math.Round(floats.Get(index));
8596 SetCleanness(cleanness);
8597 index++;
8598 }
8599 }
8600
8601 override void WriteVarsToCTX(ParamsWriteContext ctx)
8602 {
8603 super.WriteVarsToCTX(ctx);
8604
8605 //--------------------------------------------
8606 if (IsVariableSet(VARIABLE_QUANTITY))
8607 {
8608 ctx.Write(GetQuantity());
8609 }
8610 //--------------------------------------------
8611 if (IsVariableSet(VARIABLE_WET))
8612 {
8613 ctx.Write(GetWet());
8614 }
8615 //--------------------------------------------
8616 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
8617 {
8618 ctx.Write(GetLiquidType());
8619 }
8620 //--------------------------------------------
8621 if (IsVariableSet(VARIABLE_COLOR))
8622 {
8623 int r,g,b,a;
8624 GetColor(r,g,b,a);
8625 ctx.Write(r);
8626 ctx.Write(g);
8627 ctx.Write(b);
8628 ctx.Write(a);
8629 }
8630 //--------------------------------------------
8631 if (IsVariableSet(VARIABLE_CLEANNESS))
8632 {
8633 ctx.Write(GetCleanness());
8634 }
8635 }
8636
8637 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
8638 {
8639 if (!super.ReadVarsFromCTX(ctx,version))
8640 return false;
8641
8642 int intValue;
8643 float value;
8644
8645 if (version < 140)
8646 {
8647 if (!ctx.Read(intValue))
8648 return false;
8649
8650 m_VariablesMask = intValue;
8651 }
8652
8653 if (m_VariablesMask & VARIABLE_QUANTITY)
8654 {
8655 if (!ctx.Read(value))
8656 return false;
8657
8658 if (IsStoreLoad())
8659 {
8661 }
8662 else
8663 {
8664 SetQuantity(value, true, false, false, false);
8665 }
8666 }
8667 //--------------------------------------------
8668 if (version < 140)
8669 {
8670 if (m_VariablesMask & VARIABLE_TEMPERATURE)
8671 {
8672 if (!ctx.Read(value))
8673 return false;
8674 SetTemperatureDirect(value);
8675 }
8676 }
8677 //--------------------------------------------
8678 if (m_VariablesMask & VARIABLE_WET)
8679 {
8680 if (!ctx.Read(value))
8681 return false;
8682 SetWet(value);
8683 }
8684 //--------------------------------------------
8685 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
8686 {
8687 if (!ctx.Read(intValue))
8688 return false;
8689 SetLiquidType(intValue);
8690 }
8691 //--------------------------------------------
8692 if (m_VariablesMask & VARIABLE_COLOR)
8693 {
8694 int r,g,b,a;
8695 if (!ctx.Read(r))
8696 return false;
8697 if (!ctx.Read(g))
8698 return false;
8699 if (!ctx.Read(b))
8700 return false;
8701 if (!ctx.Read(a))
8702 return false;
8703
8704 SetColor(r,g,b,a);
8705 }
8706 //--------------------------------------------
8707 if (m_VariablesMask & VARIABLE_CLEANNESS)
8708 {
8709 if (!ctx.Read(intValue))
8710 return false;
8711 SetCleanness(intValue);
8712 }
8713 //--------------------------------------------
8714 if (version >= 138 && version < 140)
8715 {
8716 if (m_VariablesMask & VARIABLE_TEMPERATURE)
8717 {
8718 if (!ctx.Read(intValue))
8719 return false;
8720 SetFrozen(intValue);
8721 }
8722 }
8723
8724 return true;
8725 }
8726
8727 //----------------------------------------------------------------
8728 override bool OnStoreLoad(ParamsReadContext ctx, int version)
8729 {
8730 m_IsStoreLoad = true;
8732 {
8733 m_FixDamageSystemInit = true;
8734 }
8735
8736 if (!super.OnStoreLoad(ctx, version))
8737 {
8738 m_IsStoreLoad = false;
8739 return false;
8740 }
8741
8742 if (version >= 114)
8743 {
8744 bool hasQuickBarIndexSaved;
8745
8746 if (!ctx.Read(hasQuickBarIndexSaved))
8747 {
8748 m_IsStoreLoad = false;
8749 return false;
8750 }
8751
8752 if (hasQuickBarIndexSaved)
8753 {
8754 int itmQBIndex;
8755
8756 //Load quickbar item bind
8757 if (!ctx.Read(itmQBIndex))
8758 {
8759 m_IsStoreLoad = false;
8760 return false;
8761 }
8762
8763 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
8764 if (itmQBIndex != -1 && parentPlayer)
8765 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
8766 }
8767 }
8768 else
8769 {
8770 // Backup of how it used to be
8771 PlayerBase player;
8772 int itemQBIndex;
8773 if (version == int.MAX)
8774 {
8775 if (!ctx.Read(itemQBIndex))
8776 {
8777 m_IsStoreLoad = false;
8778 return false;
8779 }
8780 }
8781 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
8782 {
8783 //Load quickbar item bind
8784 if (!ctx.Read(itemQBIndex))
8785 {
8786 m_IsStoreLoad = false;
8787 return false;
8788 }
8789 if (itemQBIndex != -1 && player)
8790 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
8791 }
8792 }
8793
8794 if (version < 140)
8795 {
8796 // variable management system
8797 if (!LoadVariables(ctx, version))
8798 {
8799 m_IsStoreLoad = false;
8800 return false;
8801 }
8802 }
8803
8804 //agent trasmission system
8805 if (!LoadAgents(ctx, version))
8806 {
8807 m_IsStoreLoad = false;
8808 return false;
8809 }
8810 if (version >= 132)
8811 {
8812 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
8813 if (raib)
8814 {
8815 if (!raib.OnStoreLoad(ctx,version))
8816 {
8817 m_IsStoreLoad = false;
8818 return false;
8819 }
8820 }
8821 }
8822
8823 m_IsStoreLoad = false;
8824 return true;
8825 }
8826
8827 //----------------------------------------------------------------
8828
8829 override void OnStoreSave(ParamsWriteContext ctx)
8830 {
8831 super.OnStoreSave(ctx);
8832
8833 PlayerBase player;
8834 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
8835 {
8836 ctx.Write(true); // Keep track of if we should actually read this in or not
8837 //Save quickbar item bind
8838 int itemQBIndex = -1;
8839 itemQBIndex = player.FindQuickBarEntityIndex(this);
8840 ctx.Write(itemQBIndex);
8841 }
8842 else
8843 {
8844 ctx.Write(false); // Keep track of if we should actually read this in or not
8845 }
8846
8847 SaveAgents(ctx);//agent trasmission system
8848
8849 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
8850 if (raib)
8851 {
8852 raib.OnStoreSave(ctx);
8853 }
8854 }
8855 //----------------------------------------------------------------
8856
8857 override void AfterStoreLoad()
8858 {
8859 super.AfterStoreLoad();
8860
8862 {
8864 }
8865
8866 if (GetStoreLoadedQuantity() != float.LOWEST)
8867 {
8869 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
8870 }
8871 }
8872
8873 override void EEOnAfterLoad()
8874 {
8875 super.EEOnAfterLoad();
8876
8878 {
8879 m_FixDamageSystemInit = false;
8880 }
8881
8884 }
8885
8886 bool CanBeDisinfected()
8887 {
8888 return false;
8889 }
8890
8891
8892 //----------------------------------------------------------------
8893 override void OnVariablesSynchronized()
8894 {
8895 if (m_Initialized)
8896 {
8897 #ifdef PLATFORM_CONSOLE
8898 //bruteforce it is
8899 if (IsSplitable())
8900 {
8901 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
8902 if (menu)
8903 {
8904 menu.Refresh();
8905 }
8906 }
8907 #endif
8908 }
8909
8911 {
8912 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
8913 m_WantPlayImpactSound = false;
8914 }
8915
8917 {
8918 SetWeightDirty();
8920 }
8921 if (m_VarWet != m_VarWetPrev)
8922 {
8925 }
8926
8927 if (m_SoundSyncPlay != 0)
8928 {
8931
8932 m_SoundSyncPlay = 0;
8933 m_SoundSyncSlotID = -1;
8934 }
8935 if (m_SoundSyncStop != 0)
8936 {
8938 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
8939 m_SoundSyncStop = 0;
8940 }
8941
8942 super.OnVariablesSynchronized();
8943 }
8944
8945 //------------------------- Quantity
8946 //----------------------------------------------------------------
8948 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
8949 {
8950 if (!IsServerCheck(allow_client))
8951 return false;
8952
8953 if (!HasQuantity())
8954 return false;
8955
8956 float min = GetQuantityMin();
8957 float max = GetQuantityMax();
8958
8959 if (value <= (min + 0.001))
8960 value = min;
8961
8962 if (value == min)
8963 {
8964 if (destroy_config)
8965 {
8966 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
8967 if (dstr)
8968 {
8969 m_VarQuantity = Math.Clamp(value, min, max);
8970 this.Delete();
8971 return true;
8972 }
8973 }
8974 else if (destroy_forced)
8975 {
8976 m_VarQuantity = Math.Clamp(value, min, max);
8977 this.Delete();
8978 return true;
8979 }
8980 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
8981 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
8982 }
8983
8984 float delta = m_VarQuantity;
8985 m_VarQuantity = Math.Clamp(value, min, max);
8986
8987 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
8988 {
8989 EntityAI parent = GetHierarchyRoot();
8990 InventoryLocation iLoc = new InventoryLocation();
8991 GetInventory().GetCurrentInventoryLocation(iLoc);
8992 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
8993 {
8994 int iLocSlot = iLoc.GetSlot();
8995 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
8996 {
8997 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
8998 }
8999 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
9000 {
9001 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
9002 }
9003 }
9004 }
9005
9006 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
9007 {
9008 delta = m_VarQuantity - delta;
9009
9010 if (delta)
9011 OnQuantityChanged(delta);
9012 }
9013
9014 SetVariableMask(VARIABLE_QUANTITY);
9015
9016 return false;
9017 }
9018
9019 //----------------------------------------------------------------
9021 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
9022 {
9023 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
9024 }
9025 //----------------------------------------------------------------
9026 void SetQuantityMax()
9027 {
9028 float max = GetQuantityMax();
9029 SetQuantity(max);
9030 }
9031
9032 override void SetQuantityToMinimum()
9033 {
9034 float min = GetQuantityMin();
9035 SetQuantity(min);
9036 }
9037 //----------------------------------------------------------------
9039 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
9040 {
9041 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
9042 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
9043 SetQuantity(result, destroy_config, destroy_forced);
9044 }
9045
9046 //----------------------------------------------------------------
9048 override float GetQuantityNormalized()
9049 {
9050 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
9051 }
9052
9054 {
9055 return GetQuantityNormalized();
9056 }
9057
9058 /*void SetAmmoNormalized(float value)
9059 {
9060 float value_clamped = Math.Clamp(value, 0, 1);
9061 Magazine this_mag = Magazine.Cast(this);
9062 int max_rounds = this_mag.GetAmmoMax();
9063 int result = value * max_rounds;//can the rounded if higher precision is required
9064 this_mag.SetAmmoCount(result);
9065 }*/
9066 //----------------------------------------------------------------
9067 override int GetQuantityMax()
9068 {
9069 int slot = -1;
9070 GameInventory inventory = GetInventory();
9071 if (inventory)
9072 {
9073 InventoryLocation il = new InventoryLocation;
9074 inventory.GetCurrentInventoryLocation(il);
9075 slot = il.GetSlot();
9076 }
9077
9078 return GetTargetQuantityMax(slot);
9079 }
9080
9081 override int GetTargetQuantityMax(int attSlotID = -1)
9082 {
9083 float quantity_max = 0;
9084
9085 if (IsSplitable()) //only stackable/splitable items can check for stack size
9086 {
9087 if (attSlotID != -1)
9088 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
9089
9090 if (quantity_max <= 0)
9091 quantity_max = m_VarStackMax;
9092 }
9093
9094 if (quantity_max <= 0)
9095 quantity_max = m_VarQuantityMax;
9096
9097 return quantity_max;
9098 }
9099 //----------------------------------------------------------------
9100 override int GetQuantityMin()
9101 {
9102 return m_VarQuantityMin;
9103 }
9104 //----------------------------------------------------------------
9105 int GetQuantityInit()
9106 {
9107 return m_VarQuantityInit;
9108 }
9109
9110 //----------------------------------------------------------------
9111 override bool HasQuantity()
9112 {
9113 return !(GetQuantityMax() - GetQuantityMin() == 0);
9114 }
9115
9116 override float GetQuantity()
9117 {
9118 return m_VarQuantity;
9119 }
9120
9121 bool IsFullQuantity()
9122 {
9123 return GetQuantity() >= GetQuantityMax();
9124 }
9125
9126 //Calculates weight of single item without attachments and cargo
9127 override float GetSingleInventoryItemWeightEx()
9128 {
9129 //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
9130 float weightEx = GetWeightEx();//overall weight of the item
9131 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
9132 return weightEx - special;
9133 }
9134
9135 // Obsolete, use GetSingleInventoryItemWeightEx() instead
9137 {
9139 }
9140
9141 override protected float GetWeightSpecialized(bool forceRecalc = false)
9142 {
9143 if (IsSplitable()) //quantity determines size of the stack
9144 {
9145 #ifdef DEVELOPER
9146 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9147 {
9148 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
9149 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
9150 }
9151 #endif
9152
9153 return GetQuantity() * GetConfigWeightModified();
9154 }
9155 else if (HasEnergyManager())// items with energy manager
9156 {
9157 #ifdef DEVELOPER
9158 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9159 {
9160 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
9161 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
9162 }
9163 #endif
9164 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
9165 }
9166 else//everything else
9167 {
9168 #ifdef DEVELOPER
9169 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9170 {
9171 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
9172 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
9173 }
9174 #endif
9175 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
9176 }
9177 }
9178
9180 int GetNumberOfItems()
9181 {
9182 int item_count = 0;
9183 ItemBase item;
9184
9185 GameInventory inventory = GetInventory();
9186 CargoBase cargo = inventory.GetCargo();
9187 if (cargo != NULL)
9188 {
9189 item_count = cargo.GetItemCount();
9190 }
9191
9192 int nAttachments = inventory.AttachmentCount();
9193 for (int i = 0; i < nAttachments; ++i)
9194 {
9195 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
9196 if (item)
9197 item_count += item.GetNumberOfItems();
9198 }
9199 return item_count;
9200 }
9201
9203 float GetUnitWeight(bool include_wetness = true)
9204 {
9205 float weight = 0;
9206 float wetness = 1;
9207 if (include_wetness)
9208 wetness += GetWet();
9209 if (IsSplitable()) //quantity determines size of the stack
9210 {
9211 weight = wetness * m_ConfigWeight;
9212 }
9213 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
9214 {
9215 weight = 1;
9216 }
9217 return weight;
9218 }
9219
9220 //-----------------------------------------------------------------
9221
9222 override void ClearInventory()
9223 {
9224 GameInventory inventory = GetInventory();
9225 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
9226 {
9227 array<EntityAI> items = new array<EntityAI>;
9228 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
9229 for (int i = 0; i < items.Count(); ++i)
9230 {
9231 ItemBase item = ItemBase.Cast(items.Get(i));
9232 if (item)
9233 {
9234 g_Game.ObjectDelete(item);
9235 }
9236 }
9237 }
9238 }
9239
9240 //------------------------- Energy
9241
9242 //----------------------------------------------------------------
9243 float GetEnergy()
9244 {
9245 float energy = 0;
9246 if (HasEnergyManager())
9247 {
9248 energy = GetCompEM().GetEnergy();
9249 }
9250 return energy;
9251 }
9252
9253
9254 override void OnEnergyConsumed()
9255 {
9256 super.OnEnergyConsumed();
9257
9259 }
9260
9261 override void OnEnergyAdded()
9262 {
9263 super.OnEnergyAdded();
9264
9266 }
9267
9268 // Converts energy (from Energy Manager) to quantity, if enabled.
9270 {
9271 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
9272 {
9273 if (HasQuantity())
9274 {
9275 float energy_0to1 = GetCompEM().GetEnergy0To1();
9276 SetQuantityNormalized(energy_0to1);
9277 }
9278 }
9279 }
9280
9281 //----------------------------------------------------------------
9282 float GetHeatIsolationInit()
9283 {
9284 return ConfigGetFloat("heatIsolation");
9285 }
9286
9287 float GetHeatIsolation()
9288 {
9289 return m_HeatIsolation;
9290 }
9291
9292 float GetDryingIncrement(string pIncrementName)
9293 {
9294 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
9295 if (g_Game.ConfigIsExisting(paramPath))
9296 return g_Game.ConfigGetFloat(paramPath);
9297
9298 return 0.0;
9299 }
9300
9301 float GetSoakingIncrement(string pIncrementName)
9302 {
9303 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
9304 if (g_Game.ConfigIsExisting(paramPath))
9305 return g_Game.ConfigGetFloat(paramPath);
9306
9307 return 0.0;
9308 }
9309 //----------------------------------------------------------------
9310 override void SetWet(float value, bool allow_client = false)
9311 {
9312 if (!IsServerCheck(allow_client))
9313 return;
9314
9315 float min = GetWetMin();
9316 float max = GetWetMax();
9317
9318 float previousValue = m_VarWet;
9319
9320 m_VarWet = Math.Clamp(value, min, max);
9321
9322 if (previousValue != m_VarWet)
9323 {
9324 SetVariableMask(VARIABLE_WET);
9325 OnWetChanged(m_VarWet, previousValue);
9326 }
9327 }
9328 //----------------------------------------------------------------
9329 override void AddWet(float value)
9330 {
9331 SetWet(GetWet() + value);
9332 }
9333 //----------------------------------------------------------------
9334 override void SetWetMax()
9335 {
9337 }
9338 //----------------------------------------------------------------
9339 override float GetWet()
9340 {
9341 return m_VarWet;
9342 }
9343 //----------------------------------------------------------------
9344 override float GetWetMax()
9345 {
9346 return m_VarWetMax;
9347 }
9348 //----------------------------------------------------------------
9349 override float GetWetMin()
9350 {
9351 return m_VarWetMin;
9352 }
9353 //----------------------------------------------------------------
9354 override float GetWetInit()
9355 {
9356 return m_VarWetInit;
9357 }
9358 //----------------------------------------------------------------
9359 override void OnWetChanged(float newVal, float oldVal)
9360 {
9361 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
9362 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
9363 if (newLevel != oldLevel)
9364 {
9365 OnWetLevelChanged(newLevel,oldLevel);
9366 }
9367 }
9368
9369 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
9370 {
9371 SetWeightDirty();
9372 }
9373
9374 override EWetnessLevel GetWetLevel()
9375 {
9376 return GetWetLevelInternal(m_VarWet);
9377 }
9378
9379 //----------------------------------------------------------------
9380
9381 override void SetStoreLoad(bool value)
9382 {
9383 m_IsStoreLoad = value;
9384 }
9385
9386 override bool IsStoreLoad()
9387 {
9388 return m_IsStoreLoad;
9389 }
9390
9391 override void SetStoreLoadedQuantity(float value)
9392 {
9393 m_StoreLoadedQuantity = value;
9394 }
9395
9396 override float GetStoreLoadedQuantity()
9397 {
9398 return m_StoreLoadedQuantity;
9399 }
9400
9401 //----------------------------------------------------------------
9402
9403 float GetItemModelLength()
9404 {
9405 if (ConfigIsExisting("itemModelLength"))
9406 {
9407 return ConfigGetFloat("itemModelLength");
9408 }
9409 return 0;
9410 }
9411
9412 float GetItemAttachOffset()
9413 {
9414 if (ConfigIsExisting("itemAttachOffset"))
9415 {
9416 return ConfigGetFloat("itemAttachOffset");
9417 }
9418 return 0;
9419 }
9420
9421 override void SetCleanness(int value, bool allow_client = false)
9422 {
9423 if (!IsServerCheck(allow_client))
9424 return;
9425
9426 int previousValue = m_Cleanness;
9427
9428 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
9429
9430 if (previousValue != m_Cleanness)
9431 SetVariableMask(VARIABLE_CLEANNESS);
9432 }
9433
9434 override int GetCleanness()
9435 {
9436 return m_Cleanness;
9437 }
9438
9440 {
9441 return true;
9442 }
9443
9444 //----------------------------------------------------------------
9445 // ATTACHMENT LOCKING
9446 // Getters relevant to generic ActionLockAttachment
9447 int GetLockType()
9448 {
9449 return m_LockType;
9450 }
9451
9452 string GetLockSoundSet()
9453 {
9454 return m_LockSoundSet;
9455 }
9456
9457 //----------------------------------------------------------------
9458 //------------------------- Color
9459 // sets items color variable given color components
9460 override void SetColor(int r, int g, int b, int a)
9461 {
9466 SetVariableMask(VARIABLE_COLOR);
9467 }
9469 override void GetColor(out int r,out int g,out int b,out int a)
9470 {
9475 }
9476
9477 bool IsColorSet()
9478 {
9479 return IsVariableSet(VARIABLE_COLOR);
9480 }
9481
9483 string GetColorString()
9484 {
9485 int r,g,b,a;
9486 GetColor(r,g,b,a);
9487 r = r/255;
9488 g = g/255;
9489 b = b/255;
9490 a = a/255;
9491 return MiscGameplayFunctions.GetColorString(r, g, b, a);
9492 }
9493 //----------------------------------------------------------------
9494 //------------------------- LiquidType
9495
9496 override void SetLiquidType(int value, bool allow_client = false)
9497 {
9498 if (!IsServerCheck(allow_client))
9499 return;
9500
9501 int old = m_VarLiquidType;
9502 m_VarLiquidType = value;
9503 OnLiquidTypeChanged(old,value);
9504 SetVariableMask(VARIABLE_LIQUIDTYPE);
9505 }
9506
9507 int GetLiquidTypeInit()
9508 {
9509 return ConfigGetInt("varLiquidTypeInit");
9510 }
9511
9512 override int GetLiquidType()
9513 {
9514 return m_VarLiquidType;
9515 }
9516
9517 protected void OnLiquidTypeChanged(int oldType, int newType)
9518 {
9519 if (newType == LIQUID_NONE && GetIsFrozen())
9520 SetFrozen(false);
9521 }
9522
9524 void UpdateQuickbarShortcutVisibility(PlayerBase player)
9525 {
9526 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
9527 }
9528
9529 // -------------------------------------------------------------------------
9531 void OnInventoryEnter(Man player)
9532 {
9533 PlayerBase nplayer;
9534 if (PlayerBase.CastTo(nplayer, player))
9535 {
9536 m_CanPlayImpactSound = true;
9537 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
9538 }
9539 }
9540
9541 // -------------------------------------------------------------------------
9543 void OnInventoryExit(Man player)
9544 {
9545 PlayerBase nplayer;
9546 if (PlayerBase.CastTo(nplayer,player))
9547 {
9548 nplayer.SetEnableQuickBarEntityShortcut(this, false);
9549 }
9550
9551 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
9552
9553 if (HasEnergyManager())
9554 {
9555 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
9556 }
9557 }
9558
9559 // ADVANCED PLACEMENT EVENTS
9560 override void OnPlacementStarted(Man player)
9561 {
9562 super.OnPlacementStarted(player);
9563
9564 SetTakeable(false);
9565 }
9566
9567 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
9568 {
9569 if (m_AdminLog)
9570 {
9571 m_AdminLog.OnPlacementComplete(player, this);
9572 }
9573
9574 super.OnPlacementComplete(player, position, orientation);
9575 }
9576
9577 //-----------------------------
9578 // AGENT SYSTEM
9579 //-----------------------------
9580 //--------------------------------------------------------------------------
9581 bool ContainsAgent(int agent_id)
9582 {
9583 if (agent_id & m_AttachedAgents)
9584 {
9585 return true;
9586 }
9587 else
9588 {
9589 return false;
9590 }
9591 }
9592
9593 //--------------------------------------------------------------------------
9594 override void RemoveAgent(int agent_id)
9595 {
9596 if (ContainsAgent(agent_id))
9597 {
9598 m_AttachedAgents = ~agent_id & m_AttachedAgents;
9599 }
9600 }
9601
9602 //--------------------------------------------------------------------------
9603 override void RemoveAllAgents()
9604 {
9605 m_AttachedAgents = 0;
9606 }
9607 //--------------------------------------------------------------------------
9608 override void RemoveAllAgentsExcept(int agent_to_keep)
9609 {
9610 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
9611 }
9612 // -------------------------------------------------------------------------
9613 override void InsertAgent(int agent, float count = 1)
9614 {
9615 if (count < 1)
9616 return;
9617 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
9619 }
9620
9622 void TransferAgents(int agents)
9623 {
9625 }
9626
9627 // -------------------------------------------------------------------------
9628 override int GetAgents()
9629 {
9630 return m_AttachedAgents;
9631 }
9632 //----------------------------------------------------------------------
9633
9634 /*int GetContaminationType()
9635 {
9636 int contamination_type;
9637
9638 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
9639 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
9640 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
9641 const int DIRTY_MASK = eAgents.WOUND_AGENT;
9642
9643 Edible_Base edible = Edible_Base.Cast(this);
9644 int agents = GetAgents();
9645 if (edible)
9646 {
9647 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
9648 if (profile)
9649 {
9650 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
9651 }
9652 }
9653 if (agents & CONTAMINATED_MASK)
9654 {
9655 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
9656 }
9657 if (agents & POISONED_MASK)
9658 {
9659 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
9660 }
9661 if (agents & NERVE_GAS_MASK)
9662 {
9663 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
9664 }
9665 if (agents & DIRTY_MASK)
9666 {
9667 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
9668 }
9669
9670 return agents;
9671 }*/
9672
9673 // -------------------------------------------------------------------------
9674 bool LoadAgents(ParamsReadContext ctx, int version)
9675 {
9676 if (!ctx.Read(m_AttachedAgents))
9677 return false;
9678 return true;
9679 }
9680 // -------------------------------------------------------------------------
9682 {
9683
9685 }
9686 // -------------------------------------------------------------------------
9687
9689 override void CheckForRoofLimited(float timeTresholdMS = 3000)
9690 {
9691 super.CheckForRoofLimited(timeTresholdMS);
9692
9693 float time = g_Game.GetTime();
9694 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
9695 {
9696 m_PreviousRoofTestTime = time;
9697 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
9698 }
9699 }
9700
9701 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
9702 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
9703 {
9704 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
9705 {
9706 return 0;
9707 }
9708
9709 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
9710 {
9711 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
9712 if (filter)
9713 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
9714 else
9715 return 0;//otherwise return 0 when no filter attached
9716 }
9717
9718 string subclassPath, entryName;
9719
9720 switch (type)
9721 {
9722 case DEF_BIOLOGICAL:
9723 entryName = "biological";
9724 break;
9725 case DEF_CHEMICAL:
9726 entryName = "chemical";
9727 break;
9728 default:
9729 entryName = "biological";
9730 break;
9731 }
9732
9733 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
9734
9735 return g_Game.ConfigGetFloat(subclassPath + entryName);
9736 }
9737
9738
9739
9741 override void EEOnCECreate()
9742 {
9743 if (!IsMagazine())
9745
9747 }
9748
9749
9750 //-------------------------
9751 // OPEN/CLOSE USER ACTIONS
9752 //-------------------------
9754 void Open();
9755 void Close();
9756 bool IsOpen()
9757 {
9758 return true;
9759 }
9760
9761 override bool CanDisplayCargo()
9762 {
9763 return IsOpen();
9764 }
9765
9766
9767 // ------------------------------------------------------------
9768 // CONDITIONS
9769 // ------------------------------------------------------------
9770 override bool CanPutInCargo(EntityAI parent)
9771 {
9772 if (parent)
9773 {
9774 if (parent.IsInherited(DayZInfected))
9775 return true;
9776
9777 if (!parent.IsRuined())
9778 return true;
9779 }
9780
9781 return true;
9782 }
9783
9784 override bool CanPutAsAttachment(EntityAI parent)
9785 {
9786 if (!super.CanPutAsAttachment(parent))
9787 {
9788 return false;
9789 }
9790
9791 if (!IsRuined() && !parent.IsRuined())
9792 {
9793 return true;
9794 }
9795
9796 return false;
9797 }
9798
9799 override bool CanReceiveItemIntoCargo(EntityAI item)
9800 {
9801 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9802 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9803 // return false;
9804
9805 return super.CanReceiveItemIntoCargo(item);
9806 }
9807
9808 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
9809 {
9810 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9811 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9812 // return false;
9813
9814 GameInventory attachmentInv = attachment.GetInventory();
9815 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
9816 {
9817 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
9818 return false;
9819 }
9820
9821 InventoryLocation loc = new InventoryLocation();
9822 attachment.GetInventory().GetCurrentInventoryLocation(loc);
9823 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
9824 return false;
9825
9826 return super.CanReceiveAttachment(attachment, slotId);
9827 }
9828
9829 override bool CanReleaseAttachment(EntityAI attachment)
9830 {
9831 if (!super.CanReleaseAttachment(attachment))
9832 return false;
9833
9834 return GetInventory().AreChildrenAccessible();
9835 }
9836
9837 /*override bool CanLoadAttachment(EntityAI attachment)
9838 {
9839 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9840 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9841 // return false;
9842
9843 GameInventory attachmentInv = attachment.GetInventory();
9844 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
9845 {
9846 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
9847 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
9848
9849 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
9850 return false;
9851 }
9852
9853 return super.CanLoadAttachment(attachment);
9854 }*/
9855
9856 // Plays muzzle flash particle effects
9857 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9858 {
9859 int id = muzzle_owner.GetMuzzleID();
9860 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
9861
9862 if (WPOF_array)
9863 {
9864 for (int i = 0; i < WPOF_array.Count(); i++)
9865 {
9866 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
9867
9868 if (WPOF)
9869 {
9870 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
9871 }
9872 }
9873 }
9874 }
9875
9876 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
9877 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9878 {
9879 int id = muzzle_owner.GetMuzzleID();
9880 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
9881
9882 if (WPOBE_array)
9883 {
9884 for (int i = 0; i < WPOBE_array.Count(); i++)
9885 {
9886 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
9887
9888 if (WPOBE)
9889 {
9890 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
9891 }
9892 }
9893 }
9894 }
9895
9896 // Plays all weapon overheating particles
9897 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9898 {
9899 int id = muzzle_owner.GetMuzzleID();
9900 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
9901
9902 if (WPOOH_array)
9903 {
9904 for (int i = 0; i < WPOOH_array.Count(); i++)
9905 {
9906 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
9907
9908 if (WPOOH)
9909 {
9910 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
9911 }
9912 }
9913 }
9914 }
9915
9916 // Updates all weapon overheating particles
9917 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9918 {
9919 int id = muzzle_owner.GetMuzzleID();
9920 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
9921
9922 if (WPOOH_array)
9923 {
9924 for (int i = 0; i < WPOOH_array.Count(); i++)
9925 {
9926 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
9927
9928 if (WPOOH)
9929 {
9930 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9931 }
9932 }
9933 }
9934 }
9935
9936 // Stops overheating particles
9937 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9938 {
9939 int id = muzzle_owner.GetMuzzleID();
9940 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
9941
9942 if (WPOOH_array)
9943 {
9944 for (int i = 0; i < WPOOH_array.Count(); i++)
9945 {
9946 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
9947
9948 if (WPOOH)
9949 {
9950 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9951 }
9952 }
9953 }
9954 }
9955
9956 //----------------------------------------------------------------
9957 //Item Behaviour - unified approach
9958 override bool IsHeavyBehaviour()
9959 {
9960 if (m_ItemBehaviour == 0)
9961 {
9962 return true;
9963 }
9964
9965 return false;
9966 }
9967
9968 override bool IsOneHandedBehaviour()
9969 {
9970 if (m_ItemBehaviour == 1)
9971 {
9972 return true;
9973 }
9974
9975 return false;
9976 }
9977
9978 override bool IsTwoHandedBehaviour()
9979 {
9980 if (m_ItemBehaviour == 2)
9981 {
9982 return true;
9983 }
9984
9985 return false;
9986 }
9987
9988 bool IsDeployable()
9989 {
9990 return false;
9991 }
9992
9994 float GetDeployTime()
9995 {
9996 return UATimeSpent.DEFAULT_DEPLOY;
9997 }
9998
9999
10000 //----------------------------------------------------------------
10001 // Item Targeting (User Actions)
10002 override void SetTakeable(bool pState)
10003 {
10004 m_IsTakeable = pState;
10005 SetSynchDirty();
10006 }
10007
10008 override bool IsTakeable()
10009 {
10010 return m_IsTakeable;
10011 }
10012
10013 // For cases where we want to show object widget which cant be taken to hands
10015 {
10016 return false;
10017 }
10018
10020 protected void PreLoadSoundAttachmentType()
10021 {
10022 string att_type = "None";
10023
10024 if (ConfigIsExisting("soundAttType"))
10025 {
10026 att_type = ConfigGetString("soundAttType");
10027 }
10028
10029 m_SoundAttType = att_type;
10030 }
10031
10032 override string GetAttachmentSoundType()
10033 {
10034 return m_SoundAttType;
10035 }
10036
10037 //----------------------------------------------------------------
10038 //SOUNDS - ItemSoundHandler
10039 //----------------------------------------------------------------
10040
10041 string GetPlaceSoundset(); // played when deploy starts
10042 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
10043 string GetDeploySoundset(); // played when deploy sucessfully finishes
10044 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
10045 string GetFoldSoundset(); // played when fold sucessfully finishes
10046
10048 {
10049 if (!m_ItemSoundHandler)
10051
10052 return m_ItemSoundHandler;
10053 }
10054
10055 // override to initialize sounds
10056 protected void InitItemSounds()
10057 {
10058 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
10059 return;
10060
10062
10063 if (GetPlaceSoundset() != string.Empty)
10064 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
10065
10066 if (GetDeploySoundset() != string.Empty)
10067 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
10068
10069 SoundParameters params = new SoundParameters();
10070 params.m_Loop = true;
10071 if (GetLoopDeploySoundset() != string.Empty)
10072 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
10073 }
10074
10075 // Start sound using ItemSoundHandler
10076 void StartItemSoundServer(int id, int slotId)
10077 {
10078 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
10079 {
10080 m_SoundSyncSlotID = slotId;
10081 m_SoundSyncPlay = id;
10082
10083 SetSynchDirty();
10084
10085 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
10086 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
10087 }
10088 }
10089
10090 void StartItemSoundServer(int id)
10091 {
10092 StartItemSoundServer(id, InventorySlots.INVALID);
10093 }
10094
10095 // Stop sound using ItemSoundHandler
10096 void StopItemSoundServer(int id)
10097 {
10098 if (!g_Game.IsServer())
10099 return;
10100
10101 m_SoundSyncStop = id;
10102 SetSynchDirty();
10103
10104 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
10105 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
10106 }
10107
10108 protected void ClearStartItemSoundServer()
10109 {
10110 m_SoundSyncPlay = 0;
10111 m_SoundSyncSlotID = InventorySlots.INVALID;
10112 }
10113
10114 protected void ClearStopItemSoundServer()
10115 {
10116 m_SoundSyncStop = 0;
10117 }
10118
10119 void OnApply(PlayerBase player);
10120
10122 {
10123 return 1.0;
10124 };
10125 //returns applicable selection
10126 array<string> GetHeadHidingSelection()
10127 {
10129 }
10130
10132 {
10134 }
10135
10136 WrittenNoteData GetWrittenNoteData() {};
10137
10139 {
10140 SetDynamicPhysicsLifeTime(0.01);
10141 m_ItemBeingDroppedPhys = false;
10142 }
10143
10145 {
10146 array<string> zone_names = new array<string>;
10147 GetDamageZones(zone_names);
10148 for (int i = 0; i < zone_names.Count(); i++)
10149 {
10150 SetHealthMax(zone_names.Get(i),"Health");
10151 }
10152 SetHealthMax("","Health");
10153 }
10154
10156 void SetZoneDamageCEInit()
10157 {
10158 float global_health = GetHealth01("","Health");
10159 array<string> zones = new array<string>;
10160 GetDamageZones(zones);
10161 //set damage of all zones to match global health level
10162 for (int i = 0; i < zones.Count(); i++)
10163 {
10164 SetHealth01(zones.Get(i),"Health",global_health);
10165 }
10166 }
10167
10169 bool IsCoverFaceForShave(string slot_name)
10170 {
10171 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
10172 }
10173
10174 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10175 {
10176 if (!hasRootAsPlayer)
10177 {
10178 if (refParentIB)
10179 {
10180 // parent is wet
10181 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
10182 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
10183 // parent has liquid inside
10184 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
10185 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
10186 // drying
10187 else if (m_VarWet > m_VarWetMin)
10188 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
10189 }
10190 else
10191 {
10192 // drying on ground or inside non-itembase (car, ...)
10193 if (m_VarWet > m_VarWetMin)
10194 AddWet(-1 * delta * GetDryingIncrement("ground"));
10195 }
10196 }
10197 }
10198
10199 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10200 {
10202 {
10203 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
10204 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
10205 {
10206 float heatPermCoef = 1.0;
10207 EntityAI ent = this;
10208 while (ent)
10209 {
10210 heatPermCoef *= ent.GetHeatPermeabilityCoef();
10211 ent = ent.GetHierarchyParent();
10212 }
10213
10214 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
10215 }
10216 }
10217 }
10218
10219 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
10220 {
10221 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
10222 EntityAI parent = GetHierarchyParent();
10223 if (!parent)
10224 {
10225 hasParent = false;
10226 hasRootAsPlayer = false;
10227 }
10228 else
10229 {
10230 hasParent = true;
10231 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
10232 refParentIB = ItemBase.Cast(parent);
10233 }
10234 }
10235
10236 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
10237 {
10238 // this is stub, implemented on Edible_Base
10239 }
10240
10241 bool CanDecay()
10242 {
10243 // return true used on selected food clases so they can decay
10244 return false;
10245 }
10246
10247 protected bool CanProcessDecay()
10248 {
10249 // this is stub, implemented on Edible_Base class
10250 // used to determine whether it is still necessary for the food to decay
10251 return false;
10252 }
10253
10254 protected bool CanHaveWetness()
10255 {
10256 // return true used on selected items that have a wetness effect
10257 return false;
10258 }
10259
10261 bool CanBeConsumed(ConsumeConditionData data = null)
10262 {
10263 return !GetIsFrozen() && IsOpen();
10264 }
10265
10266 override void ProcessVariables()
10267 {
10268 bool hasParent = false, hasRootAsPlayer = false;
10269 ItemBase refParentIB;
10270
10271 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
10272 bool foodDecay = g_Game.IsFoodDecayEnabled();
10273
10274 if (wwtu || foodDecay)
10275 {
10276 bool processWetness = wwtu && CanHaveWetness();
10277 bool processTemperature = wwtu && CanHaveTemperature();
10278 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
10279
10280 if (processWetness || processTemperature || processDecay)
10281 {
10282 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
10283
10284 if (processWetness)
10285 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10286
10287 if (processTemperature)
10288 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10289
10290 if (processDecay)
10291 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
10292 }
10293 }
10294 }
10295
10298 {
10299 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
10300 }
10301
10302 override float GetTemperatureFreezeThreshold()
10303 {
10305 return Liquid.GetFreezeThreshold(GetLiquidType());
10306
10307 return super.GetTemperatureFreezeThreshold();
10308 }
10309
10310 override float GetTemperatureThawThreshold()
10311 {
10313 return Liquid.GetThawThreshold(GetLiquidType());
10314
10315 return super.GetTemperatureThawThreshold();
10316 }
10317
10318 override float GetItemOverheatThreshold()
10319 {
10321 return Liquid.GetBoilThreshold(GetLiquidType());
10322
10323 return super.GetItemOverheatThreshold();
10324 }
10325
10326 override float GetTemperatureFreezeTime()
10327 {
10328 if (HasQuantity())
10329 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
10330
10331 return super.GetTemperatureFreezeTime();
10332 }
10333
10334 override float GetTemperatureThawTime()
10335 {
10336 if (HasQuantity())
10337 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
10338
10339 return super.GetTemperatureThawTime();
10340 }
10341
10343 void AffectLiquidContainerOnFill(int liquid_type, float amount);
10345 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
10346
10347 bool IsCargoException4x3(EntityAI item)
10348 {
10349 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
10350 }
10351
10353 {
10354 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
10355 }
10356
10358 void AddLightSourceItem(ItemBase lightsource)
10359 {
10360 m_LightSourceItem = lightsource;
10361 }
10362
10364 {
10365 m_LightSourceItem = null;
10366 }
10367
10369 {
10370 return m_LightSourceItem;
10371 }
10372
10374 array<int> GetValidFinishers()
10375 {
10376 return null;
10377 }
10378
10380 bool GetActionWidgetOverride(out typename name)
10381 {
10382 return false;
10383 }
10384
10385 bool PairWithDevice(notnull ItemBase otherDevice)
10386 {
10387 if (g_Game.IsServer())
10388 {
10389 ItemBase explosive = otherDevice;
10391 if (!trg)
10392 {
10393 trg = RemoteDetonatorTrigger.Cast(otherDevice);
10394 explosive = this;
10395 }
10396
10397 explosive.PairRemote(trg);
10398 trg.SetControlledDevice(explosive);
10399
10400 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
10401 trg.SetPersistentPairID(persistentID);
10402 explosive.SetPersistentPairID(persistentID);
10403
10404 return true;
10405 }
10406 return false;
10407 }
10408
10410 float GetBaitEffectivity()
10411 {
10412 float ret = 1.0;
10413 if (HasQuantity())
10414 ret *= GetQuantityNormalized();
10415 ret *= GetHealth01();
10416
10417 return ret;
10418 }
10419
10420 #ifdef DEVELOPER
10421 override void SetDebugItem()
10422 {
10423 super.SetDebugItem();
10424 _itemBase = this;
10425 }
10426
10427 override string GetDebugText()
10428 {
10429 string text = super.GetDebugText();
10430
10431 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
10432 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
10433
10434 return text;
10435 }
10436 #endif
10437
10438 bool CanBeUsedForSuicide()
10439 {
10440 return true;
10441 }
10442
10444 //DEPRECATED BELOW
10446 // Backwards compatibility
10447 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10448 {
10449 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
10450 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
10451 }
10452
10453 // replaced by ItemSoundHandler
10454 protected EffectSound m_SoundDeployFinish;
10455 protected EffectSound m_SoundPlace;
10456 protected EffectSound m_DeployLoopSoundEx;
10457 protected EffectSound m_SoundDeploy;
10458 bool m_IsPlaceSound;
10459 bool m_IsDeploySound;
10461
10462 string GetDeployFinishSoundset();
10463 void PlayDeploySound();
10464 void PlayDeployFinishSound();
10465 void PlayPlaceSound();
10466 void PlayDeployLoopSoundEx();
10467 void StopDeployLoopSoundEx();
10468 void SoundSynchRemoteReset();
10469 void SoundSynchRemote();
10470 bool UsesGlobalDeploy(){return false;}
10471 bool CanPlayDeployLoopSound(){return false;}
10473 bool IsPlaceSound(){return m_IsPlaceSound;}
10474 bool IsDeploySound(){return m_IsDeploySound;}
10475 void SetIsPlaceSound(bool is_place_sound);
10476 void SetIsDeploySound(bool is_deploy_sound);
10477
10478 [Obsolete("Use ItemSoundHandler instead")]
10480 void PlayAttachSound(string slot_type)
10481 {
10482 if (!g_Game.IsDedicatedServer())
10483 {
10484 if (ConfigIsExisting("attachSoundSet"))
10485 {
10486 string cfg_path = "";
10487 string soundset = "";
10488 string type_name = GetType();
10489
10490 TStringArray cfg_soundset_array = new TStringArray;
10491 TStringArray cfg_slot_array = new TStringArray;
10492 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
10493 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
10494
10495 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
10496 {
10497 for (int i = 0; i < cfg_soundset_array.Count(); i++)
10498 {
10499 if (cfg_slot_array[i] == slot_type)
10500 {
10501 soundset = cfg_soundset_array[i];
10502 break;
10503 }
10504 }
10505 }
10506
10507 if (soundset != "")
10508 {
10509 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
10510 sound.SetAutodestroy(true);
10511 }
10512 }
10513 }
10514 }
10515
10516 void PlayDetachSound(string slot_type) {}
10517}
10518
10519EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
10520{
10521 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
10522 if (entity)
10523 {
10524 bool is_item = entity.IsInherited(ItemBase);
10525 if (is_item && full_quantity)
10526 {
10527 ItemBase item = ItemBase.Cast(entity);
10528 item.SetQuantity(item.GetQuantityInit());
10529 }
10530 }
10531 else
10532 {
10533 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
10534 return NULL;
10535 }
10536 return entity;
10537}
10538
10539void SetupSpawnedItem(ItemBase item, float health, float quantity)
10540{
10541 if (item)
10542 {
10543 if (health > 0)
10544 item.SetHealth("", "", health);
10545
10546 if (item.CanHaveTemperature())
10547 {
10548 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
10549 if (item.CanFreeze())
10550 item.SetFrozen(false);
10551 }
10552
10553 if (item.HasEnergyManager())
10554 {
10555 if (quantity >= 0)
10556 {
10557 item.GetCompEM().SetEnergy0To1(quantity);
10558 }
10559 else
10560 {
10561 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
10562 }
10563 }
10564 else if (item.IsMagazine())
10565 {
10566 Magazine mag = Magazine.Cast(item);
10567 if (quantity >= 0)
10568 {
10569 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
10570 }
10571 else
10572 {
10573 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
10574 }
10575
10576 }
10577 else
10578 {
10579 if (quantity >= 0)
10580 {
10581 item.SetQuantityNormalized(quantity, false);
10582 }
10583 else
10584 {
10585 item.SetQuantity(Math.AbsFloat(quantity));
10586 }
10587
10588 }
10589 }
10590}
10591
10592#ifdef DEVELOPER
10593ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
10594#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Param3 TSelectableActionInfo
EWetnessLevel
Определения 3_Game/DayZ/Entities/EntityAI.c:2
bool SetAttachSoundEvent()
void InventoryItemType()
bool SetDetachSoundEvent()
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
const int INPUT_UDT_ITEM_MANIPULATION
class LogManager EntityAI
eBleedingSourceType GetType()
ItemSuppressor SuppressorBase
void ActionDropItem()
Определения ActionDropItem.c:34
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Определения ActionManagerClient.c:1
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void RemoveAction(typename actionName)
Определения AdvancedCommunication.c:252
TInputActionMap m_InputActionMap
Определения AdvancedCommunication.c:137
bool m_ActionsInitialize
Определения AdvancedCommunication.c:138
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Определения AdvancedCommunication.c:202
void InitializeActions()
Определения AdvancedCommunication.c:190
string Debug()
Определения CachedEquipmentStorageBase.c:29
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:36
const int RF_DEFAULT
Определения CentralEconomy.c:65
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
Open
Implementations only.
override void EEOnCECreate()
Определения ContaminatedArea_Dynamic.c:42
map
Определения ControlsXboxNew.c:4
CookingMethodType
Определения Cooking.c:2
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
DayZGame g_Game
Определения DayZGame.c:3942
DayZGame GetDayZGame()
Определения DayZGame.c:3944
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
PluginAdminLog m_AdminLog
Определения EmoteManager.c:159
const int MIN
Определения EnConvert.c:28
const int MAX
Определения EnConvert.c:27
float GetTemperature()
Определения Environment.c:500
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool IsPrepareToDelete()
Определения FireplaceBase.c:643
override bool CanHaveTemperature()
Определения FireplaceBase.c:561
class GP5GasMask extends MaskBase ItemBase
proto GizmoApi GetGizmoApi()
Empty
Определения Hand_States.c:14
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool DamageItemInCargo(float damage)
Определения ItemBase.c:6453
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5680
bool HidesSelectionBySlot()
Определения ItemBase.c:9413
float m_VarWetMin
Определения ItemBase.c:4937
void SplitItem(PlayerBase player)
Определения ItemBase.c:6908
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9634
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8895
override float GetQuantityNormalized()
Gets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8330
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5685
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:9038
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6875
override bool IsHeavyBehaviour()
Определения ItemBase.c:9240
override void SetWetMax()
Определения ItemBase.c:8616
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9451
void ClearStartItemSoundServer()
Определения ItemBase.c:9390
float m_VarWet
Определения ItemBase.c:4934
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9481
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:3
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8890
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4997
bool CanBeMovedOverride()
Определения ItemBase.c:7600
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8592
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4983
void StartItemSoundServer(int id, int slotId)
Определения ItemBase.c:9358
override void ProcessVariables()
Определения ItemBase.c:9548
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:5011
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8423
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8956
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8806
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5271
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:5009
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9584
bool m_IsSoundSynchRemote
Определения ItemBase.c:9742
float m_OverheatingShots
Определения ItemBase.c:5004
void StopItemSoundServer(int id)
Определения ItemBase.c:9378
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5700
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5424
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9608
ref array< int > m_CompatibleLocks
Определения ItemBase.c:5021
bool CanBeCooked()
Определения ItemBase.c:7556
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5767
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:5035
bool m_RecipesInitialized
Определения ItemBase.c:4919
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6546
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9592
override void OnEnergyConsumed()
Определения ItemBase.c:8536
void RefreshAudioVisualsOnClient(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
cooking-related effect methods
Определения Bottle_Base.c:158
int GetNumberOfItems()
Returns the number of items in cargo, otherwise returns 0(non-cargo objects). Recursive.
Определения ItemBase.c:8462
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8656
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8418
ref TIntArray m_InteractActions
Определения ItemBase.c:4985
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7620
float m_VarQuantity
Определения ItemBase.c:4925
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9753
override float GetWetMax()
Определения ItemBase.c:8626
bool CanBeUsedForSuicide()
Определения ItemBase.c:9720
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7193
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5905
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7774
void DoAmmoExplosion()
Определения ItemBase.c:6388
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4996
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6732
int GetItemSize()
Определения ItemBase.c:7585
bool m_CanBeMovedOverride
Определения ItemBase.c:4962
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6312
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5492
bool CanDecay()
Определения ItemBase.c:9523
ScriptedLightBase GetLight()
string GetPlaceSoundset()
bool AddQuantity(float value, bool destroy_config=true, bool destroy_forced=false)
add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Определения ItemBase.c:8303
void SetQuantityMax()
Определения ItemBase.c:8308
override float GetQuantity()
Определения ItemBase.c:8398
int m_ColorComponentR
Определения ItemBase.c:4974
int m_ShotsToStartOverheating
Определения ItemBase.c:5006
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8641
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5499
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9139
void OnOverheatingDecay()
Определения ItemBase.c:5462
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8574
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4940
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5600
bool UsesGlobalDeploy()
Определения ItemBase.c:9752
int m_ItemBehaviour
Определения ItemBase.c:4955
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:9111
float m_HeatIsolation
Определения ItemBase.c:4950
float m_VarWetInit
Определения ItemBase.c:4936
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5945
void SetCEBasedQuantity()
Определения ItemBase.c:5713
bool m_CanPlayImpactSound
Определения ItemBase.c:4946
override string GetAttachmentSoundType()
Определения ItemBase.c:9314
float GetOverheatingCoef()
Определения ItemBase.c:5519
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9408
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9762
override bool IsStoreLoad()
Определения ItemBase.c:8668
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7169
bool IsLightSource()
Определения ItemBase.c:5841
bool m_HasQuantityBar
Определения ItemBase.c:4968
void SetResultOfSplit(bool value)
Определения ItemBase.c:7164
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6796
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6965
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5527
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8583
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9219
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8678
int m_LockType
Определения ItemBase.c:5022
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:5027
bool m_CanBeDigged
Определения ItemBase.c:4969
float m_ItemAttachOffset
Определения ItemBase.c:4952
float GetItemModelLength()
Определения ItemBase.c:8685
bool m_ThrowItemOnDrop
Определения ItemBase.c:4960
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7919
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8971
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8569
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7198
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9579
bool CanHaveWetness()
Определения ItemBase.c:9536
int m_CleannessMin
Определения ItemBase.c:4942
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8904
string IDToName(int id)
Определения ItemBase.c:7767
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9543
float GetHeatIsolationInit()
Определения ItemBase.c:8564
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7607
override bool HasQuantity()
Определения ItemBase.c:8393
float m_VarWetPrev
Определения ItemBase.c:4935
int m_SoundSyncStop
Определения ItemBase.c:5029
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9629
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4984
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5609
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5294
int m_VarLiquidType
Определения ItemBase.c:4954
int m_QuickBarBonus
Определения ItemBase.c:4956
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9302
override float GetWetInit()
Определения ItemBase.c:8636
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4948
int m_SoundSyncPlay
Определения ItemBase.c:5028
int m_MaxOverheatingValue
Определения ItemBase.c:5007
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4931
bool m_IsTakeable
Определения ItemBase.c:4959
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:6503
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4999
string GetLockSoundSet()
Определения ItemBase.c:8734
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8765
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9656
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6971
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4911
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9329
override int GetQuantityMin()
Определения ItemBase.c:8382
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6711
override int GetQuickBarBonus()
Определения ItemBase.c:5179
override void SetTakeable(bool pState)
Определения ItemBase.c:9284
float m_OverheatingDecayInterval
Определения ItemBase.c:5008
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6523
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9501
bool CanProcessDecay()
Определения ItemBase.c:9529
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5690
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9645
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7571
bool can_this_be_combined
Определения ItemBase.c:4964
EffectSound m_SoundDeploy
Определения ItemBase.c:9739
int m_SoundSyncSlotID
Определения ItemBase.c:5030
int m_Count
Определения ItemBase.c:4930
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9692
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9276
override bool IsSplitable()
Определения ItemBase.c:6490
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6473
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7883
void ConvertEnergyToQuantity()
Определения ItemBase.c:8551
override void RemoveAllAgents()
Определения ItemBase.c:8885
override void SetQuantityToMinimum()
Определения ItemBase.c:8314
bool m_WantPlayImpactSound
Определения ItemBase.c:4945
override float GetTemperatureThawTime()
Определения ItemBase.c:9616
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4998
int m_ColorComponentG
Определения ItemBase.c:4975
float m_StoreLoadedQuantity
Определения ItemBase.c:4932
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7638
int m_ColorComponentA
Определения ItemBase.c:4977
int m_VarQuantityInit
Определения ItemBase.c:4927
float GetFilterDamageRatio()
Определения ItemBase.c:5594
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8778
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6942
void OnApply(PlayerBase player)
override void SetQuantityNormalized(float value, bool destroy_config=true, bool destroy_forced=false)
Sets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8321
bool m_HideSelectionsBySlot
Определения ItemBase.c:5012
bool IsOverheatingEffectActive()
Определения ItemBase.c:5457
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5874
int GetLiquidContainerMask()
Определения ItemBase.c:5811
void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
Определения ItemBase.c:7078
ref Timer m_CheckOverheating
Определения ItemBase.c:5005
void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
Определения ItemBase.c:5505
float GetEnergy()
Определения ItemBase.c:8525
bool CanBeDigged()
Определения ItemBase.c:5890
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9662
bool IsNVG()
Определения ItemBase.c:5822
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8485
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9438
bool m_IsDeploySound
Определения ItemBase.c:9741
bool CanEat()
Определения ItemBase.c:7531
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9179
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9250
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9640
bool IsLiquidContainer()
Определения ItemBase.c:5806
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7551
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8409
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8963
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8363
int m_CleannessInit
Определения ItemBase.c:4941
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5589
override int GetAgents()
Определения ItemBase.c:8910
int m_VarQuantityMax
Определения ItemBase.c:4929
override bool IsHologram()
Определения ItemBase.c:5885
float GetItemAttachOffset()
Определения ItemBase.c:8694
bool IsPlaceSound()
Определения ItemBase.c:9755
static int GetDebugActionsMask()
Определения ItemBase.c:5675
override int GetLiquidType()
Определения ItemBase.c:8794
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9518
override bool IsItemBase()
Определения ItemBase.c:7684
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9260
void ExplodeAmmo()
Определения ItemBase.c:6375
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:7154
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8984
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9159
override void OnEnergyAdded()
Определения ItemBase.c:8543
void AffectLiquidContainerOnFill(int liquid_type, float amount)
from enviro source
void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature)
from other liquid container source
string GetExplosiveTriggerSlotName()
Определения ItemBase.c:5834
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9738
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7824
void StopItemDynamicPhysics()
Определения ItemBase.c:9420
bool HasFoodStage()
Определения ItemBase.c:7544
override void SetStoreLoad(bool value)
Определения ItemBase.c:8663
float GetOverheatingValue()
Определения ItemBase.c:5419
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8863
override void AddWet(float value)
Определения ItemBase.c:8611
bool IsLiquidPresent()
Определения ItemBase.c:5801
bool IsFullQuantity()
Определения ItemBase.c:8403
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:6084
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6847
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6823
int m_CleannessMax
Определения ItemBase.c:4943
float m_VarStackMax
Определения ItemBase.c:4931
ref Timer m_PhysDropTimer
Определения ItemBase.c:5018
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7656
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8673
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4972
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5440
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5755
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7578
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8799
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5486
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8721
bool m_IsOverheatingEffectActive
Определения ItemBase.c:5003
int m_LiquidContainerMask
Определения ItemBase.c:4953
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9456
override int GetCleanness()
Определения ItemBase.c:8716
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9667
bool IsDeploySound()
Определения ItemBase.c:9756
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5695
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9199
int m_VarQuantityMin
Определения ItemBase.c:4928
void PerformDamageSystemReinit()
Определения ItemBase.c:9426
override void ClearInventory()
Определения ItemBase.c:8504
static int m_LastRegisteredWeaponID
Определения ItemBase.c:5000
ItemBase GetLightSourceItem()
Определения ItemBase.c:9650
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7674
override float GetItemOverheatThreshold()
Определения ItemBase.c:9600
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4965
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7788
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6762
float m_ItemModelLength
Определения ItemBase.c:4951
bool m_IsHologram
Определения ItemBase.c:4958
static int m_DebugActionsMask
Определения ItemBase.c:4918
void KillAllOverheatingParticles()
Определения ItemBase.c:5555
bool CanBeCookedOnStick()
Определения ItemBase.c:7561
override int GetQuantityMax()
Определения ItemBase.c:8349
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7232
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8759
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8876
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4961
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:9066
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9798
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4912
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9729
override bool IsBeingPlaced()
Определения ItemBase.c:5869
int GetQuantityInit()
Определения ItemBase.c:8387
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7174
bool IsResultOfSplit()
Определения ItemBase.c:7159
bool m_FixDamageSystemInit
Определения ItemBase.c:4963
float m_ImpactSpeed
Определения ItemBase.c:4947
bool m_IsStoreLoad
Определения ItemBase.c:4966
int GetLiquidTypeInit()
Определения ItemBase.c:8789
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4981
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5742
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6633
int m_AttachedAgents
Определения ItemBase.c:4989
string m_LockSoundSet
Определения ItemBase.c:5024
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5363
float m_VarQuantityPrev
Определения ItemBase.c:4926
bool IsSoundSynchRemote()
Определения ItemBase.c:9754
bool m_CanShowQuantity
Определения ItemBase.c:4967
override void OnRightClick()
Определения ItemBase.c:7014
int m_ColorComponentB
Определения ItemBase.c:4976
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4914
bool IsActionTargetVisible()
Определения ItemBase.c:9296
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:6119
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6412
bool m_IsBeingPlaced
Определения ItemBase.c:4957
int NameToID(string name)
Определения ItemBase.c:7761
void ~ItemBase()
Определения ItemBase.c:5640
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8651
void ClearStopItemSoundServer()
Определения ItemBase.c:9396
override string ChangeIntoOnDetach()
Определения ItemBase.c:6336
float m_VarWetMax
Определения ItemBase.c:4938
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6757
int GetLockType()
Определения ItemBase.c:8729
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9736
override float GetWet()
Определения ItemBase.c:8621
EffectSound m_SoundPlace
Определения ItemBase.c:9737
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8335
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8703
bool m_IsPlaceSound
Определения ItemBase.c:9740
override float GetWetMin()
Определения ItemBase.c:8631
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:5032
override bool KindOf(string tag)
Определения ItemBase.c:7690
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
string Type
Определения JsonDataContaminatedArea.c:11
EffectSound m_LockingSound
Определения Land_Underground_Entrance.c:336
string GetDebugText()
Определения ModifierBase.c:71
@ LOWEST
Определения PPEConstants.c:54
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:325
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Определения RemoteDetonator.c:272
void RemoteDetonatorTrigger()
Определения RemoteDetonator.c:233
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Определения RemoteDetonator.c:305
int particle_id
Определения SmokeSimulation.c:28
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
override void Explode(int damageType, string ammoType="")
Определения Trap_LandMine.c:220
bool m_Initialized
Определения UiHintPanel.c:317
int GetID()
Определения ActionBase.c:1335
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:974
GetInputType()
Определения ActionBase.c:221
int m_StanceMask
Определения ActionBase.c:25
int m_CommandUIDProne
Определения ActionBase.c:24
int m_CommandUID
Определения ActionBase.c:23
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
float GetEnergyAtSpawn()
Определения ComponentEnergyManager.c:1325
void SetEnergy0To1(float energy01)
Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value be...
Определения ComponentEnergyManager.c:550
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Определения ComponentEnergyManager.c:1320
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:603
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
Определения EffectSound.c:274
override bool IsMan()
Определения 3_Game/DayZ/Entities/Man.c:48
proto native EntityAI GetAttachmentFromIndex(int index)
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
proto native int AttachmentCount()
Returns count of attachments attached to this item.
proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
proto void SelectObject(Object object)
proto void SelectPhysics(Physics physics)
Определения ItemBase.c:21
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetCol()
returns column of cargo if current type is Cargo / ProxyCargo
proto native int GetRow()
returns row of cargo if current type is Cargo / ProxyCargo
bool WriteToContext(ParamsWriteContext ctx)
Определения InventoryLocation.c:507
proto native int GetType()
returns type of InventoryLocation
proto native int GetIdx()
returns index of cargo if current type is Cargo / ProxyCargo
proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
sets current inventory location type to Cargo with coordinates (idx, row, col)
proto native bool GetFlip()
returns flip status of cargo
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:30
override bool CanDisplayCargo()
Определения TentBase.c:91
override void OnInventoryEnter(Man player)
Определения BarbedWire.c:203
override string GetFoldSoundset()
Определения BaseBuildingBase.c:108
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:7
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:934
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения GardenBase.c:199
override void OnWasDetached(EntityAI parent, int slot_id)
override void EEOnAfterLoad()
Определения GardenBase.c:242
override void EEDelete(EntityAI parent)
Определения BaseBuildingBase.c:68
override bool CanBeRepairedByCrafting()
Определения TentBase.c:86
override void OnPlacementStarted(Man player)
Определения BatteryCharger.c:376
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Определения BarbedWire.c:357
override bool IsElectricAppliance()
Определения BatteryCharger.c:43
override bool IsItemTent()
Определения TentBase.c:81
override string GetLoopFoldSoundset()
Определения BaseBuildingBase.c:113
override bool CanMakeGardenplot()
Определения FieldShovel.c:3
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения PowerGenerator.c:397
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения HandcuffsLocked.c:12
override WrittenNoteData GetWrittenNoteData()
Определения Paper.c:30
override int GetDamageSystemVersionChange()
Определения BaseBuildingBase.c:1238
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
override void InitItemVariables()
Определения Matchbox.c:3
override void SetActionAnimOverrides()
Определения PickAxe.c:28
override void OnCreatePhysics()
Определения BaseBuildingBase.c:489
override string GetDeploySoundset()
Определения BarbedWire.c:392
override float GetBandagingEffectivity()
Определения BandageDressing.c:49
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения PowerGenerator.c:409
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения BaseBuildingBase.c:496
override void OnStoreSave(ParamsWriteContext ctx)
Определения GardenBase.c:266
override void AfterStoreLoad()
Определения BarbedWire.c:155
override int GetOnDigWormsAmount()
Определения FieldShovel.c:27
override bool IsSelfAdjustingTemperature()
Определения PortableGasStove.c:287
override bool IsPlayerInside(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1037
override void OnVariablesSynchronized()
Определения GardenBase.c:97
override void RefreshPhysics()
Определения BatteryCharger.c:359
override bool CanObstruct()
Определения BaseBuildingBase.c:84
override void OnWasAttached(EntityAI parent, int slot_id)
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения BaseBuildingBase.c:982
override bool CanPutInCargo(EntityAI parent)
Определения GardenBase.c:331
override string GetLoopDeploySoundset()
Определения BarbedWire.c:397
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Определения BarbedWire.c:372
override void OnInventoryExit(Man player)
Определения BatteryCharger.c:341
override bool IsTakeable()
Определения BaseBuildingBase.c:1008
override bool IsIgnoredByConstruction()
Определения BaseBuildingBase.c:1170
override void InitItemSounds()
Определения BaseBuildingBase.c:94
override void EEKilled(Object killer)
Определения HandcuffsLocked.c:70
override void OnCombine(ItemBase other_item)
Определения BandageDressing.c:71
override bool CanExplodeInFire()
Определения LargeGasCannister.c:3
override bool IsFacingPlayer(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1032
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Определения Rag.c:61
override bool IsBloodContainer()
Определения BloodContainerBase.c:10
override bool CanBeSplit()
Определения Rag.c:34
override bool IsDeployable()
Определения BaseBuildingBase.c:365
override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения ToolBase.c:24
override bool CanBeDisinfected()
Определения BandageDressing.c:54
override float GetInfectionChance(int system=0, Param param=null)
Определения BandageDressing.c:59
override void OnEndPlacement()
Определения KitBase.c:65
Определения ItemBase.c:14
Определения EnMath.c:7
float GetOverheatingLimitMax()
Определения WeaponParticles.c:417
void SetOverheatingLimitMax(float max)
Определения WeaponParticles.c:407
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
Определения WeaponParticles.c:422
float GetOverheatingLimitMin()
Определения WeaponParticles.c:412
Particle GetParticle()
Определения WeaponParticles.c:397
void SetOverheatingLimitMin(float min)
Определения WeaponParticles.c:402
void RegisterParticle(Particle p)
Определения WeaponParticles.c:392
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Определения Particle.c:266
void SetControlledDevice(EntityAI pDevice)
Определения RemoteDetonator.c:140
bool OnStoreLoad(ParamsReadContext ctx, int version)
void OnStoreSave(ParamsWriteContext ctx)
proto native void Send()
proto bool Write(void value_out)
proto bool Read(void value_in)
bool m_Loop
Определения ItemSoundHandler.c:5
override void Stop()
Определения DayZPlayerImplement.c:40
proto native float GetDamage(string zoneName, string healthType)
override void Refresh()
Определения ChatInputMenu.c:70
void SetCalcDetails(string details)
Определения 3_Game/DayZ/tools/Debug.c:916
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения WrittenNoteData.c:13
const float LOWEST
Определения EnConvert.c:113
Serializer ParamsReadContext
Определения gameplay.c:15
class LOD Object
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Определения gameplay.c:6
Serializer ParamsWriteContext
Определения gameplay.c:16
const int DEF_BIOLOGICAL
Определения 3_Game/DayZ/constants.c:515
const int DEF_CHEMICAL
Определения 3_Game/DayZ/constants.c:516
const int COMP_TYPE_ENERGY_MANAGER
Определения Component.c:9
ErrorExSeverity
Определения EnDebug.c:62
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
enum ShapeType ErrorEx
proto native void SetColor(int color)
array< string > TStringArray
Определения EnScript.c:712
array< int > TIntArray
Определения EnScript.c:714
void Obsolete(string msg="")
Определения EnScript.c:371
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/DayZ/constants.c:811
const int VARIABLE_LIQUIDTYPE
Определения 3_Game/DayZ/constants.c:635
const int VARIABLE_CLEANNESS
Определения 3_Game/DayZ/constants.c:638
const int VARIABLE_COLOR
Определения 3_Game/DayZ/constants.c:637
const int VARIABLE_TEMPERATURE
Определения 3_Game/DayZ/constants.c:633
const int VARIABLE_QUANTITY
Определения 3_Game/DayZ/constants.c:631
const int VARIABLE_WET
Определения 3_Game/DayZ/constants.c:634
const int LIQUID_NONE
Определения 3_Game/DayZ/constants.c:532
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения 3_Game/DayZ/constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения 3_Game/DayZ/constants.c:456
const int SAT_DEBUG_ACTION
Определения 3_Game/DayZ/constants.c:457
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
const int CALL_CATEGORY_GAMEPLAY
Определения 3_Game/DayZ/tools/tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/DayZ/tools/tools.c:8
proto native int GetColor()

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