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

◆ IsBloodContainer()

bool SpawnItemOnLocation::IsBloodContainer ( )
private

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

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