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

◆ SetIsBeingPlaced()

void SpawnItemOnLocation::SetIsBeingPlaced ( bool is_being_placed)
private

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

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