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

◆ DoAmmoExplosion()

void SpawnItemOnLocation::DoAmmoExplosion ( )
private

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

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