Gates of Arimyth

AI that will gamble Jewels
Page 1 of 1

Author:  mud [ Tue May 22, 2018 2:31 pm ]
Post subject:  AI that will gamble Jewels

I wrote a simple AI script which will automatically gamble Jewels. It seem harmless enough and it might be educational for some. It's good to learn, especially in a world where automation is the future and perhaps you can apply knowledge like this in real life.

What the script does:
-By following it's instructions it automatically opens and closes the gamble screen
-scans for a certain pixel color that only Jewels have and purchases it
-Fills the inventory full of Jewels.
-can be modified to purchase charms

You will need autoit, a windows programing tool that uses a general script language.

Also run D2 in windows mode.

#include <MsgBoxConstants.au3>

HotKeySet("{ESC}", "Terminate")
HotKeySet("{g}", "Start")
HotKeySet("{1}", "Gheed")
HotKeySet("{2}", "Gamble")
WinActivate("Diablo II")
Local $ga, $gh
MsgBox($MB_SYSTEMMODAL, "Locate Coords", "Talk to a NPC that can gamble and do not move. Then issue coordinates by pressing 1 on NPC, and press 2 on the word 'Gamble.' Press 'G' to begin and press ESC to stop the script.")
While 1
Func Gheed()
   $gh = MouseGetPos()
   MsgBox($MB_SYSTEMMODAL, "Gheed's Location", $gh[0] & ", " & $gh[1])

Func Gamble()
   $ga = MouseGetPos()
   MsgBox($MB_SYSTEMMODAL, "Gamble Location:", $ga[0] & ", " & $ga[1])

Func Start()
   Local $hWnd = WinWait("Diablo II", "", 10)
   Local $aClientSize = WinGetClientSize($hWnd)
For $b = 1 to 100
   mouseClick("right", $ga[0], $ga[1], 1)
   $pt = PixelSearch( (@DeskTopWidth-$aClientSize[0])/2, (@DeskTopHeight-$aClientSize[1])/2, @DeskTopWidth/2, @DeskTopHeight-($aClientSize[1]/2), 0xc043fe, 0)
While @error = 0
   mousemove($pt[0], $pt[1], 0)
   $pt = PixelSearch( (@DeskTopWidth-$aClientSize[0])/2, (@DeskTopHeight-$aClientSize[1])/2, @DeskTopWidth/2, @DeskTopHeight-($aClientSize[1]/2), 0xc043fe, 0)
   Send("{Space 1}")
   mousemove($gh[0], $gh[1], 1)

Func Terminate()

Save this code as a .au3 file and double click it while your char is in a game.

Author:  Ensley03 [ Tue May 22, 2018 2:54 pm ]
Post subject:  Re: AI that will gamble Jewels

As soon as I saw this, I knew it would be pixel detection. Nice meme. Are you sure none of the areas and such will make it freak out when reloading the gambling screen? And what about people with different video/monitor settings? Sometimes pixel detection isn't universal. I had an ahk bot for WoW that ran Alterac Valley by using pixel detection to find specific markers and look like a real player. I sent it to a friend and he was not able to use it, even with the same resolution and everything.

Author:  mud [ Tue May 22, 2018 3:20 pm ]
Post subject:  Re: AI that will gamble Jewels

Can't be entirely sure about everything.
I ran it on multiple resolutions so far seems to work fine. AI for WoW is alot more complex than a simple AI script like this.

It scans for pixel color while the gambling screen is opened. It goes click gamble, wait, scan, wait, close, wait, click NPC, wait... cycle. Gambling jewels have a significantly distinct pink color, so it doesn't conflict with anything else on the gambling screen.

Author:  kramuti [ Wed May 23, 2018 1:29 pm ]
Post subject:  Re: AI that will gamble Jewels

Someone else did this a number of years ago (i forgot who). It worked well most of the time from what I read, but would booboo from time to time. This one looks a lil cleaner.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group