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

◆ KillAllOverheatingParticles()

void SpawnItemOnLocation::KillAllOverheatingParticles ( )
private

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

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