Last active
October 14, 2017 03:18
-
-
Save blakelee/630ccdacff547818c7717ecd3378021d to your computer and use it in GitHub Desktop.
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
| program QuickPlay; | |
| type | |
| states = (MAIN, PREFIGHT, POSTFIGHT, NONE); | |
| var | |
| cur: states; | |
| client: TSCARClient; | |
| w, h: Integer; | |
| prev_x, prev_y: Integer; | |
| qx, qy: Integer; //Quick Fight Coordinates | |
| cx, cy: Integer; //Center Screen Coordinates | |
| ox, oy: Integer; //Red OK Coordinates | |
| bx, by: Integer; //Back Button Coordinates | |
| osx, osy, oex, oey: Integer; | |
| qsx, qsy, qex, qey: Integer; | |
| bsx, bsy, bex, bey: Integer; | |
| x1, x2, x3, x4, y1, y2, y3, y4: Integer; | |
| qfcx, qfcy: Integer; | |
| cancelx, cancely: Integer; | |
| active_window: Hwnd; | |
| function FindOKButton(): Boolean; | |
| begin | |
| if FindColorTol(ox, oy, 2434002, osx, osy, oex, oey, 10) then | |
| begin | |
| WriteLn('Found OK or Claim Button'); | |
| MoveMouse(ox, oy); | |
| ClickMouse(ox, oy, False); | |
| Result := true; | |
| end else | |
| Result := false; | |
| end; | |
| function WhiteScreen(): Boolean; | |
| var r1, r2, r3, r4: Boolean; | |
| var outx, outy: Integer; | |
| begin | |
| r1 := FindColorTol(outx, outy, 16777215, x1, y1, x1, y1, 10); | |
| r2 := FindColorTol(outx, outy, 16777215, x2, y2, x2 + 1, y2 + 1, 10); | |
| r3 := FindColorTol(outx, outy, 16777215, x3, y3, x3 + 1, y3 + 1, 10); | |
| r4 := FindColorTol(outx, outy, 16777215, x4, y4, x4 + 1, y4 + 1, 10); | |
| if r1 and r2 and r3 and r4 then | |
| begin | |
| ClickMouse(cancelx, cancely, False); | |
| Result := true; | |
| end else | |
| Result := false; | |
| end; | |
| function FindQuickFightButton(): Boolean; | |
| begin | |
| if FindColorTol(qx, qy, 13556713, qsx, qsy, qex, qey, 10) then | |
| begin | |
| WriteLn('Found Quick Fight Button'); | |
| MoveMouse(qx, qy); | |
| ClickMouse(qx, qy, False); | |
| Wait(1000); | |
| Result := true; | |
| end else | |
| Result := false; | |
| end; | |
| function FindBackButton(): Boolean; | |
| begin | |
| if FindColorTol(bx, by, 2434002, bsx, bsy, bex, bey, 10) then | |
| begin | |
| WriteLn('Found Back Button, expected else'); | |
| MoveMouse(bx, by); | |
| ClickMouse(bx, by, False); | |
| Result := true; | |
| end else | |
| Result := false; | |
| end; | |
| function FindWatchScreen(): Boolean; | |
| var x, y: Integer; | |
| begin | |
| if FindColorTol(x, y, 16777215, qfcx, qfcy, qfcx + 1, qfcy + 1, 10) then | |
| begin | |
| WriteLn('Found Watch screen'); | |
| Wait(100); | |
| Result := True; | |
| end else | |
| Result := False; | |
| end; | |
| procedure SaveCoordinates(); | |
| begin | |
| active_window := GetDesktopWindow; | |
| GetMousePos(prev_x, prev_y); | |
| end; | |
| procedure RestoreCoordinates(); | |
| begin | |
| ClickMouse(prev_x, prev_y, False); | |
| SetWindowTopMost(active_window, True); | |
| end; | |
| procedure MainScreen(); | |
| var found: Boolean; | |
| begin | |
| found := false; | |
| while found <> true do | |
| if FindOKButton() then | |
| begin | |
| end else | |
| if WhiteScreen() then | |
| begin | |
| end else | |
| if FindQuickFightButton() then | |
| begin | |
| found := true; | |
| cur := PREFIGHT; | |
| end; | |
| end; | |
| procedure PreFightScreen(); | |
| begin | |
| if FindWatchScreen() then | |
| begin | |
| MoveMouse(cx, cy); | |
| ClickMouse(cx, cy, False); | |
| WriteLn('Clicked center of screen'); | |
| cur := POSTFIGHT | |
| end else | |
| begin | |
| FindBackButton(); | |
| cur := MAIN; | |
| end; | |
| end; | |
| procedure PostFightScreen(); | |
| var found: Boolean; | |
| begin | |
| found := false; | |
| while found <> true do | |
| if FindOKButton() then | |
| begin | |
| found := true; | |
| cur := MAIN; | |
| end; | |
| end; | |
| procedure StateHandler(); | |
| begin | |
| while 1 = 1 do | |
| case cur of | |
| MAIN: MainScreen(); | |
| PREFIGHT: PreFightScreen(); | |
| POSTFIGHT: PostFightScreen(); | |
| end; | |
| end; | |
| begin | |
| cur := MAIN; | |
| client := GetClient; | |
| client.Update; | |
| GetBoxSize(client.ImageArea, w, h); | |
| //Quick Fights Button coordinates | |
| qsx := Round(0.56 * w); | |
| qsy := Round(0.8 * h); | |
| qex := Round(0.72 * w); | |
| qey := Round(0.86 * h); | |
| //Center of screen coordinates | |
| cx := Round(w / 2); | |
| cy := Round(h / 2); | |
| //OK button coordinates | |
| osx := Round(0.46 * w); //0.46 - 0.54 | |
| osy := Round(0.815 * h); //0.815 - 0.89 | |
| oex := Round(0.54 * w); | |
| oey := Round(0.89 * h); | |
| //Back button coordinates | |
| bsx := Round(0.039 * w); | |
| bsy := Round(0.88 * h); | |
| bex := Round(0.1 * w); | |
| bey := Round(0.95 * h); | |
| //Quick Fight start line coordinates | |
| qfcx := Round(w / 6); | |
| qfcy := Round(0.18 * h); | |
| //White Screen... Means I fucked up | |
| x1 := Round(0.05 * w); | |
| y1 := Round(0.2 * h); | |
| x2 := Round(0.85 * w); | |
| y2 := Round(0.2 * h); | |
| x3 := Round(0.05 * w); | |
| y3 := Round(0.9 * h); | |
| x4 := Round(0.85 * w); | |
| y4 := Round(0.9 * h); | |
| cancelx := Round(0.7 * w); | |
| cancely := Round(0.88 * h); | |
| StateHandler(); | |
| end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment