diff --git a/AutoHook/WorldStateUpdater.cs b/AutoHook/WorldStateUpdater.cs index 4dba186e..2d4d92fa 100644 --- a/AutoHook/WorldStateUpdater.cs +++ b/AutoHook/WorldStateUpdater.cs @@ -8,6 +8,7 @@ using FFXIVClientStructs.FFXIV.Client.Game.WKS; using FFXIVClientStructs.FFXIV.Client.UI.Agent; using Lumina.Excel.Sheets; +using System.Reflection; namespace AutoHook; @@ -25,6 +26,9 @@ public sealed class WorldStateUpdater : IDisposable { private readonly Hook? _updateCatchHook; private readonly Hook? _playAnimationHook; private static IReadOnlyList FshActions = []; + private static readonly FieldInfo? WksMissionScoreField = + typeof(WKSMissionModule.MissionState).GetField("ScoreUInt") ?? + typeof(WKSMissionModule.MissionState).GetField("Score"); private bool _needInventoryUpdate = true; @@ -305,11 +309,12 @@ private static unsafe WKSInfo.OpState CollectWKSInfo() { devGrade = wks->State.DevGrade; currentFateControlRowId = wks->State.CurrentFateControlRowId; currentFateId = wks->State.CurrentFateId; - currentMissionUnitRowId = wks->State.CurrentMission.MissionUnitRowId; - currentScore = wks->State.CurrentMission.ScoreUInt; - currentRank = wks->State.CurrentMission.Rank; - collectedTotal = wks->State.CurrentMission.CollectedTotal; - collectedIndividual = wks->State.CurrentMission.CollectedIndividual; + var mission = wks->State.CurrentMission; + currentMissionUnitRowId = mission.MissionUnitRowId; + currentScore = GetWksMissionScore(mission); + currentRank = mission.Rank; + collectedTotal = mission.CollectedTotal; + collectedIndividual = mission.CollectedIndividual; } } catch { } @@ -317,6 +322,15 @@ private static unsafe WKSInfo.OpState CollectWKSInfo() { return new WKSInfo.OpState(devGrade, currentFateControlRowId, currentFateId, currentMissionUnitRowId, currentScore, currentRank, collectedTotal, collectedIndividual); } + private static uint GetWksMissionScore(WKSMissionModule.MissionState mission) { + var score = WksMissionScoreField?.GetValue(mission); + return score switch { + uint value => value, + ushort value => value, + _ => 0, + }; + } + private static unsafe WorldState.OpZone CollectZone() => new(WeatherManager.Instance()->GetCurrentWeather(), Svc.ClientState.TerritoryType); }