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

◆ SplitIntoStackMax()

void SpawnItemOnLocation::SplitIntoStackMax ( EntityAI destination_entity,
int slot_id,
PlayerBase player )
protected

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

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