Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.

Commit

Permalink
fixed getting stuck on colo purify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
MgAl2O4 committed Feb 15, 2021
1 parent 637b9a8 commit 56f2963
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
39 changes: 36 additions & 3 deletions SINoCOLO/GameLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ public enum EUnknownBehavior
private TrackerActionBoost actionBoost = new TrackerActionBoost();
private DateTime lastClickTime;
private DateTime lastCombatTime;
private DateTime lastPurifyActTime;
private DateTime unknownStateStartTime;
private bool waitingForCombat = false;
private bool waitingForCombatReport = false;
private bool waitingForEventSummary = false;
private bool canWaitForPurifySpawn = false;
private bool useDebugScreenshotOnUnknown = false;

private Font overlayFont = new Font(FontFamily.GenericSansSerif, 7.0f);
Expand Down Expand Up @@ -568,8 +570,12 @@ private bool OnScan_ColoPurify(ScannerColoPurify.ScreenData screenData)
OnStateChanged();

useDebugScreenshotOnUnknown = false;
canWaitForPurifySpawn = true;
cachedDataMessageBox = null;

// mark activity for fallback clicking
lastPurifyActTime = DateTime.Now;

// when returning to purify state, check if there's burst ready with at least 1 big on screen
// enforce longer delay so stuff can spawn back in and be detected
if (cachedDataColoPurify != null &&
Expand All @@ -594,6 +600,7 @@ private bool OnScan_ColoPurify(ScannerColoPurify.ScreenData screenData)
if (screenData.BurstState == ScannerColoPurify.EBurstState.Active)
{
purifySlot = 0;
lastPurifyActTime = DateTime.Now;
return true;
}

Expand Down Expand Up @@ -622,12 +629,21 @@ private bool OnScan_ColoPurify(ScannerColoPurify.ScreenData screenData)

// if about to transition to next scene (or in flight) and burst is ready, wait a bit longer
// to make sure everything spawns in before decision to use burst
if (numTotal == 0 && (screenData.BurstState != ScannerColoPurify.EBurstState.None))
if (canWaitForPurifySpawn && numTotal == 0 && (screenData.BurstState != ScannerColoPurify.EBurstState.None))
{
scanSkipCounter = 15; // 1.5s
canWaitForPurifySpawn = false;
lastPurifyActTime = DateTime.Now;
return true;
}

// reset waiting flag every time it sees spawned slots
// that way it can do single longer delay for burst logic after clearing out screen
if (numTotal > 0)
{
canWaitForPurifySpawn = true;
}

// if burst is ready, check if there's anything worth using it on
if (screenData.BurstState == ScannerColoPurify.EBurstState.ReadyAndCenter && (numBig > 0))
{
Expand All @@ -649,6 +665,7 @@ private bool OnScan_ColoPurify(ScannerColoPurify.ScreenData screenData)
specialIdx = (int)(shouldUseBurst ? ScannerColoPurify.ESpecialBox.BurstReady : ScannerColoPurify.ESpecialBox.ReturnToBattle);
Rectangle actionBox = screenScanner.GetSpecialActionBox(specialIdx);
RequestMouseClick(actionBox, -1, specialIdx);
lastPurifyActTime = DateTime.Now;
return true;
}

Expand All @@ -661,6 +678,7 @@ private bool OnScan_ColoPurify(ScannerColoPurify.ScreenData screenData)
specialIdx = (int)(shouldUseBurst ? ScannerColoPurify.ESpecialBox.BurstReady : ScannerColoPurify.ESpecialBox.ReturnToBattle);
Rectangle actionBox = screenScanner.GetSpecialActionBox(specialIdx);
RequestMouseClick(actionBox, -1, specialIdx);
lastPurifyActTime = DateTime.Now;
return true;
}

Expand All @@ -673,14 +691,29 @@ private bool OnScan_ColoPurify(ScannerColoPurify.ScreenData screenData)
Rectangle[] actionBoxes = screenScanner.GetActionBoxes();
slotIdx = purifySlot;
RequestMouseClick(actionBoxes[slotIdx], slotIdx, -1);
lastPurifyActTime = DateTime.Now;
return true;
}

purifySlot = (purifySlot + 1) % 8;
}

// no valid slots detected? ignore for now
// maybe click every 0.5s on random one?
// no valid slots detected?
// wait a bit for everything to spawn in and start clicking all potential slots in sequence - maybe it failed to recognize?

TimeSpan timeSinceLastAct = DateTime.Now - lastPurifyActTime;
if (timeSinceLastAct.TotalSeconds > 5)
{
// don't mark timestamp, it's just a fallback action that should keep going
// slightly increase delay between scan actions though
scanSkipCounter = randGen.Next(3, 5);
purifySlot = (purifySlot + 1) % 8;

Rectangle[] actionBoxes = screenScanner.GetActionBoxes();
slotIdx = purifySlot;
RequestMouseClick(actionBoxes[slotIdx], slotIdx, -1);
}

return true;
}

Expand Down
4 changes: 2 additions & 2 deletions SINoCOLO/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("22.0.0.0")]
[assembly: AssemblyFileVersion("22.0.0.0")]
[assembly: AssemblyVersion("23.0.0.0")]
[assembly: AssemblyFileVersion("23.0.0.0")]

0 comments on commit 56f2963

Please sign in to comment.