DEV Community

Cover image for GTA RP Nopixel Thermite Fast Click Bot
Possessed Player
Possessed Player

Posted on

GTA RP Nopixel Thermite Fast Click Bot

If you've played GTA RP Nopixel, you know it has very challenging minigames, one of which is called "Thermite".

Image description

In this minigame you've to memorize the pattern in 5 seconds only, after which you're asked to repeat it very quickly, and as you might imagine this is pretty challenging.

But no worries, this is where my script comes to the rescue, all you've to do is press a hotkey to the record the pattern, then press another one to make the script repeat what it just recorded.

Clone the Github repo here.

Check out the bot video here.

Code Explained

Line (12) record function

def record():
    img_bgr = pag.screenshot()
    img_bgr = np.array(img_bgr)
    img_rgb = img_bgr[:,:,::-1].copy()
    img_gray = cv.cvtColor(img_rgb, cv.COLOR_BGR2GRAY)
    template = cv.imread('obj/' + WIMG + '.jpg',0)
    w, h = template.shape[::-1]

    res = cv.matchTemplate(img_gray, template,cv.TM_SQDIFF_NORMED)
    mn,mx,mnLoc,mxLoc = cv.minMaxLoc(res)
Enter fullscreen mode Exit fullscreen mode

This function is called when the user presses

Which initiates the pattern recording process.

It works by taking a screenshot of the whole screen using pyautogui.screenshot function, then looks for parts of the screen that looks exactly like a white square, by comparing a template image of the white square to the screenshot using opencv "cv.matchTemplate" function.

Line (23) record function cont.

    threshold = 0.05
    loc = np.where(res <= threshold)
    points = []
    for pt in zip(*loc[::-1]):
        close = False
        for p in points:
            if abs(pt[0] - p[0]) < 10 and abs(pt[1] - p[1]) < 10:
                close = True

        if close: 
        cv.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (0,0,255), 2)

    global Whites
    Whites = points
Enter fullscreen mode Exit fullscreen mode

In this part of the record function it looks for matches, and saves them in the global list "Whites", after processing them into a screen position tuples.

Line (43) go function

def go():
    global Whites
    for pt in Whites:[0] + 30, pt[1] + 30)
Enter fullscreen mode Exit fullscreen mode

This function is executed when the user presses

It works by clicking on recorded screen locations, which are saved by the 'record' function.

It goes over the global list "Whites", and clicks on each screen location, using function.

def kb_listener():
    def on_release(key):
        if str(key) == "<79>":
        elif str(key) == "<80>":

    with Listener(on_release=on_release) as listener:
Enter fullscreen mode Exit fullscreen mode

This is our usual keyboard listener function, which executes 'record' and 'go' functions when the user presses the right combinations(Check pynput documentation for more info about this function).

Line (62) script main code

if __name__ == '__main__':
    WIMG = input("Type 7 for 7x7, 8 for 8x8 then press Enter\n")
    if not (WIMG in ("7", "8")):
        print("Type either 7 or 8 to run this bot, Exiting...")


    while True:
Enter fullscreen mode Exit fullscreen mode

This part is responsible of running the whole script and loads the global variable 'WIMG', which a selector for the minigame square size, 7x7 and 8x8 are supported.

Thanks for reading.

Top comments (1)

arrtuu profile image

i seems to cant get this to work, if you could help me i would apprieate it