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

◆ DamageItemAttachments()

bool SpawnItemOnLocation::DamageItemAttachments ( float damage)
private

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

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

Используется в InventoryItem::EEHitBy().