diff --git a/.editorconfig b/.editorconfig index 89b283f4..621c97e8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -203,3 +203,6 @@ csharp_space_after_keywords_in_control_flow_statements=true # CS0649: Field 'LocalPlayerExtensions.Offsets.CurrentGC' is never assigned to, and will always have its default value dotnet_diagnostic.CS0649.severity = silent + +dotnet_diagnostic.CA1416.severity = none + diff --git a/AssemblyProxy.cs b/AssemblyProxy.cs index de13f4f2..7a385866 100644 --- a/AssemblyProxy.cs +++ b/AssemblyProxy.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Concurrent; -using System.Collections.Generic; using System.Reflection; using System.Windows.Media; using ff14bot; diff --git a/ClientDataHelpers/UiManagerProxy.cs b/ClientDataHelpers/UiManagerProxy.cs index 316137c8..85ad0c24 100644 --- a/ClientDataHelpers/UiManagerProxy.cs +++ b/ClientDataHelpers/UiManagerProxy.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using ff14bot; using LlamaLibrary.Memory; diff --git a/Enums/World.cs b/Enums/World.cs index cc677d44..404caf2e 100644 --- a/Enums/World.cs +++ b/Enums/World.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.ComponentModel; -using System.ComponentModel.DataAnnotations; using LlamaLibrary.Extensions; // ReSharper disable IdentifierTypo diff --git a/Extensions/EnumExtensions.cs b/Extensions/EnumExtensions.cs index 136df86c..20df0bea 100644 --- a/Extensions/EnumExtensions.cs +++ b/Extensions/EnumExtensions.cs @@ -1,10 +1,8 @@ using System; -using System.ComponentModel; using System.Linq; +using System.Reflection; using ff14bot.Enums; using LlamaLibrary.Enums; -using System.ComponentModel.DataAnnotations; -using System.Reflection; namespace LlamaLibrary.Extensions { diff --git a/Extensions/LocalPlayerExtensions.cs b/Extensions/LocalPlayerExtensions.cs index 219896ed..f4a71a6c 100644 --- a/Extensions/LocalPlayerExtensions.cs +++ b/Extensions/LocalPlayerExtensions.cs @@ -13,7 +13,7 @@ namespace LlamaLibrary.Extensions public static class LocalPlayerExtensions { public const uint TheEndeavor = 900; - public const uint TheEndeaver_Ruby = 1163; + public const uint TheEndeaverRuby = 1163; internal static class Offsets { @@ -28,7 +28,7 @@ internal static class Offsets //PlayerID 8byte ulong ID unique to that character which is included in MB listings [Offset("Search 48 8B 05 ? ? ? ? 48 8D 0D ? ? ? ? 41 8B DC Add 3 TraceRelative")] - internal static IntPtr PlayerID; + internal static IntPtr PlayerId; [Offset("Search 0F B6 05 ? ? ? ? 88 83 ? ? ? ? Add 3 TraceRelative")] internal static IntPtr RunWalk; @@ -52,7 +52,7 @@ public static bool IsFishing(this LocalPlayer play) public static bool IsOnFishingBoat(this LocalPlayer play) { - return WorldManager.RawZoneId == TheEndeavor || WorldManager.RawZoneId == TheEndeaver_Ruby; + return WorldManager.RawZoneId == TheEndeavor || WorldManager.RawZoneId == TheEndeaverRuby; } public static Location Location(this LocalPlayer play) @@ -127,7 +127,7 @@ public static bool CheckCondition(this LocalPlayer player, byte condition) public static ulong PlayerId(this LocalPlayer player) { - return Core.Memory.Read(Offsets.PlayerID); + return Core.Memory.Read(Offsets.PlayerId); } public static World HomeWorld(this Character? character) @@ -140,27 +140,27 @@ public static int CurrentMount(this LocalPlayer player) return Core.Memory.Read(player.Pointer + Offsets.CurrentMount); } - public static bool IsTank(this ClassJobType CurrentJob) + public static bool IsTank(this ClassJobType currentJob) { - return CurrentJob == ClassJobType.Gladiator || CurrentJob == ClassJobType.Marauder || CurrentJob == ClassJobType.Paladin || CurrentJob == ClassJobType.Warrior || CurrentJob == ClassJobType.DarkKnight || CurrentJob == ClassJobType.Gunbreaker; + return currentJob == ClassJobType.Gladiator || currentJob == ClassJobType.Marauder || currentJob == ClassJobType.Paladin || currentJob == ClassJobType.Warrior || currentJob == ClassJobType.DarkKnight || currentJob == ClassJobType.Gunbreaker; } //IsHealer - public static bool IsHealer(this ClassJobType CurrentJob) + public static bool IsHealer(this ClassJobType currentJob) { - return CurrentJob == ClassJobType.Conjurer || CurrentJob == ClassJobType.WhiteMage || CurrentJob == ClassJobType.Scholar || CurrentJob == ClassJobType.Astrologian; + return currentJob == ClassJobType.Conjurer || currentJob == ClassJobType.WhiteMage || currentJob == ClassJobType.Scholar || currentJob == ClassJobType.Astrologian; } //IsMeleeDps - public static bool IsMeleeDps(this ClassJobType CurrentJob) + public static bool IsMeleeDps(this ClassJobType currentJob) { - return CurrentJob == ClassJobType.Pugilist || CurrentJob == ClassJobType.Lancer || CurrentJob == ClassJobType.Rogue || CurrentJob == ClassJobType.Samurai || CurrentJob == ClassJobType.Monk || CurrentJob == ClassJobType.Dragoon || CurrentJob == ClassJobType.Ninja; + return currentJob == ClassJobType.Pugilist || currentJob == ClassJobType.Lancer || currentJob == ClassJobType.Rogue || currentJob == ClassJobType.Samurai || currentJob == ClassJobType.Monk || currentJob == ClassJobType.Dragoon || currentJob == ClassJobType.Ninja; } //IsRangedDps - public static bool IsRangedDps(this ClassJobType CurrentJob) + public static bool IsRangedDps(this ClassJobType currentJob) { - return CurrentJob == ClassJobType.Archer || CurrentJob == ClassJobType.Machinist || CurrentJob == ClassJobType.Dancer || CurrentJob == ClassJobType.Bard; + return currentJob == ClassJobType.Archer || currentJob == ClassJobType.Machinist || currentJob == ClassJobType.Dancer || currentJob == ClassJobType.Bard; } public static GearSet[] SortedGearSets(this LocalPlayer player) diff --git a/Extensions/OtherExtensions.cs b/Extensions/OtherExtensions.cs index 5959dd69..a4fc0b52 100644 --- a/Extensions/OtherExtensions.cs +++ b/Extensions/OtherExtensions.cs @@ -79,7 +79,7 @@ public static string GetOrderJson(this IEnumerable orders) return JsonConvert.SerializeObject(orders.OrderBy(i => i.Type), Formatting.Indented, settings); } - public static bool Contains(this string source, string toCheck, StringComparison comp) + public static bool Contains(this string? source, string toCheck, StringComparison comp) { return source?.IndexOf(toCheck, comp) >= 0; } diff --git a/Extensions/RetainerTaskAskExtensions.cs b/Extensions/RetainerTaskAskExtensions.cs index 0ac7e6b5..20de5a97 100644 --- a/Extensions/RetainerTaskAskExtensions.cs +++ b/Extensions/RetainerTaskAskExtensions.cs @@ -6,25 +6,16 @@ public static class RetainerTaskAskExtensions { public static bool CanAssign() { - var WindowByName = RaptureAtkUnitManager.GetWindowByName("RetainerTaskAsk"); - if (WindowByName == null) - { - return false; - } + var windowByName = RaptureAtkUnitManager.GetWindowByName("RetainerTaskAsk"); - var remoteButton = WindowByName.FindButton(40); - return remoteButton != null && remoteButton.Clickable; + var remoteButton = windowByName?.FindButton(40); + return remoteButton is { Clickable: true }; } public static string GetErrorReason() { - var WindowByName = RaptureAtkUnitManager.GetWindowByName("RetainerTaskAsk"); - if (WindowByName == null || WindowByName.FindLabel(39) == null) - { - return ""; - } - - return WindowByName.FindLabel(39).Text; + var windowByName = RaptureAtkUnitManager.GetWindowByName("RetainerTaskAsk"); + return windowByName?.FindLabel(39) == null ? "" : windowByName.FindLabel(39).Text; } } } \ No newline at end of file diff --git a/Helpers/GeneralFunctions.cs b/Helpers/GeneralFunctions.cs index c12e3b24..c5ca530c 100644 --- a/Helpers/GeneralFunctions.cs +++ b/Helpers/GeneralFunctions.cs @@ -1676,8 +1676,8 @@ public static async Task TurninSkySteelGathering() if (turninItems.Any()) { await InteractWithDenys(3); - await Coroutine.Wait(10000, () => ShopExchangeItem.Instance.IsOpen); - if (ShopExchangeItem.Instance.IsOpen) + await Coroutine.Wait(10000, () => LlamaLibrary.RemoteWindows.ShopExchangeItem.Instance.IsOpen); + if (LlamaLibrary.RemoteWindows.ShopExchangeItem.Instance.IsOpen) { Log.Information($"Window Open"); foreach (var turnin in turninItems) @@ -1685,12 +1685,12 @@ public static async Task TurninSkySteelGathering() var reward = GatheringItems[turnin.RawItemId].Reward; var amt = turnin.Count / GatheringItems[turnin.RawItemId].Cost; Log.Information($"Buying {amt}x{DataManager.GetItem(reward).CurrentLocaleName}"); - await ShopExchangeItem.Instance.Purchase(reward, amt); + await LlamaLibrary.RemoteWindows.ShopExchangeItem.Instance.Purchase(reward, amt); await Coroutine.Sleep(500); } - ShopExchangeItem.Instance.Close(); - await Coroutine.Wait(10000, () => !ShopExchangeItem.Instance.IsOpen); + LlamaLibrary.RemoteWindows.ShopExchangeItem.Instance.Close(); + await Coroutine.Wait(10000, () => !LlamaLibrary.RemoteWindows.ShopExchangeItem.Instance.IsOpen); } } } diff --git a/Helpers/LoadServerProfile.cs b/Helpers/LoadServerProfile.cs index 402385a3..c6d688c8 100644 --- a/Helpers/LoadServerProfile.cs +++ b/Helpers/LoadServerProfile.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Net; using System.Net.Http; -using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Media; using System.Xml.Linq; @@ -12,12 +11,9 @@ using ff14bot; using ff14bot.Behavior; using ff14bot.Enums; -using ff14bot.Helpers; using ff14bot.Managers; using ff14bot.NeoProfiles; using ff14bot.RemoteWindows; -using LlamaLibrary.Helpers; -using LlamaLibrary.Helpers.NPC; using LlamaLibrary.Logging; using LlamaLibrary.RemoteAgents; using LlamaLibrary.RemoteWindows; @@ -127,12 +123,12 @@ public class LoadServerProfile private static readonly ShuffleCircularQueue _greetingQueue = new ShuffleCircularQueue(Greetings); - private static ShuffleCircularQueue _greetingQueueCustom; + //private static ShuffleCircularQueue _greetingQueueCustom; public static ChatBroadcaster PartyBroadcaster = new ChatBroadcaster(MessageType.Party); public static ChatBroadcaster EmoteBroadcaster = new ChatBroadcaster(MessageType.StandardEmotes); - public static async Task LoadProfile(string profileName, int QueueType, bool GoToBarracks, bool sayHello, bool sayHelloCustom, string sayHelloMessages) + public static async Task LoadProfile(string profileName, int QueueType, bool GoToBarracks, bool sayHello = false, bool sayHelloCustom = false, string sayHelloMessages = "") { Log.Information("Loading Profile"); @@ -492,8 +488,6 @@ await Coroutine.Wait(-1, Log.Information("Should be in duty"); - ShuffleCircularQueue _greetingQueueCustom = new ShuffleCircularQueue(SayHelloMessages.Split('/')); - if (DirectorManager.ActiveDirector is ff14bot.Directors.InstanceContentDirector director) { var time = new TimeSpan(1, 29, 59); @@ -524,9 +518,13 @@ await Coroutine.Wait(-1, if (sayHelloCustom && sayHello) { - var sentcustomgreeting = _greetingQueueCustom.Dequeue(); - Log.Information($"Saying '{sentcustomgreeting}' the group"); - await PartyBroadcaster.Send(sentcustomgreeting); + ShuffleCircularQueue greetingQueueCustomNew = new ShuffleCircularQueue(SayHelloMessages.Split('/')); + if (greetingQueueCustomNew.Any) + { + var sentcustomgreeting = greetingQueueCustomNew.Dequeue(); + Log.Information($"Saying '{sentcustomgreeting}' the group"); + await PartyBroadcaster.Send(sentcustomgreeting); + } } await Coroutine.Wait(-1, () => director.TimeLeftInDungeon < time); diff --git a/LastCommit.txt b/LastCommit.txt index 5c2ef742..99fd0f63 100644 --- a/LastCommit.txt +++ b/LastCommit.txt @@ -1 +1 @@ -2024-05-15T12:30:53-05:00 +2024-05-22T18:16:19-04:00 diff --git a/LlamaLibrary.csproj b/LlamaLibrary.csproj index 54a3313c..24e8483c 100644 --- a/LlamaLibrary.csproj +++ b/LlamaLibrary.csproj @@ -1,468 +1,54 @@ - - - - - Debug - false - AnyCPU - {196EE308-0205-4CC4-B449-51064F7E9960} - Library - Properties - LlamaLibrary - LlamaLibrary - v4.8 - 512 - true - 10 - enable - - - bin\x64\Release\ - TRACE - true - true - pdbonly - x64 - latest - prompt - - - true - DEBUG;TRACE - true - full - prompt - bin\Debug\ - - - - ..\..\Clio.Localization.dll - - - ..\..\GreyMagic.dll - true - - - - - ..\..\RebornBuddy.exe - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PublicResXFileCodeGenerator - Resources.Designer.cs - - - - - - - - - - - - - - - - - - - - - - - - - + + + false + Library + true + 10 + enable + false + true + true + true + net8.0-windows;net48 + true + + + bin\x64\Release\ + true + latest + + + true + + + + + + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + \ No newline at end of file diff --git a/LlamaLibrary.sln b/LlamaLibrary.sln index a0018169..cab7f9ed 100644 --- a/LlamaLibrary.sln +++ b/LlamaLibrary.sln @@ -1,30 +1,16 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.1.31903.286 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LlamaLibrary", "LlamaLibrary.csproj", "{196EE308-0205-4CC4-B449-51064F7E9960}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LlamaLibrary", "LlamaLibrary.csproj", "{30A6CDF5-8D64-43CA-8D17-79978B5C8B24}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {196EE308-0205-4CC4-B449-51064F7E9960}.Debug|x64.ActiveCfg = Debug|x64 - {196EE308-0205-4CC4-B449-51064F7E9960}.Debug|x64.Build.0 = Debug|x64 - {196EE308-0205-4CC4-B449-51064F7E9960}.Release|Any CPU.ActiveCfg = Release|x64 - {196EE308-0205-4CC4-B449-51064F7E9960}.Release|x64.ActiveCfg = Release|x64 - {196EE308-0205-4CC4-B449-51064F7E9960}.Release|x64.Build.0 = Release|x64 - {196EE308-0205-4CC4-B449-51064F7E9960}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {196EE308-0205-4CC4-B449-51064F7E9960}.Debug|Any CPU.Build.0 = Debug|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {0B1CF9ED-2F3A-4A3B-8D79-AFAE2C6486CE} + {30A6CDF5-8D64-43CA-8D17-79978B5C8B24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {30A6CDF5-8D64-43CA-8D17-79978B5C8B24}.Debug|Any CPU.Build.0 = Debug|Any CPU + {30A6CDF5-8D64-43CA-8D17-79978B5C8B24}.Release|Any CPU.ActiveCfg = Release|Any CPU + {30A6CDF5-8D64-43CA-8D17-79978B5C8B24}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Managers/SnipeManager.cs b/Managers/SnipeManager.cs index 743fbf10..effeb92e 100644 --- a/Managers/SnipeManager.cs +++ b/Managers/SnipeManager.cs @@ -5,182 +5,182 @@ using System.Windows.Media; using Buddy.Coroutines; using ff14bot; -using ff14bot.Behavior; using ff14bot.Managers; using ff14bot.Objects; using LlamaLibrary.Logging; using LlamaLibrary.Memory.Attributes; -namespace LlamaLibrary.Managers{ - -public class SnipeManager +namespace LlamaLibrary.Managers { - private static LLogger Log = new LLogger("SnipeManager", Colors.Silver); - - internal static class Offsets + public class SnipeManager { - [Offset("Search 48 8D 0D ? ? ? ? 32 DB E8 ? ? ? ? 84 C0 0F B6 CB BA ? ? ? ? 0F 45 CA 45 32 FF Add 3 TraceRelative")] - internal static IntPtr Instance; + private static LLogger Log = new LLogger("SnipeManager", Colors.Silver); - [Offset("Search 8B 83 ? ? ? ? 48 8B 54 24 ? 48 89 4D ? Add 2 Read32")] - internal static int Id; + internal static class Offsets + { + [Offset("Search 48 8D 0D ? ? ? ? 32 DB E8 ? ? ? ? 84 C0 0F B6 CB BA ? ? ? ? 0F 45 CA 45 32 FF Add 3 TraceRelative")] + internal static IntPtr Instance; - //0F B6 83 ? ? ? ? 3C ? 0F 85 ? ? ? ? F3 0F 10 83 ? ? ? ? - [Offset("Search 0F B6 83 ? ? ? ? 3C ? 0F 85 ? ? ? ? F3 0F 10 83 ? ? ? ? Add 2 Read32")] - internal static int Active; + [Offset("Search 8B 83 ? ? ? ? 48 8B 54 24 ? 48 89 4D ? Add 2 Read32")] + internal static int Id; - //48 2B 8B ? ? ? ? 49 8B C7 48 F7 E9 44 8B C7 Add 3 Read32 - [Offset("Search 48 2B 8B ? ? ? ? 49 8B C7 48 F7 E9 44 8B C7 Add 3 Read32")] - internal static int Params; + //0F B6 83 ? ? ? ? 3C ? 0F 85 ? ? ? ? F3 0F 10 83 ? ? ? ? + [Offset("Search 0F B6 83 ? ? ? ? 3C ? 0F 85 ? ? ? ? F3 0F 10 83 ? ? ? ? Add 2 Read32")] + internal static int Active; - //66 C7 83 ? ? ? ? ? ? E9 ? ? ? ? 48 63 83 ? ? ? ? Add 3 Read32 - [Offset("Search 66 C7 83 ? ? ? ? ? ? E9 ? ? ? ? 48 63 83 ? ? ? ? Add 3 Read32")] - internal static int State; + //48 2B 8B ? ? ? ? 49 8B C7 48 F7 E9 44 8B C7 Add 3 Read32 + [Offset("Search 48 2B 8B ? ? ? ? 49 8B C7 48 F7 E9 44 8B C7 Add 3 Read32")] + internal static int Params; - //48 8B 8B ? ? ? ? 48 8B 0C D1 Add 3 Read32 - [Offset("Search 48 8B 8B ? ? ? ? 48 8B 0C D1 Add 3 Read32")] - internal static int SnipeObjects; + //66 C7 83 ? ? ? ? ? ? E9 ? ? ? ? 48 63 83 ? ? ? ? Add 3 Read32 + [Offset("Search 66 C7 83 ? ? ? ? ? ? E9 ? ? ? ? 48 63 83 ? ? ? ? Add 3 Read32")] + internal static int State; - //0F B6 83 ? ? ? ? 3C ? 0F 85 ? ? ? ? F3 0F 10 83 ? ? ? ? Add 3 Read32 - [Offset("Search 0F B6 83 ? ? ? ? 3C ? 0F 85 ? ? ? ? F3 0F 10 83 ? ? ? ? Add 3 Read32")] - internal static int Shoot; + //48 8B 8B ? ? ? ? 48 8B 0C D1 Add 3 Read32 + [Offset("Search 48 8B 8B ? ? ? ? 48 8B 0C D1 Add 3 Read32")] + internal static int SnipeObjects; - //0F B6 47 ? 88 83 ? ? ? ? 0F B6 47 ? 88 83 ? ? ? ? 44 88 B3 ? ? ? ? Add 3 Read8 - [Offset("Search 0F B6 47 ? 88 83 ? ? ? ? 0F B6 47 ? 88 83 ? ? ? ? 44 88 B3 ? ? ? ? Add 3 Read8")] - internal static int ShootParam; + //0F B6 83 ? ? ? ? 3C ? 0F 85 ? ? ? ? F3 0F 10 83 ? ? ? ? Add 3 Read32 + [Offset("Search 0F B6 83 ? ? ? ? 3C ? 0F 85 ? ? ? ? F3 0F 10 83 ? ? ? ? Add 3 Read32")] + internal static int Shoot; - // 44 89 A3 ? ? ? ? 66 C7 83 ? ? ? ? ? ? EB ? Add 3 Read32 - [Offset("Search 44 89 A3 ? ? ? ? 66 C7 83 ? ? ? ? ? ? EB ? Add 3 Read32")] - internal static int ShootData; + //0F B6 47 ? 88 83 ? ? ? ? 0F B6 47 ? 88 83 ? ? ? ? 44 88 B3 ? ? ? ? Add 3 Read8 + [Offset("Search 0F B6 47 ? 88 83 ? ? ? ? 0F B6 47 ? 88 83 ? ? ? ? 44 88 B3 ? ? ? ? Add 3 Read8")] + internal static int ShootParam; - //0F B6 47 ? 88 83 ? ? ? ? 44 88 B3 ? ? ? ? - [Offset("Search 0F B6 47 ? 88 83 ? ? ? ? 44 88 B3 ? ? ? ? Add 3 Read8")] - internal static int ShootParam2; - } + // 44 89 A3 ? ? ? ? 66 C7 83 ? ? ? ? ? ? EB ? Add 3 Read32 + [Offset("Search 44 89 A3 ? ? ? ? 66 C7 83 ? ? ? ? ? ? EB ? Add 3 Read32")] + internal static int ShootData; - public static IntPtr addr => Core.Memory.Read(Offsets.Instance); - public static uint SnipeRowId => Core.Memory.Read(addr + Offsets.Id); + //0F B6 47 ? 88 83 ? ? ? ? 44 88 B3 ? ? ? ? + [Offset("Search 0F B6 47 ? 88 83 ? ? ? ? 44 88 B3 ? ? ? ? Add 3 Read8")] + internal static int ShootParam2; + } - public static byte State - { - get => Core.Memory.NoCacheRead(addr + Offsets.State); - set => Core.Memory.Write(addr + Offsets.State, value); - } + public static IntPtr addr => Core.Memory.Read(Offsets.Instance); + public static uint SnipeRowId => Core.Memory.Read(addr + Offsets.Id); - public static byte Active - { - get => Core.Memory.Read(addr + Offsets.Active); - set => Core.Memory.Write(addr + Offsets.Active, value); - } + public static byte State + { + get => Core.Memory.NoCacheRead(addr + Offsets.State); + set => Core.Memory.Write(addr + Offsets.State, value); + } - private static bool Shoot - { - get => Core.Memory.Read(addr + Offsets.Shoot) == 1; - set => Core.Memory.Write(addr + Offsets.Shoot, value ? 1 : 0); - } + public static byte Active + { + get => Core.Memory.Read(addr + Offsets.Active); + set => Core.Memory.Write(addr + Offsets.Active, value); + } + private static bool Shoot + { + get => Core.Memory.Read(addr + Offsets.Shoot) == 1; + set => Core.Memory.Write(addr + Offsets.Shoot, value ? 1 : 0); + } - public static IntPtr SnipeObjectsPtr => Core.Memory.Read(addr + Offsets.SnipeObjects); + public static IntPtr SnipeObjectsPtr => Core.Memory.Read(addr + Offsets.SnipeObjects); - public static SnipeObject[] SnipeObjects - { - get + public static SnipeObject[] SnipeObjects + { + get + { + if (addr == IntPtr.Zero) + { + return Array.Empty(); + } + + var first = Core.Memory.Read(addr + Offsets.SnipeObjects); + var end = Core.Memory.Read(addr + Offsets.SnipeObjects + 8); + + var count = (uint)((end.ToInt64() - first.ToInt64()) / 0x48); + Log.Information($"{count} snipe objects found"); + return Core.Memory.ReadArray(first, (int)count); + } + } + + public static bool Ready => State == 4; + + public static async Task Snipe(byte index) { if (addr == IntPtr.Zero) { - return Array.Empty(); + return; } - var first = Core.Memory.Read(addr + Offsets.SnipeObjects); - var end = Core.Memory.Read(addr + Offsets.SnipeObjects + 8); + var obj = SnipeObjects[index]; - var count = (uint)((end.ToInt64() - first.ToInt64()) / 0x48); - Log.Information($"{count} snipe objects found"); - return Core.Memory.ReadArray(first, (int)count); + byte shoot_1 = 0; + if (obj.x18 != 0 && obj.x22 != 0) + { + shoot_1 = 0; + } + else if (obj.x34 != 0 && obj.x3e != 0) + { + shoot_1 = 1; + } + else + { + Log.Information($"Tried to snipe object but object is in an unexpected state. {obj}"); + return; + } + + Log.Information($"Snipe {obj.GameObject?.Name ?? "Unknown Object"}"); + Core.Memory.Write(addr + Offsets.ShootData, index); //0x5000 - this should be object Index (0x4c) (0x4e) + //ox4c - should be the object index + //ox4e - should be the array index (0 or 1) + // these get set during state 4 + Core.Memory.Write(addr + Offsets.ShootData + 1, shoot_1); //0x5001 + Core.Memory.Write(addr + Offsets.ShootData + 2, shoot_1 == 0 ? obj.x22 : obj.x3e); //0x5002 + Core.Memory.Write(addr + Offsets.ShootData + 4, 1); //0x5004 + State = (byte)(State + 1); + + await Coroutine.Sleep(500); } } - public static bool Ready => State == 4; - - public static async Task Snipe(byte index) + [StructLayout(layoutKind: LayoutKind.Explicit, Size = 0x48)] + public struct SnipeObject { - if (addr == IntPtr.Zero) - { - return; - } - var obj = SnipeObjects[index]; + [FieldOffset(0)] + private IntPtr objPtr; - byte shoot_1 = 0; - if (obj.x18 != 0 && obj.x22 != 0) - { - shoot_1 = 0; - } - else if (obj.x34 != 0 && obj.x3e != 0) - { - shoot_1 = 1; - } - else - { - Log.Information($"Tried to snipe object but object is in an unexpected state. {obj}"); - return; - } + // -0x10 + [FieldOffset(0x8)] + internal byte x8; + //Start of array 1 + [FieldOffset(0x18)] + internal byte x18; + [FieldOffset(0x22)] + internal byte x22; - Log.Information($"Snipe {obj.GameObject?.Name ?? "Unknown Object"}"); - Core.Memory.Write(addr + Offsets.ShootData, index); //0x5000 - this should be object Index (0x4c) (0x4e) - //ox4c - should be the object index - //ox4e - should be the array index (0 or 1) - // these get set during state 4 - Core.Memory.Write(addr + Offsets.ShootData + 1, shoot_1); //0x5001 - Core.Memory.Write(addr + Offsets.ShootData + 2, shoot_1 == 0 ? obj.x22 : obj.x3e); //0x5002 - Core.Memory.Write(addr + Offsets.ShootData + 4, 1); //0x5004 - State = (byte)(State + 1); + //-0x10 + [FieldOffset(0x24)] + internal byte x24; - await Coroutine.Sleep(500); - } -} + //start of array 2 + [FieldOffset(0x34)] + internal byte x34; -[StructLayout(layoutKind: LayoutKind.Explicit, Size = 0x48)] -public struct SnipeObject -{ - [FieldOffset(0)] private IntPtr objPtr; - - // -0x10 - [FieldOffset(0x8)] - internal byte x8; - //Start of array 1 - [FieldOffset(0x18)] - internal byte x18; - [FieldOffset(0x22)] - internal byte x22; - - //-0x10 - [FieldOffset(0x24)] - internal byte x24; - //start of array 2 - [FieldOffset(0x34)] - internal byte x34; - [FieldOffset(0x3e)] - internal byte x3e; - - [FieldOffset(0x44)] - public byte Hit; - - public override string ToString() - { - return $"{GameObject?.Name ?? "Null Object"} - Hit:{Hit:X} - {x8:X} - {x18:X}:{x22:X} or {x34:X}:{x3e:X}"; - } + [FieldOffset(0x3e)] + internal byte x3e; - public GameObject? GameObject - { - get + [FieldOffset(0x44)] + public byte Hit; + + public override string ToString() + { + return $"{GameObject?.Name ?? "Null Object"} - Hit:{Hit:X} - {x8:X} - {x18:X}:{x22:X} or {x34:X}:{x3e:X}"; + } + + public GameObject? GameObject { - var id = objPtr; - if (objPtr == IntPtr.Zero) - return null; - return GameObjectManager.GameObjects.FirstOrDefault(i => i.Pointer == id); + get + { + var id = objPtr; + return objPtr == IntPtr.Zero ? null : GameObjectManager.GameObjects.FirstOrDefault(i => i.Pointer == id); + } } } -} -} +} \ No newline at end of file diff --git a/Memory/OffsetManager.cs b/Memory/OffsetManager.cs index 5226188e..44ad4522 100644 --- a/Memory/OffsetManager.cs +++ b/Memory/OffsetManager.cs @@ -1,4 +1,4 @@ -/* +/* DeepDungeon is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. @@ -9,7 +9,6 @@ You should have received a copy of the license along with this */ using System; -using System.CodeDom; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; @@ -24,7 +23,6 @@ You should have received a copy of the license along with this using System.Windows.Media; using Clio.Utilities; using ff14bot; -using ff14bot.Enums; using ff14bot.Helpers; using ff14bot.Managers; using GreyMagic; @@ -119,7 +117,7 @@ public static async Task InitLib() newStopwatch.Restart(); - Logger.Information($"OffsetManager Init took {stopwatch.ElapsedMilliseconds}ms {new System.Diagnostics.StackTrace().GetFrame(1).GetMethod().DeclaringType.Name}"); + Logger.Information($"OffsetManager Init took {stopwatch.ElapsedMilliseconds}ms {new System.Diagnostics.StackTrace().GetFrame(1)?.GetMethod()?.DeclaringType?.Name}"); PrintLastCommit(); } @@ -139,24 +137,27 @@ public static async Task InitLib() stopwatch.Stop(); Logger.Debug($"OffsetManager Init took {stopwatch.ElapsedMilliseconds}ms"); } + return true; } private static void PrintLastCommit() { - var lastCommitfile = Path.Combine(GeneralFunctions.SourceDirectory().Parent.FullName, "LastCommit.txt"); - if (File.Exists(lastCommitfile)) + var lastCommitfile = Path.Combine(GeneralFunctions.SourceDirectory()?.Parent?.FullName ?? string.Empty, "LastCommit.txt"); + if (!File.Exists(lastCommitfile)) { - var lastCommit = File.ReadAllText(lastCommitfile).Trim(); - if (DateTime.TryParse(lastCommit, out DateTime result)) - { - Logger.Information($"Last Commit: {result.ToUniversalTime():ddd, dd MMM yyy HH:mm:ss ‘UTC’}"); - Logger.Information($"Raw Last Commit: {lastCommit}"); - } - else - { - Logger.Information($"Last Commit: '{lastCommit}'"); - } + return; + } + + var lastCommit = File.ReadAllText(lastCommitfile).Trim(); + if (DateTime.TryParse(lastCommit, out DateTime result)) + { + Logger.Information($"Last Commit: {result.ToUniversalTime():ddd, dd MMM yyy HH:mm:ss ‘UTC’}"); + Logger.Information($"Raw Last Commit: {lastCommit}"); + } + else + { + Logger.Information($"Last Commit: '{lastCommit}'"); } } @@ -221,8 +222,7 @@ internal static void SetPostOffsets() { IntPtr.Zero }, - null) - ).RegisteredVtable; + null)!)!.RegisteredVtable; if (vtables.ContainsKey(test)) { diff --git a/packages.config b/packages.config deleted file mode 100644 index 94537633..00000000 --- a/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file