Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoEnv
- SetWorkingDir %A_ScriptDir%
- ;Sets the working directory to be where the script is located.
- CoordMode, Mouse, Window
- ;Lets the finding of X and Y to be determined by the mouse's coordinates on the functions below.
- SendMode Input
- #SingleInstance Force
- SetTitleMatchMode 2
- #WinActivateForce
- SetControlDelay 1
- SetWinDelay 0
- SetKeyDelay -1
- SetMouseDelay -1
- SetBatchLines -1
- #Persistent
- #Include %A_ScriptDir%\FindTextLib.ahk
- ;;;#ME: They're 1920x1080, I'm 1366x768
- ;;;#ME: 1920 is 1.4x 1366, or 0.711
- ;;;#ME: 1080 is 1.4x 768, or 0.711
- global WidthRatio := A_ScreenWidth / 1920
- global HeightRatio := A_ScreenHeight / 1080
- ;;; This was generated by the FindText AHK script/library: https://autohotkey.com/boards/viewtopic.php?t=17834
- global JumpText:="|<Jump text>*106$45.zzzzzzzzzzzzzzzzkDzzzzzs0zzzzzzDbzzzzztyTzzzzyMk0000Tn600000yMzzyxzbm4zzzzywk2A030Ta0l0003wV48EU4Dg0X6A1XlWAMlU8SwM7CQ06j74tnY7pkzzzzXswDzzSwy7zz003a0zzw00Dk7zzk01y0zzzzzsTw"
- global EnterText:="|<Enter text>*159$33.zzzzzw3zzzzUTzzzxzzzzzjzxzzxy3339UGNn8gytiNDjrBk9xytiTDjrBndw2tX1Dzzzzzw"
- global PartyScreenNextText:="|<Party screen next text>*152$33.rxzzzyTbzzzlwzzzy7bzzbowsnYCnY2N7rAaMQywY3bbrkbwQyy4v9brskHgDzzzzzzzzzzw"
- global RemoveRWText:="|<Remove RW text>*134$47.zzzzzzzzzzzzzzzz1zzzzzzynzzzzzzxrzzzzzzvC60A4u3ktYrHZZrck/ib9MDRbrRCMrytiivQnbxt1Rq3rVzzzzzzzzzzzzzzzz"
- global GoText:="|<Go! text>*154$28.zzzzzwzvzy0w1tlvXXbDyTaNznyNbzDtaS4zatyHyPntbtz7aCDy0Q1tzzzzzzzzzs"
- global RoundsText:="|<Rounds text>*112$36.700030Tk007UTs00DUENByAwHDzzwyHAmEkXE8GEU3EFGG47P1GGAXv8EGVHvgsKlbzzzzzzzzzzzzU"
- global BeginBattleText:="|<Begin Battle text>*150$68.zzzzzzzzzzzsDzzzzw7zzwy1zzvzz0zzzDaTzyzzrDzxntbzzzzxnziQyFks/1z8kk1AUNYanDkNAtmNW1RhnxnvCQWQbkPQzSEnb9b9yCrDrZgtmN39DhnwWP/Im1kkPQz1kMlCzzxnzzzzzzzzzyQzzzzzzzzzzkTzzzzzzzzzyDzzzzzzzzzzzzzzzzzzy"
- global OutsideBattleSteps := [{"Description": "This check is for the Green Shinra's finest event box."
- ,"FindText args": [751, 259, 150000, 150000, 0, 0, JumpText]
- ,"Wait ratio": 0.4}
- ,{"Description": "Clicks the Enter Dungeon button."
- ,"FindText args": [744, 592, 150000, 150000, 0, 0, EnterText]
- ,"Wait ratio": 0.8}
- ,{"Description": "Clicks the Next button."
- ,"FindText args": [682, 648, 150000, 150000, 0, 0, PartyScreenNextText]
- ,"Wait ratio": 0.8}
- ,{"Description": "#ME: Unselect the RW"
- ,"FindText args": [843, 355, 150000, 150000, 0, 0, RemoveRWText]
- ,"Wait ratio": 0.1}
- ,{"Description": "Clicks the GO! button."
- ,"FindText args": [683, 648, 150000, 150000, 0, 0, GoText]
- ,"Wait ratio": 0.4}
- ,{"Description": "#ME: Clicks the 'Rounds' text on boss platform"
- ,"FindText args": [704, 353, 150000, 150000, 0, 0, RoundsText]
- ,"Wait ratio": 0.4}
- ,{"Description": "Clicks the begin battle button."
- ,"FindText args": [771, 494, 150000, 150000, 0, 0, BeginBattleText]
- ,"Wait ratio": 0.8
- ,"Done?": true}]
- global AttackText:="|<Attack text>*129$40.yTzzzvztzzzzjzXzzzyzwD4QyPjqMEVUgyNrDqS7s7QwPszDBnhjVwyrgqSnrt68A/bzzzzzzs"
- global GuardScorpionLeg:="|<Guard Scorpion front left leg>*44$71.zzzzs00Tzzzzzzzzk00zzzzzzzzzk01zzzzzzzzzk03zzzzzzzzzU07zzzzzzzzz00zzzzzzzzzy01zzzzzzzzzw03zzzzzzzzzs07zzzzzzzzzw0zzzzzzzzzzs1zzzzzzzzzzkDzzzzzzzzzzUTzzzzzzzzzzkzzzzzzzzzzzVzzzzzzzzzzzTzzzzzzzzzzyzzzzzzzzzzzxzzzzzzzzzzzvzzzzzzzzzzzzzzzzzzzzzzyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
- global ResultsText:="|<ResultsText>*138$56.zzzzzzzzzw3zzzzyTzz0TzzzzbzznbzzzztzzwtzzzzyRzzCTXstva33m7kA6St0UQ3tnDbiNtz8yQntvaSDnb0CCStbkwstzlbiNz7DCTyNvaTtntU8a8tUYQyA31kCQ8DzzzzzzzzzU"
- F1::
- ;Press F1 to start your macro.
- Macro1:
- CoordMode, Pixel, Window
- WinActivate, NoxPlayer ahk_class Qt5QWindowIcon
- Sleep, 350
- Loop
- {
- mainloopstart:
- FoundX := 0
- FoundY := 0
- if (NOT GetIntoBattle()) {
- return
- }
- WorthyBoss := 0
- Loop
- {
- battleloop:
- ;Checks if the fight has ended and you are in the champion screen.
- ;If it is, it will click and check whether it should return to the beginning of the loop.
- if (FindText(575, 92, 150000, 150000, 0, 0, ResultsText)) {
- Goto, resultsloop
- } else {
- PixelSearchRelative(FoundX, FoundY, 991, 903, 991, 903, "0xA8A8A8", 10, "Fast")
- ;Checks if your turn available by ensuring the 2nd ability slot includes the color white that is on the outer ring of the ability.
- if (ErrorLevel = 0) { ;If the turn is available..
- Sleep, 250 ;;;#ME: Wait for text to bounce in
- if (FindText(507, 672, 150000, 150000, 0, 0, AttackText)) { ;If the text "Attack" is visible, burst mode is inactive
- ClickRelative(1131, 816, 1)
- ;Click the BSB button
- Sleep, 300
- ;Left click on bsb. Repeat the loop.
- } else { ;If it doesn't say "Attack", meaning the burst is active..
- ;PixelSearchRelative(FoundX, FoundY, 847, 480, 847, 480, "0x0F0A0A", 10, "Fast")
- ;Check tank
- ;If ErrorLevel = 0
- ;{
- ; WorthyBoss += 1
- ;}
- ;~ PixelSearchRelative(FoundX, FoundY, 770, 467, 770, 467, "0x2534BE", 10, "Fast")
- ;~ ;Check Guard Scorpion
- ;~ If ErrorLevel = 0
- if (FindText(611, 352, 150000, 150000, 0, 0, GuardScorpionLeg)) {
- WorthyBoss += 1
- }
- ;First we check if it is a worthy boss. There is a static spot on this boss.
- ;You can add one more counter if you want to do it for the other bosses as well, just have to find a good pixel.
- if (WorthyBoss > 0) {
- ;If we confirmed it is this boss..
- ClickRelative(726, 840, 1)
- Sleep, 300
- WorthyBoss := 0
- ;Left click on cmd1. Repeat the loop.
- } else {
- ClickRelative(827, 830, 1)
- Sleep, 300
- ;Left click on cmd2. Repeat the loop.
- }
- }
- }
- }
- }
- resultsloop:
- Loop
- {
- Sleep, 100
- PixelSearchRelative(FoundX, FoundY, 860, 390, 860, 390, "0x0D2910", 10, "Fast")
- if (ErrorLevel = 0) { ;Checks if the Shinra screen is there.
- Goto, mainloopstart
- } else if (ErrorLevel = 1) {
- Sleep, 1500
- ClickRelative(885, 840, 2)
- Sleep, 1500
- ClickRelative(885, 840, 2)
- ;Clicks the next button
- }
- }
- }
- Return
- F2::ExitApp
- F3::Pause
- MyDebug(MyText)
- {
- ToolTip, %MyText%
- SetTimer, RemoveToolTip, 5000
- }
- PixelSearchRelative(byRef Out1, byRef Out2, X1, Y1, X2, Y2, color, tol, opt)
- {
- PixelSearch, FoundX, FoundY, X1*WidthRatio-10, Y1*HeightRatio-10, X2*WidthRatio+10, Y2*HeightRatio+10, %color%, tol, %opt%
- ;MyDebug("Error level was: " ErrorLevel)
- }
- ClickRelative(RelativeX, RelativeY, Count)
- {
- XClickLocation := RelativeX * WidthRatio
- YClickLocation := RelativeY * HeightRatio
- ;;;#ME: MyDebug("Going to click at " XClickLocation ", " YClickLocation)
- Click, %XClickLocation%, %YClickLocation%, Left, %Count%
- }
- FindTextDebug(X, Y, Width, Height, Err1, Err0, TextToFind)
- {
- ok := FindText(X, Y, Width, Height, Err1, Err0, TextToFind)
- if (ok) {
- return ok
- } else {
- MyDebug("Couldn't find the text :(")
- }
- }
- ClickFindTextResult(FindTextResult)
- {
- if (FindTextResult) {
- CoordMode, Mouse
- X := FindTextResult.1.1, Y:=FindTextResult.1.2, W:=FindTextResult.1.3, H:=FindTextResult.1.4, X+=W//2, Y+=H//2
- Sleep, 250
- Click, %X%, %Y%, Left, 2
- }
- return FindTextResult
- }
- GetIntoBattle()
- {
- while (true) {
- for StepNum, Step in OutsideBattleSteps {
- if (ok := FindText(Step["FindText args"]*)) {
- ClickFindTextResult(ok)
- WaitTime := 5000 * Step["Wait ratio"]
- Sleep, %WaitTime%
- if (Step["Done?"]) {
- return true
- } else {
- break
- }
- }
- }
- }
- }
- RemoveToolTip:
- SetTimer, RemoveToolTip, Off
- ToolTip
- return
- ;Edit log: 1. /u/spirialis, 2. /u/richiealvian, 3. /u/MattDarling
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement