Hack Forums
[Python] How to recognize NPCs in a game? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] How to recognize NPCs in a game? (/showthread.php?tid=6103522)



How to recognize NPCs in a game? - Crypt - Aug 17, 2020

So I'm trying to write a script for a game and the most important part is the script needs to be able to recognize the NPC is there and then click on it.  So I am using pyautogui and I give the script an image, the issue is it can only recognize the NPC if it's in the same exact angle it was in when the picture was taken.  Here is a code example of how I'm doing it and I hope someone has a better method because mine isn't working.


Code
while 1:
    if pyautogui.locateOnScreen('character.png', confidence=0.8) is not None:
        print("I can see it")
        time.sleep(0.5)
    else:
        print("I cannot see the character")



RE: How to recognize NPCs in a game? - Charger - Aug 18, 2020

If it’s 3D then that library isn’t going to do anything to help you. Look into openCV and tesseract


RE: How to recognize NPCs in a game? - Crypt - Aug 18, 2020

(Aug 18, 2020 05:23 PM)Charger Wrote:  If it’s 3D then that library isn’t going to do anything to help you. Look into openCV and tesseract

Ahh, so tesseract should treat the image as a 3d image, while pyautogui is treating it as 2d.

I'll have to do some research.