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

◆ OnEndPlacement()

void SpawnItemOnLocation::OnEndPlacement ( )
private

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

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