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

◆ IsLightSource()

bool SpawnItemOnLocation::IsLightSource ( )
private

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

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