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

◆ CombineItemsClient()

override void SpawnItemOnLocation::CombineItemsClient ( EntityAI entity2,
bool use_stack_max = true )
private

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

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