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

◆ EEItemLocationChanged()

override void SpawnItemOnLocation::EEItemLocationChanged ( notnull InventoryLocation oldLoc,
notnull InventoryLocation newLoc )
private

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

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