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

◆ GetInfectionChance()

float SpawnItemOnLocation::GetInfectionChance ( int system = 0,
Param param = null )
private

Infection chance while/after using this item, originally used for wound infection after bandaging, params 'system' and 'param' can allow usage by other systems as well.

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

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