Fix next quest logic for alliance raids, update arr to-do

This commit is contained in:
Liza 2024-07-21 16:22:01 +02:00
parent a9b25e3722
commit cd72beca89
Signed by: liza
GPG Key ID: 7199F8D727D55F67
6 changed files with 81 additions and 55 deletions

View File

@ -383,8 +383,12 @@ internal sealed class GameUiController : IDisposable
}
var simulatedQuest = _questController.SimulatedQuest;
if (simulatedQuest != null)
HandleTravelYesNo(addonSelectYesno, simulatedQuest, actualPrompt);
if (simulatedQuest != null && HandleTravelYesNo(addonSelectYesno, simulatedQuest, actualPrompt))
return;
var nextQuest = _questController.NextQuest;
if (nextQuest != null)
HandleTravelYesNo(addonSelectYesno, nextQuest, actualPrompt);
}
private unsafe bool HandleDefaultYesNo(AddonSelectYesno* addonSelectYesno, Quest quest,

View File

@ -141,12 +141,7 @@ internal sealed class QuestController
{
DebugState = null;
byte currentSequence = 0;
if (_simulatedQuest != null)
{
currentSequence = _simulatedQuest.Sequence;
}
else if (_nextQuest != null)
if (_simulatedQuest == null && _nextQuest != null)
{
// if the quest is accepted, we no longer track it
bool canUseNextQuest;
@ -158,19 +153,25 @@ internal sealed class QuestController
if (!canUseNextQuest)
{
_logger.LogInformation("Next quest {QuestId} accepted or completed", _nextQuest.Quest.QuestId);
_nextQuest = null;
currentSequence = 0;
}
else
}
QuestProgress? questToRun;
byte currentSequence;
if (_simulatedQuest != null)
{
currentSequence = _simulatedQuest.Sequence;
questToRun = _simulatedQuest;
}
else if (_nextQuest != null && _gameFunctions.IsReadyToAcceptQuest(_nextQuest.Quest.QuestId))
{
questToRun = _nextQuest;
currentSequence = _nextQuest.Sequence; // by definition, this should always be 0
if (_nextQuest.Step == 0 && _currentTask == null && _taskQueue.Count == 0 && _automatic)
ExecuteNextStep(true);
}
}
if (_simulatedQuest == null && _nextQuest == null)
else
{
(ushort currentQuestId, currentSequence) = _gameFunctions.GetCurrentQuest();
if (currentQuestId == 0)
@ -181,6 +182,8 @@ internal sealed class QuestController
_startedQuest = null;
Stop("Resetting current quest");
}
questToRun = null;
}
else if (_startedQuest == null || _startedQuest.Quest.QuestId != currentQuestId)
{
@ -205,9 +208,10 @@ internal sealed class QuestController
return;
}
else
questToRun = _startedQuest;
}
var questToRun = CurrentQuest;
if (questToRun == null)
{
DebugState = "No quest active";
@ -230,7 +234,8 @@ internal sealed class QuestController
if (questToRun.Sequence != currentSequence)
{
questToRun.SetSequence(currentSequence);
Stop("New sequence", continueIfAutomatic: true);
Stop($"New sequence {questToRun == _startedQuest}/{_gameFunctions.GetCurrentQuestInternal()}",
continueIfAutomatic: true);
}
var q = questToRun.Quest;
@ -316,6 +321,7 @@ internal sealed class QuestController
private void ClearTasksInternal()
{
_logger.LogDebug("Clearing task (internally)");
_currentTask = null;
if (_taskQueue.Count > 0)
@ -626,8 +632,7 @@ internal sealed class QuestController
{
SetNextQuest(quest);
_chatGui.Print(
"[Questionable] Picking up quest '{Name}' as a priority over current main story/side quests",
quest.Info.Name);
$"[Questionable] Picking up quest '{quest.Info.Name}' as a priority over current main story/side quests.");
return true;
}
}

View File

@ -123,7 +123,7 @@ internal static class WaitAtEnd
var complete = serviceProvider.GetRequiredService<WaitQuestCompleted>()
.With(step.TurnInQuestId ?? quest.QuestId);
var delay = serviceProvider.GetRequiredService<WaitDelay>();
if (step.NextQuestId != null)
if (step.TurnInQuestId != null)
return [complete, delay, Next(quest, sequence)];
else
return [complete, delay];

View File

@ -35,12 +35,14 @@ internal sealed class ARealmRebornComponent
public void Draw()
{
var completedPrimals = UIState.IsInstanceContentCompleted(RequiredPrimalInstances.Last());
bool completedRaids = _gameFunctions.IsQuestComplete(RequiredAllianceRaidQuests.Last());
bool complete = completedPrimals && completedRaids;
bool hover = _uiUtils.ChecklistItem("ARR Primals & Raids",
complete ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed,
complete ? FontAwesomeIcon.Check : FontAwesomeIcon.Times);
DrawPrimals();
DrawAllianceRaids();
}
private void DrawPrimals()
{
bool complete = UIState.IsInstanceContentCompleted(RequiredPrimalInstances.Last());
bool hover = _uiUtils.ChecklistItem("Hard Mode Primals", complete);
if (complete || !hover)
return;
@ -48,14 +50,24 @@ internal sealed class ARealmRebornComponent
if (!tooltip)
return;
ImGui.Text("Primals:");
foreach (var instanceId in RequiredPrimalInstances)
{
(Vector4 color, FontAwesomeIcon icon) = UiUtils.GetInstanceStyle(instanceId);
_uiUtils.ChecklistItem(_territoryData.GetInstanceName(instanceId) ?? "?", color, icon);
}
}
private void DrawAllianceRaids()
{
bool complete = _gameFunctions.IsQuestComplete(RequiredAllianceRaidQuests.Last());
bool hover = _uiUtils.ChecklistItem("Crystal Tower Raids", complete);
if (complete || !hover)
return;
using var tooltip = ImRaii.Tooltip();
if (!tooltip)
return;
ImGui.Text("Alliance Raids:");
foreach (var questId in RequiredAllianceRaidQuests)
{
(Vector4 color, FontAwesomeIcon icon, _) = _uiUtils.GetQuestStyle(questId);

View File

@ -91,31 +91,19 @@ internal sealed class ActiveQuestComponent
{
if (currentQuestType == QuestController.CurrentQuestType.Simulated)
{
var simulatedQuest = _questController.SimulatedQuest ?? currentQuest;
using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
ImGui.TextUnformatted(
$"Simulated Quest: {simulatedQuest.Quest.Info.Name} / {simulatedQuest.Sequence} / {simulatedQuest.Step}");
$"Simulated Quest: {currentQuest.Quest.Info.Name} / {currentQuest.Sequence} / {currentQuest.Step}");
}
else if (currentQuestType == QuestController.CurrentQuestType.Next)
else
{
var startedQuest = _questController.StartedQuest;
if (startedQuest != null)
DrawCurrentQuest(startedQuest);
using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
ImGui.TextUnformatted(
$"Next Quest: {currentQuest.Quest.Info.Name} / {currentQuest.Sequence} / {currentQuest.Step}");
}
else
DrawCurrentQuest(currentQuest);
}
private void DrawCurrentQuest(QuestController.QuestProgress currentQuest)
{
ImGui.TextUnformatted(
$"Quest: {currentQuest.Quest.Info.Name} / {currentQuest.Sequence} / {currentQuest.Step}");
$"Quest: {startedQuest.Quest.Info.Name} / {startedQuest.Sequence} / {startedQuest.Step}");
if (currentQuest.Quest.Root.Disabled)
if (startedQuest.Quest.Root.Disabled)
{
ImGui.SameLine();
ImGui.TextColored(ImGuiColors.DalamudRed, "Disabled");
@ -128,6 +116,16 @@ internal sealed class ActiveQuestComponent
}
}
var nextQuest = _questController.NextQuest;
if (nextQuest != null)
{
using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
ImGui.TextUnformatted(
$"Next Quest: {currentQuest.Quest.Info.Name} / {currentQuest.Sequence} / {currentQuest.Step}");
}
}
}
private QuestWork? DrawQuestWork(QuestController.QuestProgress currentQuest)
{
ImGui.BeginDisabled();

View File

@ -54,4 +54,11 @@ internal sealed class UiUtils
ImGui.TextUnformatted(text);
return hover;
}
public bool ChecklistItem(string text, bool complete)
{
return ChecklistItem(text,
complete ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed,
complete ? FontAwesomeIcon.Check : FontAwesomeIcon.Times);
}
}