qstcompanion v1.0.5

This commit is contained in:
alydev 2025-12-04 04:40:50 +10:00
parent 52daefcfd7
commit 5e1e1decc5
9 changed files with 304 additions and 200 deletions

View file

@ -42,6 +42,8 @@ public class Configuration : IPluginConfiguration
public List<string> SelectedCharactersForRotation { get; set; } = new List<string>();
public List<string> SelectedCharactersForUI { get; set; } = new List<string>();
public Dictionary<uint, List<string>> QuestCompletionByCharacter { get; set; } = new Dictionary<uint, List<string>>();
public Dictionary<string, List<string>> EventQuestCompletionByCharacter { get; set; } = new Dictionary<string, List<string>>();

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Reflection;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.Command;
@ -126,6 +127,8 @@ public sealed class Plugin : IDalamudPlugin, IDisposable
private AlliedSocietyPriorityWindow AlliedSocietyPriorityWindow { get; init; }
private ErrorRecoveryService ErrorRecoveryService { get; init; }
private ConfigWindow ConfigWindow { get; init; }
private NewMainWindow NewMainWindow { get; init; }
@ -182,7 +185,7 @@ public sealed class Plugin : IDalamudPlugin, IDisposable
Log.Debug("[Plugin] Initializing StepsOfFaithHandler...");
StepsOfFaithHandler = new StepsOfFaithHandler(Condition, Log, ClientState, CommandManager, Framework, Configuration);
Log.Debug("[Plugin] Initializing MSQProgressionService...");
MSQProgressionService = new MSQProgressionService(DataManager, Log, QuestDetection, ClientState, Framework);
MSQProgressionService = new MSQProgressionService(DataManager, Log, QuestDetection, ObjectTable, Framework);
Log.Debug("[Plugin] Initializing ChauffeurMode...");
ChauffeurMode = new ChauffeurModeService(Configuration, Log, ClientState, Condition, Framework, CommandManager, DataManager, PartyList, ObjectTable, QuestionableIPC, CrossProcessIPC, PartyInviteService, PartyInviteAutoAccept, PluginInterface, MemoryHelper, MovementMonitor);
MovementMonitor.SetChauffeurMode(ChauffeurMode);
@ -194,6 +197,9 @@ public sealed class Plugin : IDalamudPlugin, IDisposable
AlliedSocietyQuestSelector = new AlliedSocietyQuestSelector(QuestionableIPC, Log);
AlliedSocietyRotationService = new AlliedSocietyRotationService(QuestionableIPC, AlliedSocietyDatabase, AlliedSocietyQuestSelector, AutoRetainerIPC, Configuration, Log, Framework, CommandManager, Condition, ClientState);
AlliedSocietyPriorityWindow = new AlliedSocietyPriorityWindow(Configuration, AlliedSocietyDatabase);
Log.Debug("[Plugin] Initializing Error Recovery Service...");
ErrorRecoveryService = new ErrorRecoveryService(Log, GameInterop, ClientState, AutoRetainerIPC, Framework, GameGui);
QuestRotationService.SetErrorRecoveryService(ErrorRecoveryService);
MultiClientIPC.OnChatMessageReceived += OnMultiClientChatReceived;
CrossProcessIPC.OnChatMessageReceived += OnMultiClientChatReceived;
CrossProcessIPC.OnCommandReceived += OnCommandReceived;
@ -218,7 +224,7 @@ public sealed class Plugin : IDalamudPlugin, IDisposable
}
Log.Debug("[Plugin] Initializing windows...");
ConfigWindow = new ConfigWindow(this);
NewMainWindow = new NewMainWindow(this, AutoRetainerIPC, QuestTrackingService, QuestRotationService, EventQuestService, AlliedSocietyRotationService, AlliedSocietyPriorityWindow, dataCenterService, MSQProgressionService, Log, PluginInterface.UiBuilder, DataManager);
NewMainWindow = new NewMainWindow(this, AutoRetainerIPC, QuestTrackingService, QuestRotationService, EventQuestService, AlliedSocietyRotationService, AlliedSocietyPriorityWindow, dataCenterService, MSQProgressionService, Configuration, Log, PluginInterface.UiBuilder, DataManager);
DebugWindow = new DebugWindow(this, CombatDutyDetection, DeathHandler, DungeonAutomation);
WindowSystem.AddWindow(ConfigWindow);
WindowSystem.AddWindow(NewMainWindow);
@ -228,6 +234,14 @@ public sealed class Plugin : IDalamudPlugin, IDisposable
{
HelpMessage = "Open the Quest Sequence Manager"
});
string[] array = new string[2] { "/qstc", "/qstcompanion" };
foreach (string alias in array)
{
CommandManager.AddHandler(alias, new CommandInfo(OnCommand)
{
HelpMessage = "Open the Quest Sequence Manager"
});
}
CommandManager.AddHandler("/qsthelper", new CommandInfo(OnHelperCommand)
{
HelpMessage = "Helper commands: /qsthelper reset - Reset helper status to Available"
@ -393,6 +407,7 @@ public sealed class Plugin : IDalamudPlugin, IDisposable
LifestreamIPC?.Dispose();
AutoRetainerIPC?.Dispose();
QuestionableIPC?.Dispose();
ErrorRecoveryService?.Dispose();
Log.Debug("[Plugin] Services disposed");
}
catch (Exception ex3)
@ -418,6 +433,11 @@ public sealed class Plugin : IDalamudPlugin, IDisposable
{
CommandManager.RemoveHandler("/qstcomp");
CommandManager.RemoveHandler("/qsthelper");
string[] array = new string[2] { "/qstc", "/qstcompanion" };
foreach (string alias in array)
{
CommandManager.RemoveHandler(alias);
}
Log.Debug("[Plugin] Command handlers removed");
}
catch (Exception ex5)
@ -487,6 +507,9 @@ public sealed class Plugin : IDalamudPlugin, IDisposable
case "mounts":
TestListMounts();
break;
case "aetheryte":
TestFindNearestAetheryte();
break;
default:
NewMainWindow.Toggle();
break;
@ -802,6 +825,85 @@ public sealed class Plugin : IDalamudPlugin, IDisposable
Log.Information("========================================");
}
private void TestFindNearestAetheryte()
{
Log.Information("========================================");
Log.Information("[TEST] Finding Nearest Aetheryte (Map Data)");
Log.Information("========================================");
IPlayerCharacter player = ClientState.LocalPlayer;
if (player == null)
{
Log.Error("[TEST] Player not logged in!");
Log.Information("========================================");
return;
}
Vector3 playerPos = player.Position;
ushort territoryId = ClientState.TerritoryType;
Log.Information($"[TEST] Player Position: ({playerPos.X:F2}, {playerPos.Y:F2}, {playerPos.Z:F2})");
Log.Information($"[TEST] Territory ID: {territoryId}");
ExcelSheet<Aetheryte> aetheryteSheet = DataManager.GetExcelSheet<Aetheryte>();
ExcelSheet<Map> mapSheet = DataManager.GetExcelSheet<Map>();
if (aetheryteSheet == null || mapSheet == null)
{
Log.Error("[TEST] Failed to load sheets!");
Log.Information("========================================");
return;
}
float minDistance = float.MaxValue;
string nearestName = "Unknown";
uint nearestId = 0u;
int aetheryteCount = 0;
foreach (Aetheryte aetheryte in aetheryteSheet)
{
if (aetheryte.Territory.RowId != territoryId || !aetheryte.IsAetheryte)
{
continue;
}
aetheryteCount++;
PlaceName? placeName = aetheryte.PlaceName.ValueNullable;
string nameStr = (placeName.HasValue ? placeName.Value.Name.ExtractText() : $"Aetheryte #{aetheryte.RowId}");
Map? map = aetheryte.Map.ValueNullable;
if (map.HasValue)
{
float mapX = ConvertMapCoordinateToRawPosition(aetheryte.AetherstreamX, map.Value.SizeFactor);
float mapY = ConvertMapCoordinateToRawPosition(aetheryte.AetherstreamY, map.Value.SizeFactor);
Vector3 aethPos = new Vector3(mapX, 0f, mapY);
float num = playerPos.X - aethPos.X;
float dz = playerPos.Z - aethPos.Z;
float distance = (float)Math.Sqrt(num * num + dz * dz);
Log.Information($"[TEST] Aetheryte #{aetheryteCount}: {nameStr}");
Log.Information($"[TEST] Position: ({aethPos.X:F2}, ?, {aethPos.Z:F2})");
Log.Information($"[TEST] Distance (2D): {distance:F2} yalms");
Log.Information($"[TEST] Aetheryte ID: {aetheryte.RowId}");
if (distance < minDistance)
{
minDistance = distance;
nearestName = nameStr;
nearestId = aetheryte.RowId;
}
}
}
if (aetheryteCount == 0)
{
Log.Warning("[TEST] No aetherytes found in this territory!");
}
else
{
Log.Information("========================================");
Log.Information("[TEST] NEAREST AETHERYTE: " + nearestName);
Log.Information($"[TEST] Distance (2D): {minDistance:F2} yalms");
Log.Information($"[TEST] Aetheryte ID: {nearestId}");
Log.Information("========================================");
}
Log.Information("========================================");
}
private float ConvertMapCoordinateToRawPosition(int coordinate, ushort scale)
{
float c = (float)(int)scale / 100f;
return ((((float)coordinate - 1024f) / 2048f + 1f) * c / 2f - 1f) * (2048f / c) * 1000f / 2048f;
}
private void TestAlliedSociety()
{
Log.Information("========================================");