Add experimental NG+ support

This commit is contained in:
Liza 2024-06-19 13:00:14 +02:00
parent 09d50b1305
commit af37252629
Signed by: liza
GPG Key ID: 7199F8D727D55F67
3 changed files with 48 additions and 5 deletions

View File

@ -36,6 +36,16 @@
],
"TargetTerritoryId": 956
},
{
"Position": {
"X": -431.53903,
"Y": -220.1193,
"Z": 301.76364
},
"TerritoryId": 956,
"InteractionType": "WalkTo",
"Fly": true
},
{
"DataId": 1039827,
"Position": {
@ -45,7 +55,7 @@
},
"TerritoryId": 956,
"InteractionType": "Interact",
"Fly": true
"Fly": false
}
]
},

View File

@ -84,6 +84,16 @@
"FlyingUnlocked"
]
},
{
"Position": {
"X": -431.53903,
"Y": -220.1193,
"Z": 301.76364
},
"TerritoryId": 956,
"InteractionType": "WalkTo",
"Fly": true
},
{
"DataId": 1039582,
"Position": {
@ -93,7 +103,7 @@
},
"TerritoryId": 956,
"InteractionType": "Interact",
"Fly": true
"Fly": false
}
]
},

View File

@ -9,6 +9,7 @@ using System.Text;
using Dalamud.Game;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Memory;
using Dalamud.Plugin.Services;
using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Application.Network.WorkDefinitions;
@ -153,7 +154,7 @@ internal sealed unsafe class GameFunctions
{
// always prioritize accepting MSQ quests, to make sure we don't turn in one MSQ quest and then go off to do
// side quests until the end of time.
var msqQuest = GetMainStoryQuest(questManager);
var msqQuest = GetMainScenarioQuest(questManager);
if (msqQuest.CurrentQuest != 0 && !questManager->IsQuestAccepted(msqQuest.CurrentQuest))
return msqQuest;
@ -186,9 +187,31 @@ internal sealed unsafe class GameFunctions
return default;
}
// TODO This doesn't work with unaccepted quests in NG+, only accepted quests
private (ushort CurrentQuest, byte Sequence) GetMainStoryQuest(QuestManager* questManager)
private (ushort CurrentQuest, byte Sequence) GetMainScenarioQuest(QuestManager* questManager)
{
if (QuestManager.IsQuestComplete(3759)) // Memories Rekindled
{
AgentInterface* questRedoHud = AgentModule.Instance()->GetAgentByInternalId(AgentId.QuestRedoHud);
if (questRedoHud != null && questRedoHud->IsAgentActive())
{
// there's surely better ways to check this, but the one in the OOB Plugin was even less reliable
if (_gameGui.TryGetAddonByName<AtkUnitBase>("QuestRedoHud", out var addon) &&
addon->AtkValuesCount == 4 &&
// 0 seems to be active,
// 1 seems to be paused,
// 2 is unknown, but it happens e.g. before the quest 'Alzadaal's Legacy'
// 3 seems to be having /ng+ open while active,
// 4 seems to be when (a) suspending the chapter, or (b) having turned in a quest
addon->AtkValues[0].UInt is 0 or 2 or 3 or 4)
{
// redoHud+44 is chapter
// redoHud+46 is quest
ushort questId = MemoryHelper.Read<ushort>((nint)questRedoHud + 46);
return (questId, QuestManager.GetQuestSequence(questId));
}
}
}
var scenarioTree = AgentScenarioTree.Instance();
if (scenarioTree == null)
return default;