Page 1 of 1

Argo Bot (Partially working)

Posted: Fri May 06, 2011 2:35 am
by MiesterMan
Updated (5/6/2011 - 2:44 PM CST):

Requires you to keep the window open and active. Doesn't work with the main action bar yet but the shift+action bar is working so use that for your pots. Also it loots which is nice.

Here is the bot.lua:

Code: Select all

include("addresses.lua");

setStartKey(key.VK_DELETE);
setStopKey(key.VK_END);
window = findWindow("ARGO")

function updateHP()
	-- curHP = memoryReadIntPtr(myProcess, curHP_addr, curHP_offset);
	-- maxHP = memoryReadIntPtr(myProcess, maxHP_addr, maxHP_offset);
	-- tarHP = memoryReadIntPtr(myProcess, maxHP_addr, maxHP_offset);
	
end
function findTarget()
	print( "Finding a target." )
	targetSearch = true
	hdc = openDC( window )
	rSC,gSC,bSC = getPixel(hdc, 170, 641);
	closeDC(hdc)
	if ( rSC == 39 ) then
		keyboardHold( key.VK_SHIFT )
		yrest(50)
		keyboardHold( key.VK_7 )
		yrest(100)
		keyboardRelease( key.VK_7 )
		keyboardRelease( key.VK_SHIFT )
		yrest(30000)
	end
	keyboardHold( key.VK_Q )
	yrest(100)
	while targetSearch do
		keyboardHold( key.VK_TAB )
		yrest(100)
		keyboardRelease( key.VK_TAB )
		if (  isTarget() ) then
			targetSearch = false
		end
	end
	keyboardRelease( key.VK_Q )
	return true
end
function isTarget()
	print( "Checking if there's a target." )
	hdc = openDC( window )
	rTF,gTF,bTF = getPixel(hdc, 391, 24);
	closeDC(hdc)
	if ( rTF == 165 and gTF == 50 and bTF == 65 ) then
		return true
	else
		return false
	end
end
function potUpdate()
	print( "Checking HP, MP, and Core." )
	hdc = openDC( window )
	rHP,gHP,bHP = getPixel(hdc, 243, 641);
	rMP,gMP,bMP = getPixel(hdc, 243, 656);
	rCP,gCP,bCP = getPixel(hdc, 769, 630);
	closeDC(hdc)
	if ( rHP == 39 ) then
		keyboardHold( key.VK_SHIFT )
		yrest(50)
		keyboardHold( key.VK_2 )
		yrest(100)
		keyboardRelease( key.VK_2 )
		keyboardRelease( key.VK_SHIFT )
		yrest(500)
	end
	if ( bMP == 39 ) then
		keyboardHold( key.VK_SHIFT )
		yrest(50)
		keyboardHold( key.VK_3 )
		yrest(100)
		keyboardRelease( key.VK_3 )
		keyboardRelease( key.VK_SHIFT )
		yrest(500)
	end
	if ( gCP == 5 ) then
		keyboardHold( key.VK_SHIFT )
		yrest(50)
		keyboardHold( key.VK_6 )
		yrest(100)
		keyboardRelease( key.VK_6 )
		keyboardRelease( key.VK_SHIFT )
		yrest(500)
	end
end
function fightMonster()
	print( "Fighting Monster!" )
	while isTarget() do
		potUpdate();
		keyboardPress( key.VK_TILDE )
		yrest(500);
		keyboardPress( key.VK_1 )
		keyboardHold( key.VK_1 )
		yrest(100)
		keyboardRelease( key.VK_1 )
		yrest(500);
		keyboardPress( key.VK_2 )
		keyboardHold( key.VK_2 )
		yrest(100)
		keyboardRelease( key.VK_2)
		yrest(500);
		keyboardPress( key.VK_3 )
		keyboardHold( key.VK_3 )
		yrest(100)
		keyboardRelease( key.VK_3 )
		yrest(500);
		keyboardPress( key.VK_4 )
		keyboardHold( key.VK_4 )
		yrest(100)
		keyboardRelease( key.VK_4 )
		yrest(500);
		keyboardPress( key.VK_5 )
		keyboardHold( key.VK_5 )
		yrest(100)
		keyboardRelease( key.VK_5 )
		yrest(500);
	end
end
function main()
--	attach( window )
--	number = getAttachedHwnd() 
--	print( "Your window number is " .. number .. "\n")
	print("This is my new Argo bot!")
	--print("Pressing End will pause the bot and Delete will resume.\nPress Delete to continue.")
--	attachKeyboard(window)
	-- weTestVks = true
	-- while weTestVks do
		-- keyboardPress( key.VK_TILDE )
		-- yrest(500);
		-- keyboardPress( key.VK_1 )
		-- yrest(500);
		-- keyboardPress( key.VK_2 )
		-- yrest(500);
		-- keyboardPress( key.VK_3 )
		-- yrest(500);
		-- keyboardPress( key.VK_4 )
		-- yrest(500);
	-- end
	if ( not isTarget() ) then
		findTarget()
	end
	weBegin = true
	while weBegin do
		print( "We Begin." )
		fightMonster()
		findTarget()
	end
end
 
startMacro(main)
Yes, there is some stubbing (or just broken code) in there either not doing anything or commented out. When I work in more activity that'll change (namely using mem addresses instead of pixel scans).

Re: Argo Bot (Can't get VK's to work)

Posted: Fri May 06, 2011 6:24 am
by Administrator
Check the log to see if attach() failed. Try also running it in un-attached mode (but this requires the game window to be focused) to see if the key presses go through. Every game is programmed differently, and so it is impossible to write one function that works on everything. This game just seems to not use the normal input queue, and, instead, uses it's own. This prevents MicroMacro from jamming false key presses into the queue.

As for the color scanning, do not assume that the color you have found is correct. I know this doesn't sound right, but using print screen actually screws with the color a bit. If you screenshot something, paste it, screenshot that, paste it, and continue that process, you'll notice that the image will gradually become a darker, reddish color. I would recommend you, instead, use pixelSearch with a 'accuracy' of 10 (you might need to play with this value) or implement your own range value check. Keep in mind that if there is any alpha transparency (that is, you can partially see through the health bar -- or whatever it is you're looking for), that will effect the color value as things in the background change.

Re: Argo Bot (Can't get VK's to work)

Posted: Fri May 06, 2011 7:29 am
by lisa
If I was to suguest anything it would be to add in print statements at each step of what you are testing so you can pinpoint exactly what is working and what isn't working.

Re: Argo Bot (Can't get VK's to work)

Posted: Fri May 06, 2011 2:40 pm
by MiesterMan
Lisa, did that, lolz.

Sorry this seems to have not posted this morning so posting it now:

I looked in the log and tried to find the attachment but you were right there wasn't anything about it in the log. I removed the attach statements and MicroMacro can send VKs now. The colors were very close but not exact. The main cause was that the coords were different. I used the getPixel command and outputted the colors at the coords so I could use them.

It's working for the most part, while it is killing and looting I can't seem to get it to use skills, but this is a BIG leap from nothing, lol.

TYVM!!

Addition: Seems I still had things a little off as he killed 70 then died. It's working swimmingly now - save for the fact I can't get regular skills to work (i.e. action bar 1-5). The shift presses are working though, the pots, which is quite odd.

Re: Argo Bot (Partially working)

Posted: Mon May 09, 2011 12:01 am
by MiesterMan
So any ideas as to why I can't get normal numbers from the action bar to work? TAB, R, and F keys all work as well as Shift+1,2,3,4,5... all work. Just the normal number keys wont' work.

Re: Argo Bot (Partially working)

Posted: Mon May 09, 2011 5:17 pm
by MiesterMan
Seems that working without waypoints was too dangerous. Already banned. The funny part is that botting in high traffic places didn't result in any issues, it was when I botted in a low profile area that I got nuked.

Not sure if I'll bother continuing this project. I had started to add timers and skill sets but the game itself wasn't particularly high quality. I'll have to decide this later.

Re: Argo Bot (Partially working)

Posted: Mon May 09, 2011 6:54 pm
by Administrator
Seems that working without waypoints was too dangerous. Already banned. The funny part is that botting in high traffic places didn't result in any issues, it was when I botted in a low profile area that I got nuked.
Strangely enough, that kind of makes sense. In areas that receive a lot of traffic, players don't tend to stay around long enough to notice you. That, and they are distracted by the high number of other players.

Group botting can also work pretty well (as long as it isn't blatantly obvious). If you (and possibly some friends) can completely take over an area with bots, people just go away and won't bother with it.