Page 1 of 1

Trying to make a simple mining bot for a game called Wurm...

Posted: Fri Sep 23, 2011 10:35 pm
by Exempt
Trying to make a mining bot for a game called Wurm Online. It's a game made in java and it's being a pain to detect stats like food, water, and most importantly stamina. I can't seem to find memory addresses so I'm trying to just use a color picker to check for the stamina..

Code: Select all

matchcolor = makeColor(93, 157, 88);
x,y = pixelSearch(hdc, matchcolor, 186, 0, 206, 16, 10, 2);
r,g,b = getPixel(hdc, 196, 6);
printf("RGB: %d, %d, %d", r, g, b);
printf("x: %d\n",x);
For some odd reason it's telling me the color at that location is 255, 255, 255 which is not true it's a greenish color. I used paint to get the RGB values from the stamina bar.
This is the full code..

Code: Select all

setStartKey(key.VK_DELETE);
setStopKey(key.VK_END);

function main()
	--attach( findWindow("Wurm Online 3.0") );
	keyboardSetDelay(100);
	windows = 1;                 --Not really used atm...
	times = 0;                     --Varible to hold the amount of times i've mined...
	window = findWindow("Wurm Online 3.0.1")
	hdc = openDC(window);
	printf("hdc: %s\n", hdc);
	winX, winY, wWidth, wHeight = windowRect(window);
	printf("X %d, Y %d, W %d, H %d \n", winX, winY, wWidth, wHeight);
	
              --Just an easy way to make sure the window has focus....
	mouseSet(math.random((wWidth/2)-10, (wWidth/2)+10)+winX, math.random((wHeight/2)-10, (wHeight/2)+10)+winY);
	yrest(1000);
	mouseLClick();
	yrest(1000);

	while(times < 100) do
		if(windows >= 1) then
			matchcolor = makeColor(93, 157, 88);
			x,y = pixelSearch(hdc, matchcolor, 186, 0, 206, 16, 10, 2);
			r,g,b = getPixel(hdc, 196, 6);
			printf("RGB: %d, %d, %d", r, g, b);
			printf("x: %d\n",x);
			yrest(500);
			if(x > -1) then
				yrest(500);
				mouseSet(math.random((wWidth/2)-10, (wWidth/2)+10)+winX, math.random((wHeight/2)-10, (wHeight/2)+10)+winY);
				yrest(500); 
				keyboardPress(key.VK_M);
				times = times+1;
				printf("Times: %i\n", times);
			end
		end
	end	
	printf("Mined %i times. All done.\n", times);
	--detach();
end
startMacro(main);

Re: Trying to make a simple mining bot for a game called Wur

Posted: Sat Sep 24, 2011 11:51 pm
by Administrator
For whatever reason, it seems like it is failing to get the pixel color. What does your log.txt say? There's any number of things that can be wrong. Maybe, the game is protected by some virtual machine or something.

Re: Trying to make a simple mining bot for a game called Wur

Posted: Mon Sep 26, 2011 2:05 pm
by Exempt
log.txt just says this....

Code: Select all

on Sep 26 14:00:45 2011 : Processor Type: 4X AMD or Intel x64 @3292MHz, OS: Windows 7 Service Pack 1
Mon Sep 26 14:00:45 2011 : User privilege level: Administrator
Mon Sep 26 14:00:45 2011 : Lua glues exported
Mon Sep 26 14:00:45 2011 : MicroMacro v1.01 beta 4
Mon Sep 26 14:00:45 2011 : LuaCoco is available
Mon Sep 26 14:00:45 2011 : Keyboard layout: US English
Mon Sep 26 14:01:18 2011 : Executing script 'miner.lua'
-------------------------------------------------------------------------------


Mon Sep 26 14:02:20 2011 : Execution success
All I get from the printf("RGB: %d, %d, %d", r, g, b); is 255, 255, 255.






PS: You're Avatar scares me. :shock:

Re: Trying to make a simple mining bot for a game called Wur

Posted: Tue Sep 27, 2011 3:41 pm
by Administrator
Well, that's not very helpful. It could still be anything. Would this happen to be a flash game? If not, can you try testing it on another window to rule that out?
PS: You're Avatar scares me. :shock:
But it is cute.

Re: Trying to make a simple mining bot for a game called Wur

Posted: Fri Sep 30, 2011 7:27 pm
by Exempt
Administrator wrote:Well, that's not very helpful. It could still be anything. Would this happen to be a flash game? If not, can you try testing it on another window to rule that out?
PS: You're Avatar scares me. :shock:
But it is cute.
I don't think it uses flash, the game was made with Java. http://www.wurmonline.com, it's a decent game if you like sandboxes for sure. I use similar code in other games that use directx and it works fine. I assume it's something the game does. :(
By te way is there anyway to use attach() with direct input games?

In a scary kinda way...I guess.

Re: Trying to make a simple mining bot for a game called Wur

Posted: Sat Oct 01, 2011 3:24 pm
by Administrator
You would probably have to inject a DLL to hook all of the DirectX functions in order to achieve everything you want.

Re: Trying to make a simple mining bot for a game called Wur

Posted: Sat Oct 01, 2011 4:54 pm
by Exempt
Lame, I cannot figure out drectx hooking. I spent 2 weeks tinkering with a hooking tutorial and didn't get anywhere. Do you happen to know any basic hooking tutorials that use DLL injection?

Re: Trying to make a simple mining bot for a game called Wur

Posted: Tue Oct 04, 2011 1:26 am
by Administrator
It is a pain. I'm not going to bother explaining all the details, so just try the Direct3D hook starter kit.