commit 40a3e6c2027d27cd2ea9e7bf42424e7f5cd3bf33 Author: Liza Carvelli Date: Wed May 29 01:20:15 2024 +0200 Found my old source copy diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a41e61d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +[*.{cs,vb}] + +# IDE0003: Remove qualification +dotnet_style_qualification_for_event = false:none + +# IDE0003: Remove qualification +dotnet_style_qualification_for_field = false:none + +# IDE0003: Remove qualification +dotnet_style_qualification_for_method = false:none + +# IDE0003: Remove qualification +dotnet_style_qualification_for_property = false:none + +# IDE0060: Remove unused parameter +dotnet_code_quality_unused_parameters = non_public:suggestion diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4ce6fdd --- /dev/null +++ b/.gitignore @@ -0,0 +1,340 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- Backup*.rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb \ No newline at end of file diff --git a/DalamudPackager.targets b/DalamudPackager.targets new file mode 100644 index 0000000..05ca48f --- /dev/null +++ b/DalamudPackager.targets @@ -0,0 +1,18 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Plugin.cs b/Plugin.cs new file mode 100644 index 0000000..dbd2f8b --- /dev/null +++ b/Plugin.cs @@ -0,0 +1,193 @@ +using Dalamud.Game.ClientState.Objects.Types; +using Dalamud.Plugin; +using FFXIVClientStructs.FFXIV.Client.Game; +using FFXIVClientStructs.FFXIV.Client.Game.UI; +using ImGuiNET; +using System; +using System.Collections.Generic; +using System.Numerics; +using Dalamud.Interface.Utility; +using Dalamud.Plugin.Services; + +namespace ZodiacFinder +{ + public class Plugin : IDalamudPlugin + { + private readonly DalamudPluginInterface pluginInterface; + private readonly IChatGui chat; + private readonly IClientState clientState; + private readonly IObjectTable objectTable; + private readonly IDataManager dataManager; + private readonly IGameGui gameGui; + + private readonly IDictionary books = new Dictionary(); + + private ISet atmaWeapons = new HashSet { + 7824, // Curtana Atma + 7825, // Sphairai Atma + 7826, // Bravura Atma + 7827, // Gae Bolg Atma + 7828, // Artemis Bow Atma + 7829, // Thyrus Atma + 7830, // Stardust Rod Atma + 7831, // Veil of Wiyu Atma + 7832, // Omnilex Atma + 7833, // Holy Shield Atma + 9251, // Yoshimitsu Atma + }; + + public string Name => "ZodiacFinder"; + + public Plugin( + DalamudPluginInterface pi, + ICommandManager commands, + IChatGui chat, + IClientState clientState, + IObjectTable objectTable, + IDataManager dataManager, + IGameGui gameGui) + { + this.pluginInterface = pi; + this.chat = chat; + this.clientState = clientState; + this.objectTable = objectTable; + this.dataManager = dataManager; + this.gameGui = gameGui; + + this.pluginInterface.UiBuilder.Draw += this.Draw; + + this.PopulateBooks(); + } + + #region IDisposable Support + protected virtual void Dispose(bool disposing) + { + if (!disposing) return; + + this.pluginInterface.UiBuilder.Draw -= this.Draw; + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + #endregion + + private unsafe void Draw() + { + if (!clientState.IsLoggedIn || clientState.IsPvP || objectTable == null || !HasAtmaWeaponEquipped()) + return; + + var bookId = GetCurrentBook(); + if (bookId == 0) + return; + + var relicNote = RelicNote.Instance(); + if (relicNote == null) + return; + + var book = books[bookId]; + for (int index = 0; index < objectTable.Length; ++index) + { + GameObject obj = objectTable[index]; + if (!(obj is BattleNpc npc) || npc.CurrentHp == 0) + continue; + + var indexInBook = book.Enemies.IndexOf(npc.NameId); + if (indexInBook == -1) + continue; + + if (relicNote->GetMonsterProgress(indexInBook) >= 3) + continue; + + if (!gameGui.WorldToScreen(new Vector3(obj.Position.X, obj.Position.Y, obj.Position.Z), out var pos)) + continue; + + ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 0)); + ImGuiHelpers.ForceNextWindowMainViewport(); + ImGuiHelpers.SetNextWindowPosRelativeMainViewport(new Vector2(0, 0)); + ImGui.Begin($"zodiac###{index}", + ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoTitleBar | + ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoSavedSettings); + ImGui.SetWindowSize(ImGui.GetIO().DisplaySize); + + ImGui.GetWindowDrawList().AddCircleFilled(new Vector2(pos.X, pos.Y), 5f, ImGui.GetColorU32(0xff0000ff), 100); + //ImGui.GetWindowDrawList().AddText(new Vector2(pos.X, pos.Y), ImGui.GetColorU32(0xffffffff), $"{npc.NameId} - {obj.Name.TextValue}"); + + ImGui.End(); + ImGui.PopStyleVar(); + } + } + + private bool HasAtmaWeaponEquipped() + { + return atmaWeapons.Contains(GetEquippedItem(0)) || atmaWeapons.Contains(GetEquippedItem(1)); + } + + private unsafe uint GetCurrentBook() + { + var im = InventoryManager.Instance(); + if (im == null) + return 0; + + var keyItems = im->GetInventoryContainer(InventoryType.KeyItems); + for (int i = 0; i < keyItems->Size; ++i) + { + var slot = keyItems->GetInventorySlot(i); + if (slot == null) + continue; + + uint itemId = slot->ItemID; + if (books.ContainsKey(itemId)) + return itemId; + } + + return 0; + } + + private unsafe uint GetEquippedItem(int index) + { + var im = InventoryManager.Instance(); + if (im == null) + return 0; + + var equipped = im->GetInventoryContainer(InventoryType.EquippedItems); + if (equipped == null) + return 0; + + var slot = equipped->GetInventorySlot(index); + if (slot == null) + return 0; + + return slot->ItemID; + } + + private void PopulateBooks() + { + var relicNoteSheet = this.dataManager.GetExcelSheet()!; + foreach (var row in relicNoteSheet) + { + if (row.EventItem == null || row.EventItem.Row == 0) + continue; + + var book = new Book(); + for (int i = 0; i < row.MonsterNoteTargetCommon.Length; i++) + { + book.Enemies.Add(row.MonsterNoteTargetCommon[i].MonsterNoteTargetCommon.Value!.BNpcName.Row); + } + //chat.Print($"{row.EventItem.Row} - {book}"); + books.Add(row.EventItem.Row, book); + } + } + + internal sealed class Book + { + public IList Enemies = new List(); + public override string ToString() + { + return string.Join(",", Enemies); + } + } + } +} diff --git a/RelicNote.cs b/RelicNote.cs new file mode 100644 index 0000000..5b7d903 --- /dev/null +++ b/RelicNote.cs @@ -0,0 +1,110 @@ +using Lumina; +using Lumina.Data; +using Lumina.Excel; +using Lumina.Excel.GeneratedSheets; + +namespace ZodiacFinder.Excel +{ + [Sheet("RelicNote", columnHash: 0xb557320e)] + public partial class RelicNote : ExcelRow + { + public class RelicNoteMonsterNoteTargetCommon + { + public LazyRow MonsterNoteTargetCommon { get; set; } + + public byte MonsterCount { get; set; } + } + + public class RelicNoteFate + { + public LazyRow Fate { get; set; } + + public LazyRow PlaceName { get; set; } + } + + public LazyRow EventItem { get; set; } + + public RelicNoteMonsterNoteTargetCommon[] MonsterNoteTargetCommon { get; set; } + + public LazyRow[] MonsterNoteTargetNM { get; set; } + + public ushort Unknown24 { get; set; } + + public RelicNoteFate[] Fate { get; set; } + + public LazyRow[] Leve { get; set; } + + /// + public override void PopulateData(RowParser parser, GameData gameData, Language language) + { + base.PopulateData(parser, gameData, language); + + this.EventItem = new LazyRow(gameData, parser.ReadColumn(0), language); + this.MonsterNoteTargetCommon = new RelicNoteMonsterNoteTargetCommon[10]; + for (var i = 0; i < 10; i++) + { + this.MonsterNoteTargetCommon[i] = new RelicNoteMonsterNoteTargetCommon + { + MonsterNoteTargetCommon = new LazyRow(gameData, parser.ReadColumn(1 + (i * 2) + 0), language), + MonsterCount = parser.ReadColumn(1 + (i * 2) + 1), + }; + } + + this.MonsterNoteTargetNM = new LazyRow[3]; + for (var i = 0; i < 3; i++) + this.MonsterNoteTargetNM[i] = new LazyRow(gameData, parser.ReadColumn(21 + i), language); + + this.Unknown24 = parser.ReadColumn(24); + this.Fate = new RelicNoteFate[3]; + for (var i = 0; i < 3; i++) + { + this.Fate[i] = new RelicNoteFate + { + Fate = new LazyRow(gameData, parser.ReadColumn(25 + (i * 2) + 0), language), + PlaceName = new LazyRow(gameData, parser.ReadColumn(25 + (i * 2) + 1), language), + }; + } + + this.Leve = new LazyRow[3]; + for (var i = 0; i < 3; i++) + this.Leve[i] = new LazyRow(gameData, parser.ReadColumn(31 + i), language); + } + } + + [Sheet("MonsterNoteTarget", columnHash: 0x4157404f)] + public partial class MonsterNoteTarget : ExcelRow + { + public class MonsterNoteTargetPlaceName + { + public LazyRow Zone { get; set; } + + public LazyRow Location { get; set; } + } + + public LazyRow BNpcName { get; set; } + + public int Icon { get; set; } + + public LazyRow Town { get; set; } + + public MonsterNoteTargetPlaceName[] PlaceName { get; set; } + + public override void PopulateData(RowParser parser, GameData gameData, Language language) + { + base.PopulateData(parser, gameData, language); + + this.BNpcName = new LazyRow(gameData, parser.ReadColumn(0), language); + this.Icon = parser.ReadColumn(1); + this.Town = new LazyRow(gameData, parser.ReadColumn(2), language); + this.PlaceName = new MonsterNoteTargetPlaceName[3]; + for (var i = 0; i < 3; i++) + { + this.PlaceName[i] = new MonsterNoteTargetPlaceName + { + Zone = new LazyRow(gameData, parser.ReadColumn(3 + (i * 2) + 0), language), + Location = new LazyRow(gameData, parser.ReadColumn(3 + (i * 2) + 1), language), + }; + } + } + } +} diff --git a/ZodiacFinder.csproj b/ZodiacFinder.csproj new file mode 100644 index 0000000..8194e3d --- /dev/null +++ b/ZodiacFinder.csproj @@ -0,0 +1,52 @@ + + + + net7.0-windows + 9.0 + 2.0.0.0 + none + + + + false + x64 + true + + + + + + + + + + $(AppData)\XIVLauncher\addon\Hooks\dev\Dalamud.dll + false + + + $(AppData)\XIVLauncher\addon\Hooks\dev\ImGui.NET.dll + false + + + $(AppData)\XIVLauncher\addon\Hooks\dev\ImGuiScene.dll + false + + + $(AppData)\XIVLauncher\addon\Hooks\dev\Lumina.dll + false + + + $(AppData)\XIVLauncher\addon\Hooks\dev\Lumina.Excel.dll + false + + + $(AppData)\XIVLauncher\addon\Hooks\dev\Newtonsoft.Json.dll + false + + + $(AppData)\XIVLauncher\addon\Hooks\dev\FFXIVClientStructs.dll + false + + + + diff --git a/ZodiacFinder.json b/ZodiacFinder.json new file mode 100644 index 0000000..30619f8 --- /dev/null +++ b/ZodiacFinder.json @@ -0,0 +1,8 @@ +{ + "Name": "ZodiacFinder", + "Author": "liza", + "Punchline": "Find Monsters for Zodiac Books", + "Description": "Find Monsters for Zodiac Books", + "RepoUrl": "", + "Tags": [] +} diff --git a/ZodiacFinder.sln b/ZodiacFinder.sln new file mode 100644 index 0000000..3d32b59 --- /dev/null +++ b/ZodiacFinder.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32414.318 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZodiacFinder", "ZodiacFinder.csproj", "{7A76E8A0-EF18-4FF3-A972-646635CEE119}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7A76E8A0-EF18-4FF3-A972-646635CEE119}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7A76E8A0-EF18-4FF3-A972-646635CEE119}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7A76E8A0-EF18-4FF3-A972-646635CEE119}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7A76E8A0-EF18-4FF3-A972-646635CEE119}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F19EF4CF-717B-4648-B1D6-C8CDE0202DAB} + EndGlobalSection +EndGlobal