1
0
forked from liza/Questionable

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; var simulatedQuest = _questController.SimulatedQuest;
if (simulatedQuest != null) if (simulatedQuest != null && HandleTravelYesNo(addonSelectYesno, simulatedQuest, actualPrompt))
HandleTravelYesNo(addonSelectYesno, simulatedQuest, actualPrompt); return;
var nextQuest = _questController.NextQuest;
if (nextQuest != null)
HandleTravelYesNo(addonSelectYesno, nextQuest, actualPrompt);
} }
private unsafe bool HandleDefaultYesNo(AddonSelectYesno* addonSelectYesno, Quest quest, private unsafe bool HandleDefaultYesNo(AddonSelectYesno* addonSelectYesno, Quest quest,

View File

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

View File

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

View File

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

View File

@ -91,40 +91,38 @@ internal sealed class ActiveQuestComponent
{ {
if (currentQuestType == QuestController.CurrentQuestType.Simulated) if (currentQuestType == QuestController.CurrentQuestType.Simulated)
{ {
var simulatedQuest = _questController.SimulatedQuest ?? currentQuest;
using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed); using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
ImGui.TextUnformatted( 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; var startedQuest = _questController.StartedQuest;
if (startedQuest != null) if (startedQuest != null)
DrawCurrentQuest(startedQuest); {
ImGui.TextUnformatted(
$"Quest: {startedQuest.Quest.Info.Name} / {startedQuest.Sequence} / {startedQuest.Step}");
using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow); if (startedQuest.Quest.Root.Disabled)
ImGui.TextUnformatted( {
$"Next Quest: {currentQuest.Quest.Info.Name} / {currentQuest.Sequence} / {currentQuest.Step}"); ImGui.SameLine();
} ImGui.TextColored(ImGuiColors.DalamudRed, "Disabled");
else }
DrawCurrentQuest(currentQuest);
}
private void DrawCurrentQuest(QuestController.QuestProgress currentQuest) if (_configuration.Advanced.AdditionalStatusInformation && _questController.IsInterruptible())
{ {
ImGui.TextUnformatted( ImGui.SameLine();
$"Quest: {currentQuest.Quest.Info.Name} / {currentQuest.Sequence} / {currentQuest.Step}"); ImGui.TextColored(ImGuiColors.DalamudYellow, "Interruptible");
}
}
if (currentQuest.Quest.Root.Disabled) var nextQuest = _questController.NextQuest;
{ if (nextQuest != null)
ImGui.SameLine(); {
ImGui.TextColored(ImGuiColors.DalamudRed, "Disabled"); using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
} ImGui.TextUnformatted(
$"Next Quest: {currentQuest.Quest.Info.Name} / {currentQuest.Sequence} / {currentQuest.Step}");
if (_configuration.Advanced.AdditionalStatusInformation && _questController.IsInterruptible()) }
{
ImGui.SameLine();
ImGui.TextColored(ImGuiColors.DalamudYellow, "Interruptible");
} }
} }

View File

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