diff --git a/Library/RSBot.Core/Client/ReferenceManager.cs b/Library/RSBot.Core/Client/ReferenceManager.cs index 74efd100..0854a9d4 100644 --- a/Library/RSBot.Core/Client/ReferenceManager.cs +++ b/Library/RSBot.Core/Client/ReferenceManager.cs @@ -26,6 +26,7 @@ public class ReferenceManager public Dictionary SkillMasteryData { get; } = new(32); public Dictionary AbilityItemByOptLevel { get; } = new(256); public List SkillByItemOptLevels { get; } = new(256); + public List ExtraAbilityByEquipItemOptLevel { get; } = new(4096); public Dictionary Shops { get; } = new(128); public Dictionary ShopTabs { get; } = new(256); public Dictionary ShopGroups { get; } = new(128); @@ -86,6 +87,9 @@ public void Load(int languageTab) LoadReferenceFile("refskillbyitemoptleveldata.txt", SkillByItemOptLevels); } + if (Game.ClientType >= GameClientType.Chinese) + LoadReferenceFile("refextraabilitybyequipitemoptlevel.txt", ExtraAbilityByEquipItemOptLevel); + GC.Collect(); EventManager.FireEvent("OnLoadGameData"); } @@ -642,5 +646,16 @@ public RefAbilityByItemOptLevel GetAbilityItem(uint itemId, byte optLevel) { return AbilityItemByOptLevel.Values.FirstOrDefault(p => p.ItemId == itemId && p.OptLevel == optLevel); } + + /// + /// Gets a ability item for the specified and + /// + /// Item Id + /// Opt Level + /// + public IEnumerable GetExtraAbilityItems(uint itemId, byte optLevel) + { + return ExtraAbilityByEquipItemOptLevel.Where(p => p.ItemId == itemId && p.OptLevel == optLevel); + } } } \ No newline at end of file diff --git a/Library/RSBot.Core/Client/ReferenceObjects/RefExtraAbilityByEquipItemOptLevel.cs b/Library/RSBot.Core/Client/ReferenceObjects/RefExtraAbilityByEquipItemOptLevel.cs new file mode 100644 index 00000000..a6aee14e --- /dev/null +++ b/Library/RSBot.Core/Client/ReferenceObjects/RefExtraAbilityByEquipItemOptLevel.cs @@ -0,0 +1,23 @@ +namespace RSBot.Core.Client.ReferenceObjects +{ + public class RefExtraAbilityByEquipItemOptLevel : IReference + { + public uint ItemId; + public byte OptLevel; + public uint SkillId; + + public bool Load(ReferenceParser parser) + { + if (!parser.TryParse(0, out int service) || service == 0) + return false; + + if (!parser.TryParse(20, out SkillId) || SkillId == 0) + return false; + + parser.TryParse(1, out ItemId); + parser.TryParse(2, out OptLevel); + + return true; + } + } +} diff --git a/Library/RSBot.Core/Objects/Inventory/InventoryItem.cs b/Library/RSBot.Core/Objects/Inventory/InventoryItem.cs index 4c1a440d..97af0f06 100644 --- a/Library/RSBot.Core/Objects/Inventory/InventoryItem.cs +++ b/Library/RSBot.Core/Objects/Inventory/InventoryItem.cs @@ -369,6 +369,13 @@ public bool HasAbility(out RefAbilityByItemOptLevel abilityItem) return abilityItem != null; } + public bool HasExtraAbility(out IEnumerable abilityItems) + { + abilityItems = Game.ReferenceManager.GetExtraAbilityItems(ItemId, OptLevel); + + return abilityItems != null; + } + public override bool Equals(object obj) { if(obj is TypeIdFilter filter) diff --git a/Library/RSBot.Core/Objects/Player.cs b/Library/RSBot.Core/Objects/Player.cs index 3375e7f0..6a3a6aab 100644 --- a/Library/RSBot.Core/Objects/Player.cs +++ b/Library/RSBot.Core/Objects/Player.cs @@ -983,12 +983,16 @@ public bool TryGetAbilitySkills(out List abilitySkills) foreach (var item in player.Inventory.GetEquippedPartItems().Union(player.Avatars)) { - if (!item.HasAbility(out var abilityItem)) - continue; + if (item.HasAbility(out var abilityItem)) + abilitySkills.AddRange(abilityItem.GetLinks().Select(skillId => new SkillInfo(skillId, true))); - var links = abilityItem.GetLinks().Select(skillId => new SkillInfo(skillId, true)); + if(Game.ClientType >= GameClientType.Chinese) + { + if (!item.HasExtraAbility(out var extraAbilityItems)) + continue; - abilitySkills.AddRange(links); + abilitySkills.AddRange(extraAbilityItems.Select(p => new SkillInfo(p.SkillId, true))); + } } return abilitySkills.Any();