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

◆ IsSplitable()

override bool SpawnItemOnLocation::IsSplitable ( )
private

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

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

Используется в InventoryItem::CanBeSplit(), InventoryItem::GetTargetQuantityMax(), InventoryItem::GetUnitWeight(), InventoryItem::GetWeightSpecialized(), InventoryItem::OnVariablesSynchronized() и InventoryItem::ShouldSplitQuantity().