Login | Register


All times are UTC - 5 hours


It is currently Sat Oct 20, 2018 10:45 am




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: AI that will gamble Jewels
PostPosted: Tue May 22, 2018 2:31 pm 

Joined: Tue Sep 01, 2009 11:50 am
Posts: 130
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.

https://www.autoitscript.com/site/autoit/


Code:
#RequireAdmin
#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
    Sleep(1000)
 WEnd
Func Gheed()
   $gh = MouseGetPos()
   MsgBox($MB_SYSTEMMODAL, "Gheed's Location", $gh[0] & ", " & $gh[1])
EndFunc

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

Func Start()
   Local $hWnd = WinWait("Diablo II", "", 10)
   Local $aClientSize = WinGetClientSize($hWnd)
For $b = 1 to 100
   mouseClick("right", $ga[0], $ga[1], 1)
   sleep(500)
   $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)
   mousedown("right")
   mouseup("right")
   sleep(510)
   $pt = PixelSearch( (@DeskTopWidth-$aClientSize[0])/2, (@DeskTopHeight-$aClientSize[1])/2, @DeskTopWidth/2, @DeskTopHeight-($aClientSize[1]/2), 0xc043fe, 0)
WEnd
   sleep(75)
   Send("{Space 1}")
   sleep(125)
   mousemove($gh[0], $gh[1], 1)
   sleep(125)
   mousedown("left")
   mouseup("left")
   sleep(200)
next
EndFunc

Func Terminate()
    Exit
EndFunc


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


Last edited by mud on Tue May 22, 2018 3:00 pm, edited 1 time in total.

Top
 Offline Profile  
Reply with quote  
 Post subject: Re: AI that will gamble Jewels
PostPosted: Tue May 22, 2018 2:54 pm 

Joined: Wed Dec 12, 2012 7:24 pm
Posts: 992
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.


Top
 Offline Profile  
Reply with quote  
 Post subject: Re: AI that will gamble Jewels
PostPosted: Tue May 22, 2018 3:20 pm 

Joined: Tue Sep 01, 2009 11:50 am
Posts: 130
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.


Top
 Offline Profile  
Reply with quote  
 Post subject: Re: AI that will gamble Jewels
PostPosted: Wed May 23, 2018 1:29 pm 
User avatar

Joined: Tue Sep 01, 2009 9:01 pm
Posts: 1378
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.

_________________
The reader should not be discouraged if...he does not have the prerequisites to read the prerequisites. P. Halmos


Top
 Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Google [Bot] and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron