fix: Add OCR cooldown guard to prevent skill spam false positives#2195
Closed
DCPMA wants to merge 4 commits intoFate-Grand-Automata:masterfrom
Closed
fix: Add OCR cooldown guard to prevent skill spam false positives#2195DCPMA wants to merge 4 commits intoFate-Grand-Automata:masterfrom
DCPMA wants to merge 4 commits intoFate-Grand-Automata:masterfrom
Conversation
Thin cooldown glyphs (1, 4) don't occlude enough pixels in the existing 30x30 icon-match region, causing isReadyForSpam to return true while a skill is still on cooldown. Add cooldownTextRegion() in BattleScreenLocations targeting the 96x48 area where the cooldown number is rendered. In SkillSpam, replace the direct imageRegion check with isReadyForSpam(), which requires both the icon similarity check (>=0.9) and an OCR confirmation that no cooldown digit is present. A 100ms stability re-check is also required before the cast is allowed. Common Tesseract misreads (O->0, I/l->1) are normalised before digit extraction. Changes are isolated to SkillSpam; command-script skill casting is unaffected. Fixes Fate-Grand-Automata#2073
Per the contribution guide, manual similarity values in Region.exists() should be avoided. Replace explicit similarity=0.9 with the in operator (Region.contains) so the user's Fine-Tune min similarity setting is respected, consistent with the rest of the codebase. Remove the now-unused skillReadySimilarity constant.
- Import Skill and use Skill.Servant instead of fully-qualified name, consistent with Caster.kt and the rest of the codebase - Extract duplicated readiness predicate into local checkReady() to avoid repeating the icon-match + cooldown-guard expression
The cooldownTextRegion was positioned at y-offset 108 from the skill locate() point, which lands on the NP bar area instead of the cooldown text. ADB screenshot analysis confirmed the "剩餘X" (remaining X turns) text renders at y-offset 40-90 from locate(). The old region never captured any digits, making the OCR guard ineffective. Changed from Region(8, 108, 96, 48) to Region(-5, 40, 100, 55) which correctly covers the cooldown text area across all 9 skill positions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
|
Closing — the underlying issue (skill spam false positives during cooldown) is still persisting despite this approach. Will revisit with a different strategy. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Skill spam occasionally fires skills that are still on cooldown. This happens because the readiness check uses a small 30×30 icon match (
imageRegion). When a cooldown number is displayed over the skill button, thin glyphs like 1 and 4 don't occlude enough pixels in that sample area, so the icon match still passes the similarity threshold and the skill is cast incorrectly.This has been reported as a recurring problem (see #2073, #874, #540). Note: #2076 addresses the related "stuck window" symptom (wrong close-click coordinate); this PR addresses the separate root cause of the incorrect cast itself.
Related issue
Related pull request
Fix
Add a secondary OCR guard that reads the cooldown number region of each skill button. If a numeric cooldown is detected, the cast is suppressed regardless of what the icon match says.
BattleScreenLocations— addscooldownTextRegion()targeting the area where the cooldown number text is rendered. The region is offset from the skilllocate()point.SkillSpam— replaces the directin imageRegioncheck withisReadyForSpam(), which:The OCR step normalises common Tesseract misreads (
O→0,I/l→1) before extracting the number with a\d+regex.Scope
SkillSpamandBattleScreenLocationsTesting
Verified on TW server via BlueStacks with a debug build.