1
0
Fork 0
forked from aly/qstbak

muffin v7.5.12

This commit is contained in:
alydev 2026-08-19 13:19:57 +10:00
parent 3102923ce2
commit 911ed68baa
65 changed files with 2356 additions and 1539 deletions

View file

@ -86,6 +86,12 @@ internal static class Action
return Environment.TickCount64 - _questFlagWaitStarted > (long)(timeoutSeconds * 1000f);
}
public override void ResetTimeout()
{
base.ResetTimeout();
_questFlagWaitStarted = Environment.TickCount64;
}
protected override bool Start()
{
if (base.Task.DataId.HasValue)
@ -283,6 +289,12 @@ internal static class Action
return Environment.TickCount64 - _startedAt > (long)(timeoutSeconds * 1000f);
}
public override void ResetTimeout()
{
base.ResetTimeout();
_startedAt = Environment.TickCount64;
}
protected override bool Start()
{
if (gameFunctions.HasStatus(base.Task.Status))

View file

@ -209,6 +209,8 @@ internal static class Duty
{
private long _startMs;
private bool _runAccepted;
protected unsafe override bool Start()
{
if (!territoryData.TryGetContentFinderCondition(base.Task.ContentFinderConditionId, out TerritoryData.ContentFinderConditionData contentFinderConditionData))
@ -240,6 +242,7 @@ internal static class Duty
}
autoDutyIpc.StartInstance(base.Task.ContentFinderConditionId, base.Task.DutyMode);
_startMs = Environment.TickCount64;
_runAccepted = false;
return true;
}
@ -255,8 +258,15 @@ internal static class Duty
}
if (!autoDutyIpc.IsStopped())
{
_runAccepted = true;
return ETaskResult.StillRunning;
}
if (!_runAccepted)
{
logger.LogError("AutoDuty did not start duty {CfcId} (territory {TerritoryId}) - Run was rejected, check the AutoDuty log [{Installation}]", base.Task.ContentFinderConditionId, contentFinderConditionData.TerritoryId, autoDutyIpc.DescribeInstallation());
chatGui.PrintError("AutoDuty did not start the duty (rejected the run), check the AutoDuty log.", "Questionable", 576);
return ETaskResult.End;
}
if (Environment.TickCount64 - _startMs < 10000)
{
return ETaskResult.StillRunning;
@ -277,7 +287,7 @@ internal static class Duty
}
}
internal sealed record WaitAutoDutyTask(uint ContentFinderConditionId) : ITask
internal sealed record WaitAutoDutyTask(uint ContentFinderConditionId) : IDutyTask, ITask
{
public override string ToString()
{
@ -433,17 +443,7 @@ internal static class Duty
{
protected override bool Start()
{
CombatController.CombatData combatData = new CombatController.CombatData
{
ElementId = null,
Sequence = 0,
CompletionQuestVariablesFlags = new List<QuestWorkValue>(),
SpawnType = EEnemySpawnType.None,
KillEnemyDataIds = new List<uint>(),
ComplexCombatDatas = new List<ComplexCombatData>(),
CombatItemUse = null
};
if (rsrModule.Start(combatData))
if (rsrModule.StartForDuty())
{
logger.LogDebug("Enabled RSR Henched mode for AutoDuty run");
return true;

View file

@ -92,6 +92,10 @@ internal static class EquipRecommended
private bool _smartApplied;
private bool _useDirectEquip;
private uint _smartClassJobId;
private int _directEquipCursor;
private bool _directEquipStarted;
@ -150,8 +154,9 @@ internal static class EquipRecommended
EClassJob job = (EClassJob)rowId;
StatPriority priority = StatPriority.ForJob(job);
byte playerLevel = GetPlayerLevel(job);
RaptureGearsetModule.GearsetEntry* entry = (RaptureGearsetModule.GearsetEntry*)Unsafe.AsPointer(in ptr->Entries[currentGearsetIndex]);
if (!TryComputeUpgradesAndMoves(job, priority, playerLevel, entry, out _smartUpgrades, out _smartMoves))
_smartClassJobId = rowId;
_useDirectEquip = configuration.General.PreserveGearset || !CurrentGearsetMatchesEquippedItems();
if (!TryComputeUpgradesAndMoves(job, priority, playerLevel, out _smartUpgrades, out _smartMoves))
{
_smartUpgrades = null;
_smartMoves = null;
@ -196,7 +201,11 @@ internal static class EquipRecommended
}
return ETaskResult.StillRunning;
}
if (configuration.General.PreserveGearset)
if (!_useDirectEquip && !CurrentGearsetMatchesEquippedItems())
{
_useDirectEquip = true;
}
if (_useDirectEquip)
{
return DirectEquipPhase();
}
@ -403,10 +412,20 @@ internal static class EquipRecommended
return true;
}
private unsafe bool TryComputeUpgradesAndMoves(EClassJob job, StatPriority priority, byte playerLevel, RaptureGearsetModule.GearsetEntry* entry, out List<(int Slot, BestItemRef Item)> upgrades, out List<PendingMove> moves)
private unsafe bool TryComputeUpgradesAndMoves(EClassJob job, StatPriority priority, byte playerLevel, out List<(int Slot, BestItemRef Item)> upgrades, out List<PendingMove> moves)
{
upgrades = new List<(int, BestItemRef)>();
moves = new List<PendingMove>();
InventoryManager* ptr = InventoryManager.Instance();
if (ptr == null)
{
return false;
}
InventoryContainer* inventoryContainer = ptr->GetInventoryContainer(InventoryType.EquippedItems);
if (inventoryContainer == null)
{
return false;
}
BestItemRef? bestItemRef = null;
bool flag = job.IsCrafter() || job.IsGatherer();
Dictionary<InventoryType, int> cursors = new Dictionary<InventoryType, int>();
@ -434,7 +453,8 @@ internal static class EquipRecommended
{
bestItemRef = bestItemRef2;
}
if (((ItemHandle)entry->GetItem((RaptureGearsetModule.GearsetItemIndex)i).ItemId).Id == ((ItemHandle)bestItemRef2.Value.ItemId).Id)
InventoryItem* inventorySlot = inventoryContainer->GetInventorySlot(i);
if (((inventorySlot != null) ? ItemHandle.FromInventorySlot(inventorySlot).Id : 0) == ((ItemHandle)bestItemRef2.Value.ItemId).Id)
{
continue;
}
@ -457,6 +477,48 @@ internal static class EquipRecommended
return true;
}
private unsafe bool CurrentGearsetMatchesEquippedItems()
{
RaptureGearsetModule* ptr = RaptureGearsetModule.Instance();
if (ptr == null)
{
return false;
}
int currentGearsetIndex = ptr->CurrentGearsetIndex;
if (currentGearsetIndex < 0 || !ptr->IsValidGearset(currentGearsetIndex))
{
return false;
}
RaptureGearsetModule.GearsetEntry* ptr2 = (RaptureGearsetModule.GearsetEntry*)Unsafe.AsPointer(in ptr->Entries[currentGearsetIndex]);
if (ptr2->ClassJob != _smartClassJobId)
{
return false;
}
InventoryManager* ptr3 = InventoryManager.Instance();
if (ptr3 == null)
{
return false;
}
InventoryContainer* inventoryContainer = ptr3->GetInventoryContainer(InventoryType.EquippedItems);
if (inventoryContainer == null)
{
return false;
}
for (int i = 0; i <= 13; i++)
{
if (i != 5)
{
InventoryItem* inventorySlot = inventoryContainer->GetInventorySlot(i);
uint num = ((inventorySlot != null) ? ItemHandle.FromInventorySlot(inventorySlot).Id : 0u);
if (((ItemHandle)ptr2->GetItem((RaptureGearsetModule.GearsetItemIndex)i).ItemId).Id != num)
{
return false;
}
}
}
return true;
}
private static bool IsBagContainer(InventoryType type)
{
if (type <= InventoryType.Inventory4)

View file

@ -66,6 +66,12 @@ internal static class MeldMateria
return Environment.TickCount64 - _stateChangedAt > (long)(timeoutSeconds * 1000f);
}
public override void ResetTimeout()
{
base.ResetTimeout();
_stateChangedAt = Environment.TickCount64;
}
private void SetState(EMeldState state)
{
_state = state;

View file

@ -193,7 +193,7 @@ internal static class SinglePlayerDuty
}
}
internal sealed record WaitSinglePlayerDuty(uint ContentFinderConditionId) : ITask
internal sealed record WaitSinglePlayerDuty(uint ContentFinderConditionId) : IDutyTask, ITask
{
public override string ToString()
{
@ -302,7 +302,7 @@ internal static class SinglePlayerDuty
}
}
internal sealed record CheckDutyOutcome(ElementId QuestId, byte SequenceBeforeEntering, IReadOnlyList<byte>? VariablesBeforeEntering, IList<QuestWorkValue?> CompletionQuestVariablesFlags, IReadOnlyList<ITask> DutyTasks) : ITask
internal sealed record CheckDutyOutcome(ElementId QuestId, byte SequenceBeforeEntering, IReadOnlyList<byte>? VariablesBeforeEntering, IList<QuestWorkValue?> CompletionQuestVariablesFlags, IReadOnlyList<ITask> DutyTasks) : IDutyTask, ITask
{
public override string ToString()
{