Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; Harry Potter: Hogwarts Mystery - AutoClicker
- ; Suitable for usage with Nox
- ;
- ; This script is a work in progress.
- ; Changes are likely to happen in order to ensure fast and reliable execution.
- ;
- ; Recommended values for Nox:
- ; SleepDur := 40
- ; ClickPerPosition := 3
- ; RowCount := 5
- ; ColumnCount := 10
- ;
- ; Recommended values for other emulators (BlueStacks, MEmu, etc.):
- ; SleepDur := 1
- ; ClickPerPosition := 2
- ; RowCount := 5
- ; ColumnCount := 10
- ;
- ; In both cases you can increase the execution speed tremendously by using
- ; RowCount := 3
- ; ColumnCount := 6
- ; However, this will lead to instances, where the script gets "stuck" on small objects.
- ;
- ;
- ; List of default keybindings:
- ; Alt + q: terminate script
- ; F9: toggle blue/red outline search
- ; F11: en-/disable basic AutoClicker
- ; F12: en-/disable class/quest AutoClicker
- ;
- ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- #NoEnv
- #Warn
- #maxThreadsPerHotkey, 8
- SendMode Input
- ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; Settings
- ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Activate := false ; don't touch this
- SearchRed := false ; default outline search (false -> blue, true -> red)
- SleepDur := 40 ; sleep duration (in ms) between clicks
- ClickPerPosition := 3 ; how often to click on one point
- RowCount := 3 ; how many search rows to split the screen into
- ColumnCount := 6 ; how many search columns to split the screen into
- ; button coordinates (rel) for prompts and minigames (assumed 16:9 aspect ratio)
- ; [0.5, 0.5] -> 2nd reward
- ; [0.6, 0.8] -> 2nd answer
- ; [0.6, 0.5] -> General prompt for continuing (e.g. "Focus" or "Answer Question")
- PromptCoords := [[0.5, 0.5], [0.6, 0.8], [0.6, 0.5]]
- ; limits (rel) for upper corners (assumed 16:9 aspect ratio)
- ; will be excluded from outline search
- RestrictedWidth := [0.2, 0.8]
- RestrictedHeight := 0.33
- ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; Outline-search Optimization Guide:
- ;
- ; short sleep duration: faster clicking -> faster execution (i.e. progress)
- ; long sleep duration: less demanding for your emulator -> avoids crashes
- ; few clicks per position: less time wasted on non-registering outlines
- ; many clicks per position: more likely to finish activties in one go
- ; better progress/click ratio
- ; low row/column values: faster search -> faster execution (i.e. progress)
- ; high row/column values: less likely to get stuck on non-registering outlines
- ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; Terminate the script
- ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- !q::
- {
- msgbox, ended
- exitapp
- }
- return
- ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; Toggle blue/red outline search
- ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- $f9::
- {
- SearchRed := !SearchRed
- }
- return
- ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; En-/disable basic auto-clicking
- ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- $f11::
- {
- Activate := !Activate
- while (Activate) {
- Click
- Sleep, SleepDur
- }
- }
- return
- ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; En-/disable class/quest auto-clicking
- ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- $f12::
- {
- WinGetPos, WinX, WinY, WinWidth, WinHeight, A
- Activate := !Activate
- while (Activate) {
- ; split search area in rows and columns
- ; cursor can get stuck on thin clickable objects / horizontal edges (clicks don't trigger activity)
- ; if cursor gets stuck in one area, it might find something to click in the next
- Loop, %RowCount% {
- StartHeight := WinHeight*(A_Index-1)/RowCount
- EndHeight := WinHeight*A_Index/RowCount
- Loop, %ColumnCount% {
- StartWidth := WinWidth*(A_Index-1)/ColumnCount
- EndWidth := WinWidth*A_Index/ColumnCount
- ; exclude upper left and upper right corner from search
- ; otherwise can lead to problems during potion classes
- if (StartHeight < RestrictedHeight*WinHeight) {
- if (EndWidth < RestrictedWidth[1]*WinWidth or StartWidth > RestrictedWidth[2]*WinWidth) {
- Continue
- } else if (StartWidth < RestrictedWidth[1]*WinWidth) {
- StartWidth := RestrictedWidth[1]*WinWidth
- } else if (EndWidth > RestrictedWidth[2]*WinWidth) {
- EndWidth := RestrictedWidth[2]*WinWidth
- }
- }
- ; search for blue/red outline of clickable objects
- ; blue: classes + most quests, red: occasional quest
- ; F9 to toggle
- if (SearchRed)
- PixelSearch, ObjectX, ObjectY, StartWidth, StartHeight, EndWidth, EndHeight, 0xF2542B, 0, Fast RGB
- else
- PixelSearch, ObjectX, ObjectY, StartWidth, StartHeight, EndWidth, EndHeight, 0x46BFFF, 0, Fast RGB
- ; don't click if no outline was found
- if ErrorLevel
- Continue
- Loop, %ClickPerPosition% {
- Click, %ObjectX%, %ObjectY%
- Sleep, SleepDur
- }
- }
- }
- ; click potential buttons to proceed
- For index, Coord in PromptCoords {
- MouseMove, Coord[1]*WinWidth, Coord[2]*WinHeight, 0
- Click
- }
- }
- }
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement