Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

D3 AHK potion/gold farm bot


  • Please log in to reply
66 replies to this topic
  • Guests
  • Last active:
  • Joined: --
GamerGirl is probably ganna show up and kick my ass yet again shortly after posting this, but here's my work-in-progress.

This farms for mythic potions and chests in a specific place and picks up non-white items and vendors blues.

What you do is this:

Load act 1, Quest 2 (preferably on inferno)
Get to the cellar and beat the boss
Talk to the wench
Exit the game
Run the script
Watch the potions and gold stack up

I highly recommend at least 20m of gold pickup or you're going to miss gold
I highly recommend magic find (of course)

-hits cauldron for potion, grabs potion
-tries for first chest position, picks up non-whites
-tries for second chest position, picks up non-whites
-portals back to down
-every 10th run it vendors blues

It works extremely well *for me*


Notes:
Vendors most blues. Haven't fully fixed that part yet. I personally don't want it to get rid of tome of secrets so I'm willing to live with single slot blues stacking up in my inventory. If you don't care, change the pixelsearch tolerance to 2 instead of zero, uncomment the 'escape' send and delete the second check - it will then vendor all blues.

Set up for 1680x1050 FULL SCREEN WINDOWED MODE - only -

Not clean, work-in-progress, would love to see replies with improvements. If any runescape gurus could lend a hand in the bot-detection department that would be awesome.

WinActivate, Diablo III

Loop, 400
{

MouseMove, 225, 406, 10 ;resume game
Click
sleep 8000

MouseMove, 1568, 530, 10 ;first move
Click
Sleep 3000

MouseMove, 1500, 137, 10 ; cauldron
Click
Sleep, 3000

MouseMove, 879, 446, 10 ;potion?
Click
Sleep, 2000

MouseMove, 1314, 219, 10 ;chest 1
Click
Sleep, 5000

;get yellows
ItemFound = 0
Loop, 5
{
	YellowScanClick(650, 300, 1100, 650)
}
If ItemFound = 0 ;if it found nothing check the other chest location
{
	MouseMove, 370, 125, 10 ;click chest 2
	Click
	Sleep, 5000
	Loop, 5
	{
		YellowScanClick(555, 368, 1050, 675)
	}

	;move off to grab gold
	MouseMove, 780, 745, 10
	Click
	Sleep, 1000

}


;MouseMove, 370, 125, 10 ;move to chest 2 (and grab any gold from chest 1)
;Click
;Sleep, 5000
;MouseMove, 790, 650, 10 ;small move to grab chest 2 gold
;Click

Sleep, 1000

;portal out and exit game
Send, {t}

Sleep, 9000

;sell off blues
;scan for blue items in inventory
;inventory is 1180 570 by 1650 850

;after town portal move to vendor every so many loops
If !(Mod(A_INDEX,1))
{
	MouseMove, 1296, 89, 10
	Click
	Sleep, 3000
	MouseMove, 1082, 135, 10
	Click
	Sleep, 3000

	;scan for blue item color and sell
	NoItems = 0
	While NoItems = 0
	{
		PixelSearch, xloc, yloc, 1180, 570, 1650, 850, 0x311E16, 0, fast
		If !ErrorLevel
		{
				MouseMove, %xloc%, %yloc%, 10
				Click Right
				Sleep, 1000
		}
		Else
		{
			NoItems = 1
			;Send, {esc} ;close inventory and exit vendor
		}
	}

	;scan for single slot blue item colors and sell
	;seems to only work for belts BUT DOESNT SELL TOME OF SECRETS
	NoItems = 0
	While NoItems = 0
	{
		PixelSearch, xloc, yloc, 1180, 570, 1650, 850, 0x45231C, 0, fast
		If !ErrorLevel
		{
				MouseMove, %xloc%, %yloc%, 10
				Click Right
				Sleep, 1000
		}
		Else
		{
			NoItems = 1
			Send, {esc} ;close inventory and exit vendor
		}
	}

	Sleep, 1000
}

Send, {Esc}
Sleep, 1000
MouseMove, 836, 567, 10
Click
Sleep, 4000
}

Return
F5::
Exitapp


YellowScanClick(xa, ya, xb, yb)
{
	Global ItemFound
	PixelSearch, xloc, yloc, %xa%, %ya%, %xb%, %yb%, 0x00FFFF, 2, Fast ;yellows
	If !ErrorLevel
	{
		ItemFound := 1
		MouseMove, %xloc%, %yloc%, 10
		Click
		Sleep, 1000
	}
	PixelSearch, xloc, yloc, %xa%, %ya%, %xb%, %yb%, 0x2F64BF, 2, Fast ;legendaries
	If !ErrorLevel
	{
		ItemFound := 1
		MouseMove, %xloc%, %yloc%, 10
		Click
		Sleep, 1000
	}
	PixelSearch, xloc, yloc, %xa%, %ya%, %xb%, %yb%, 0xFF6969, 2, Fast ;blues why not?
	If !ErrorLevel
	{
		ItemFound := 1
		MouseMove, %xloc%, %yloc%, 10
		Click
		Sleep, 1000
	}
Return
}



randallf
  • Members
  • 711 posts
  • Last active: Jan 07 2014 11:45 PM
  • Joined: 06 Jul 2009
Damn I posted under guest. FALE

Change the line

If !(Mod(A_INDEX,1))

to

If !(Mod(A_INDEX,10))

For every 10 loops instead of every loop.

Exclusively posted here. Please do not repost.

girlgamer
  • Moderators
  • 3263 posts
  • Last active: Feb 01 2015 09:49 AM
  • Joined: 04 Jun 2010
You spoke the name, Randallf, and poof there I was. Actually I've been lurking for several weeks, Haven't tried d3 yet but been working on several games in tandem. Aion F2p a fight manager and a crafting manager, Forsaken world fight manager, and a generic skeleton for any game using just-in-time reads from an ini file to configure the manager's fight engine. That along with several tools like an in-game click recorder to grab click sequences like with aion crafting and play them back. Been a fun break actually.

Looking at your code, I'd say you did a lot of work grabbing those locations and hardcoding them into your script. Pity but i can't use that screen resolution so i'd have to translate all those locations down' to the resolution my own card can handle. Wouldn't be that hard just time consuming you could add a screen location and pixel grabber to your code so you could tweak the locations ingame.. this might help ...
!g::
ScreenGrabber:
If (Grabflag)
{	Gosub EndGrab
	Return
}
GrabFlag = 1
[color=#008000];this sets the mouse return position[/color]
MouseGetPos, oposx, oposy
Sleep 100
[color=#008000]; we'll use a 1shot timer since the duration of the code
; in the timer is actually longer than the duration of the 
; timer. this will prevent timer hit conflicts.[/color]
SetTimer, WatchMouse, -100
Return

[color=#008000];------------------------------------------------
; 100 ms timer watches the mouse position
;------------------------------------------------
;............................
; entry point for mbutton grab section. mbutton
; calls this when it has a location and color to
; be saved
;............................[/color]
WatchMouse:
MouseGetPos, mx, my
Sleep 100

[color=#008000]; Get the color at the cursor position It's possible
; this color could be different than the color at the
; same position when the mouse is not over the item.
; If it is different color it is likely to be highlighted
; in some way. We will actually try to grab both
; highlighted and non highlighted colors[/color]
PixelGetColor, mcHilight, %mx%, %my%, RGB
Sleep 100
ToolTip, Line%A_LineNumber% %AppName% Activate window.`nCtrl-MButton to grab.`nx=%mx% y=%my% c=%mcHilight%
[color=#008000];reset the timer for the next go round[/color]
SetTimer, WatchMouse, -100
return

[color=#008000];------------------------------------------------
; end grabbing a screen location/color here is 
; where we'll grab the unhiglighted color for 
; the selected location. We'll put all this info
; on the clipboard so it can be pasted in where
; needed.
;------------------------------------------------[/color]
^MButton::
EndGrab:
If (GrabFlag) [color=#008000]; If grabbing loc and color[/color]
{	GrabFlag = 0
	Clipboard =
	
	[color=#008000]; turn off the cursor watch timer[/color]
	SetTimer, WatchMouse, Off
	Sleep 1000
	Tooltip,
	
	[color=#008000];grab the unhighlighted color[/color]
	MouseMove, %oposx%, %oposy%
	Sleep 100
	PixelGetColor, mcLolight, %mx%, %my%, RGB
	Sleep 300
	
	[color=#008000]; Save the data on the clipboard for use with ctrl-v or "paste"[/color]
	Clipboard = %mx%,%my%,%mcLolight%,%mcHilight%
	ClipWait
	
	[color=#008000]; put the data into notepad so it can
	; be seen[/color]
	Run, Notepad
	WinActivate, Untitled
	WinWaitActive, Untitled
	Send, ^v
}
Return

Hope you can use this in your code. I've had pretty good luck with it.

The universe is a wondrous place! The faster you create unbreakable code, the faster the universe creates people that can break it. All scripting follows the rule Rule Of Twos -- 1) Good, 2) Fast 3) Cheap -- pick any Two.
I guarantee absolutely nothing about any code I provide except that it works in my machine. ●
MMO Fighter   KeyLooperDemo   Key Spammer   TinyClickRecorder  GGs Password Generator.ahk
For the newest version of AutoHotkey and some killer scripts go here.
Rock-on%20kitten.gif


randallf
  • Members
  • 711 posts
  • Last active: Jan 07 2014 11:45 PM
  • Joined: 06 Jul 2009
Unfortunately in D3 there are all sorts of random dust clouds, critters, etc that create motion on the screen. It's a full 3D game stuck in iso perspective so coordinates of some type have to be used.

I was thinking that I could use percentages of active screen resolution to get coordinates for any resolution but I bet that's not going to work exactly right.

Any other suggestions? I have some friends who want to use this but they'd have to reprogram all the coords.

girlgamer
  • Moderators
  • 3263 posts
  • Last active: Feb 01 2015 09:49 AM
  • Joined: 04 Jun 2010
Actually one way this could be done is to take all the coordinates and move them from hardcoded into a text ini file. They could then be loaded as needed from the ini when the game starts up. If you arranged them in several CSV lists they could be loaded separately. Something similar to this.
[Setup]
CoordsSet1=225,406,10,8000,;resume game|1568,530,10,3000,;first move|1500,137,10,3000,; cauldron|879,446,10,2000,;potion?|1314,219,10,5000,;chest 1
YellowScanClick1=650,300,1100,650
Chest2Click= 370,125,10,5000,;Click chest 2
YellowScanClick2=555,368,1050,675
GrabGoldClick=780,745,10,1000,;grab gold
if you'll notice the csv even incorporates the comments in the last part of the element so it can be seen with debugging code like this.
!F7::KeyHistory
!F8::ListHotkeys
!F9::Pause
!F10::ListVars
!F11::ListLines
!F12::Reload
The way this kind of ini data structure could be used by the script is fairly simple to visualize...
IniFile = MyIniFile.ini
IfNotExist, %IniFile%
{     MsgBox,0,Line#%A_LineNumber%,Data file %IniFile% does not exist
      ExitApp
}
IniRead, CoordsSet1, %IniFile%, Setup, CoordsSet1, None
If (CoordsSet1 = "None")
{      MsgBox,0,Line#%A_LineNumber%,Data Set CoordSet1 is not valid
      ExitApp
}
StringSplit Coords1Array, CoordsSet1, | ;<-- splits them up into 5 piece chunks

Loop, 400
{     Loop %Coords1Array0% ;<-- contains the count of 5-plexes
      {     StringSplit, ThisCoord, Coords1Array%A_Index%, `,
            Click
            MouseMove, %ThisCoord1%, %ThisCoord2%,%ThisCoord3%
            Sleep %ThisCoord4%
      }
     ; Do other stuff from here down
}
If you wanted you might even consider making your own simple click recorder and embedding it into your script as a hotkey routine. That could allow your users to build their own data sets for the screen resolutions they work with. The grabber I showed you earlier could be modified to write to the captured data directly to the ini file for later use. You could even save the click locations in an array or pseudo array within the program for immediate playback if desired. That's kind of what I did with the AION Crafting Locs recorder. Since each craft uses a different set of locations it was necessary to dynamically alter the locs captured for each craft skill. To do that the first time through, the script allows the user to record the clicks they used and the locations and colors. Subsequent runs allow the user to run the click step (single step mode), verify the location before clicking(verify and/or change the step location), or run the entire series in one pass(run mode). You could do the same thing with this.

The universe is a wondrous place! The faster you create unbreakable code, the faster the universe creates people that can break it. All scripting follows the rule Rule Of Twos -- 1) Good, 2) Fast 3) Cheap -- pick any Two.
I guarantee absolutely nothing about any code I provide except that it works in my machine. ●
MMO Fighter   KeyLooperDemo   Key Spammer   TinyClickRecorder  GGs Password Generator.ahk
For the newest version of AutoHotkey and some killer scripts go here.
Rock-on%20kitten.gif


randallf
  • Members
  • 711 posts
  • Last active: Jan 07 2014 11:45 PM
  • Joined: 06 Jul 2009
I am not all that interested in wide dissemination of the program, frankly the less people using it the better. I figured if there were methods already out there for adjusting pixel detection and clicks for the users resolution that I might just write them into it.

I am pretty familiar with faking arrays, INI files, etc... this was extremely rough and I just wrote it to work on my system. It works for me, I guess I figured other D3 players here might be interested in item pickups, etc...

One problem with the above that I have solved is that since gems are white items it wouldn't pick them up. I got imagesearch (with a very meticulously modified image) to work to scan for the text "Flawless" in the title of the gems that I want.

So to any other AHK users working with D3, pixel detection and image searching for text on items is VERY possible.

thanks again

girlgamer
  • Moderators
  • 3263 posts
  • Last active: Feb 01 2015 09:49 AM
  • Joined: 04 Jun 2010
Of course there are techniques to scale the locations on the screen for different resolutions but many are excessively cumbersome for use in a non production script. Several commercial bots use a scaling method to adjust locations dynamically to different screen/window sizes but most all of them are some form of machine language for speed. Other production bots simply force the screen into a "lowest common denominator" screen resolution mode and anyone who can't realize that with their graphics system is just out of luck. And finally others provide a "configuration routine" often as an add on program that allows the user to run through the process grabbing and recording locations and colors and saving them for replay later on additional runs through the same process with the same screen resolution. if the resolution or screen real estate changes the configuration module allows the user to adjust to the new screen settings. Whichever way you choose to go it's important to remember that every script you make for your machine is a personal script that fits YOUR machine. Entire graphics/game developent teams are dedicated to developing widely useful programs. They have at their disposal a number of different machine setups to test their stuff on. And, unless you do too you're fighting an uphill battle trying to make your code fit someone else's machine. The easiest answer to giving your friends access to the stuff you write is to a) give them a configuration routine they can use for themselves, B) use configuration files that can be shared between them if necessary without sharing custom code, and c) make it clear you are not going to spend your life fixing the code in their machines. Guaranteed one or more of them will diddle your code and break it at some point and call you to fix what they can't remember they did. This is the one main reason for disclaimers and EULA's in commercial code.

And just so you know. I'm here if you want to just bang some ideas around.

The universe is a wondrous place! The faster you create unbreakable code, the faster the universe creates people that can break it. All scripting follows the rule Rule Of Twos -- 1) Good, 2) Fast 3) Cheap -- pick any Two.
I guarantee absolutely nothing about any code I provide except that it works in my machine. ●
MMO Fighter   KeyLooperDemo   Key Spammer   TinyClickRecorder  GGs Password Generator.ahk
For the newest version of AutoHotkey and some killer scripts go here.
Rock-on%20kitten.gif


randallf
  • Members
  • 711 posts
  • Last active: Jan 07 2014 11:45 PM
  • Joined: 06 Jul 2009
Cool, one idea I had was that as far as I know there are two types of screens - standard and widescreen? I myself am running widescreen and so are most people nowadays.

Between larger or smaller widescreen resolutions do you think it should be possible to target pixels based on a percentage of screen width and height? Will these scale properly? I think I need to get out Excel and do some basic calculations and see how accurate that can be

Also - have you seen this "StarForge" alpha? It's in alpha but the youtube video looks really cool

Edit: OF COURZES DURRR
All screen resolutions have an aspect ratio, the above code being WSXGA+ 16:10 (the second most common resolution of steam users too)
It should be possible to translate one to another by using this ratio and the actual resolution with a percentage of width and height

girlgamer
  • Moderators
  • 3263 posts
  • Last active: Feb 01 2015 09:49 AM
  • Joined: 04 Jun 2010
Looks interesting even in Alpha. I did get a headache watching the video of the guy thrashing around with the command window onscreen tho. Minecraft in space seems a pretty accurate description.

The universe is a wondrous place! The faster you create unbreakable code, the faster the universe creates people that can break it. All scripting follows the rule Rule Of Twos -- 1) Good, 2) Fast 3) Cheap -- pick any Two.
I guarantee absolutely nothing about any code I provide except that it works in my machine. ●
MMO Fighter   KeyLooperDemo   Key Spammer   TinyClickRecorder  GGs Password Generator.ahk
For the newest version of AutoHotkey and some killer scripts go here.
Rock-on%20kitten.gif


dxdiag
  • Guests
  • Last active:
  • Joined: --
Can you please explain this part

Talk to the wench
Exit the game
Run the script
Watch the potions and gold stack up


Exit the game after talking to the wench? I don't understand, shouldn't the game be running or exit how? Does the gold and potions keep popping up or how does this work?

randallf
  • Members
  • 711 posts
  • Last active: Jan 07 2014 11:45 PM
  • Joined: 06 Jul 2009

Can you please explain this part

Talk to the wench
Exit the game
Run the script
Watch the potions and gold stack up


Exit the game after talking to the wench? I don't understand, shouldn't the game be running or exit how? Does the gold and potions keep popping up or how does this work?


So you go to the cellar
You clear it
You talk to Leah
You exit the game
You run the script

The script resumes game in the cellar which now has no monsters in it but will continue to spawn chests randomly when reloaded. The potion in the cauldron always appears. I have farmed ~2500 mythic health potions and maybe 300k gold with this script over maybe 20 hours. One legendary as well, unfortunately almost all legendaries suck in D3 - but I can absolutely verify these chests CAN drop them.

I have requested a refund for this horrible game and if I get it well, that's the end of development for this. There are way better games of this type coming out in the next few months that won't be totally rushed and screwed up. It's a real shame that Diablo III existed, nearly finished as long ago as 2008, but then Blizzard North was canned for no good reason. Definitely going to be looking at Torchlight 2.

Here's my whole version as it stands.

WinActivate, Diablo III

Loop, 400
{

MouseMove, 225, 406, 10 ;resume game
Click
sleep 8000

MouseMove, 1568, 530, 10 ;first move
Click
Sleep 3000

MouseMove, 1500, 137, 10 ; cauldron
Click
Sleep, 3000

MouseMove, 879, 446, 10 ;potion?
Click
Sleep, 2000

MouseMove, 1314, 219, 10 ;chest 1
Click
Sleep, 5000

;get yellows
ItemFound = 0
Loop, 5
{
	YellowScanClick(650, 300, 1100, 650)
}

imagesearch, xloc, yloc, 650, 300, 1100, 650, *2 *TransBlack c:\flawlesssquare.png
If !errorlevel
{
	MouseMove, %xloc%, %yloc%, 10
	Click
	Sleep, 500
}

If ItemFound = 0 ;if it found nothing check the other chest location
{
	MouseMove, 370, 125, 10 ;click chest 2
	Click
	Sleep, 5000
	Loop, 5
	{
		YellowScanClick(555, 368, 1050, 675)
	}
	
	Sleep, 500
	
	imagesearch, xloc, yloc, 650, 300, 1100, 650, *2 *TransBlack c:\flawlesssquare.png
	If !errorlevel
	{
		MouseMove, %xloc%, %yloc%, 10
		Click
		Sleep, 500
	}
	
	;move off to grab gold
	MouseMove, 780, 745, 10
	Click
	Sleep, 1000

}

;get flawless gems
imagesearch, xloc, yloc, 1, 1, 1680, 1050, *2 *TransBlack c:\flawlesssquare.png
MouseMove, %xloc%, %yloc%


;MouseMove, 370, 125, 10 ;move to chest 2 (and grab any gold from chest 1)
;Click
;Sleep, 5000
;MouseMove, 790, 650, 10 ;small move to grab chest 2 gold
;Click

Sleep, 1000

;portal out and exit game
Send, {t}

Sleep, 9000

;sell off blues
;scan for blue items in inventory
;inventory is 1180 570 by 1650 850

;after town portal move to vendor every so many loops
If !(Mod(A_INDEX,10))
{
	MouseMove, 1296, 89, 10
	Click
	Sleep, 3000
	MouseMove, 1082, 135, 10
	Click
	Sleep, 3000

	;scan for blue item color and sell
	NoItems = 0
	While NoItems = 0
	{
		PixelSearch, xloc, yloc, 1180, 570, 1650, 850, 0x311E16, 0, fast
		If !ErrorLevel
		{
				MouseMove, %xloc%, %yloc%, 10
				Click Right
				Sleep, 1000
		}
		Else
		{
			NoItems = 1
			;Send, {esc} ;close inventory and exit vendor
		}
	}

	;scan for single slot blue item colors and sell
	;seems to only work for belts BUT DOESNT SELL TOME OF SECRETS
	NoItems = 0
	While NoItems = 0
	{
		PixelSearch, xloc, yloc, 1180, 570, 1650, 850, 0x45231C, 0, fast
		If !ErrorLevel
		{
				MouseMove, %xloc%, %yloc%, 10
				Click Right
				Sleep, 1000
		}
		Else
		{
			NoItems = 1
			Send, {esc} ;close inventory and exit vendor
		}
	}

	Sleep, 1000
}

Send, {Esc}
Sleep, 1000
MouseMove, 836, 567, 10
Click
Sleep, 4000
}

Return
F5::
Exitapp


YellowScanClick(xa, ya, xb, yb)
{
	Global ItemFound
	PixelSearch, xloc, yloc, %xa%, %ya%, %xb%, %yb%, 0x00FFFF, 2, Fast ;yellows
	If !ErrorLevel
	{
		ItemFound := 1
		MouseMove, %xloc%, %yloc%, 10
		Click
		Sleep, 1000
	}
	PixelSearch, xloc, yloc, %xa%, %ya%, %xb%, %yb%, 0x2F64BF, 2, Fast ;legendaries
	If !ErrorLevel
	{
		ItemFound := 1
		MouseMove, %xloc%, %yloc%, 10
		Click
		Sleep, 1000
	}
	PixelSearch, xloc, yloc, %xa%, %ya%, %xb%, %yb%, 0xFF6969, 2, Fast ;blues why not?
	If !ErrorLevel
	{
		ItemFound := 1
		MouseMove, %xloc%, %yloc%, 10
		Click
		Sleep, 1000
	}
Return
}
	
	



Edit: FlawlessSquare.PNG attached... will absolutely ONLY work in the stated resolution but may give you an idea on what to construct. ImageSearch on alias'd text requires some intelligent pixel choices. Something to remember when constructing this images, or really when automating almost anything with AHK - is that you are searching for the solution path that will always be consistent.

Possible improvements that could be made;
Could be sped up by Pixel verification of chest locations instead of just checking each chest every time.
Item selling detection could be improved
Could stash gems and tome of secrets
Many delay times could be adjusted to improve speed - I think with the above individual runs could be whittled down to ~15 seconds.

FFSmasher
  • Members
  • 3 posts
  • Last active: Jun 05 2012 02:51 PM
  • Joined: 05 Jun 2012
So this is working and looping properly, however it's not checking the other chest location, just ports back to town after clicking around in the corner, and it seems the chest spawns at the top more often than to the right (first location it checks)

randallf
  • Members
  • 711 posts
  • Last active: Jan 07 2014 11:45 PM
  • Joined: 06 Jul 2009
Fire on weapons will cause false positives, I say this because "ItemFound" is the trap for the second chest. If it thinks it found something, it will not check the second chest (as there is only one)

  • Guests
  • Last active:
  • Joined: --
the detecting color of items doesnt seem to work, at least for me, the rest is perfect.
Anyone had any problems with the colors too?

randallf
  • Members
  • 711 posts
  • Last active: Jan 07 2014 11:45 PM
  • Joined: 06 Jul 2009
Try changing the tolerance on the PixelSearch for item selling to a 2. It will then sell all blue items - but will also sell tome of secrets which is what I did not want.

If that does not work try a larger variance.

Edit: If you mean the other item varieties for picking up items, also try changing the variance color. If that doesn't work or causes false positives then you will need to take some screenshots and use pixelspy - I recommend just printscreen and paste it into mspaint, zoom in all the way and pixelspy on an appropriately colored pixel.

Also as stated make sure you are in windowed mode.