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

◆ CanBeRepairedByCrafting()

bool SpawnItemOnLocation::CanBeRepairedByCrafting ( )
private

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

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