markhuge MH\n s

Infinite Overwatch bots with Go

published:

signed with 0x683A22F9469CA4EB

tags:

There was a bug in Overwatch that made the game fun. Blizzard just uninstalled the fun, so now I can probably post this without getting banned.

The bug was a race condition in the custom games UI, that would allow for moving AI players into teams that were already full. Exploiting the bug was pretty simple, you just had to click quickly enough to cause the collision.

Example:

I’m lazy and I cheat at cookie clicker, so I decided to write a thing to automate the exploit. I used Go because I needed a Windows binary, and didn’t want to hand craft XML and setup like 3GB of NuGet bullshit to click the screen.

The first cross platform lib I found for mouse input was https://github.com/go-vgo/robotgo.

For some reason the lib is limited to a single keypress event listener, and that listener can only reliably be triggered one time. My ego won’t let me acknowledge that Go is a poor choice for this problem, and I should have just written this in C#. I devise a shit workaround: start with a keypress, end with a mouse gesture.

Press 1 to start. If the mouse y position is > starting point + 500, exit.

This code is hot garbage, but it did the job:

package main

import (
	"fmt"
	"math/rand"
	"time"

	"github.com/go-vgo/robotgo"
)

var start, x, y int

// Add a random delay to behave more like human input
func delay() int {
	rand.Seed(time.Now().Unix())
	return rand.Intn(37-20) + 20
}

func main() {
	fmt.Println("Press 1 to start clicking. Move mouse to bottom of screen to stop clicking.")
	start = robotgo.AddEvent("1")
	x, y = robotgo.GetMousePos()
	if start == 1 {
		click()
	}
}

func click() {
	for {
		fmt.Println("Clicking...")
		robotgo.MouseClick()
		time.Sleep(time.Duration(delay()) * time.Millisecond)
		_, newy := robotgo.GetMousePos()
		if y+500 < newy {
			fmt.Println("Got exit event")
			return
		}
	}
}

For less than 8 mins of work, I’m pretty okay with this solution.

If I were solving this problem in days instead of minutes, I probably would have pulled a trinket from the pile and emulated a HID mouse to get around any potential cheat detection totally legitimate software conflicts.

About the Author

Mark Wilkerson

0x683A22F9469CA4EB

R&D engineer @ Twitch. Previously Blizzard, Hightail, Co-Founder @ SpeakUp

Mark is building open source tools to make web3 and decentralized self-ownership easy for regular people.

Live dev streams at Twitch.tv

More Posts