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

◆ IsLiquidContainer()

bool SpawnItemOnLocation::IsLiquidContainer ( )
private

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

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

Используется в InventoryItem::GetDebugActions(), InventoryItem::GetItemOverheatThreshold(), InventoryItem::GetTemperatureFreezeThreshold(), InventoryItem::GetTemperatureThawThreshold(), InventoryItem::GetUnitWeight(), InventoryItem::InitItemVariables() и InventoryItem::OnQuantityChanged().