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

◆ IsLiquidPresent()

bool SpawnItemOnLocation::IsLiquidPresent ( )
private

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

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