maths stuff

Whatever you want here. Just make sure it's off topic. Which...I guess if the topic is being off topic, then it means you should be on topic. Understand?
Post Reply
Message
Author
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

maths stuff

#1 Post by lisa » Sat Jun 28, 2014 8:16 pm

Ok long story short I have been playing Star Trek Online a bit lately and there is something called mining which I do as a daily quest, it is like a game and I do it 16 times a day, it is easy enough but to be honest I get bored of it.

So to that end I have looked to memory and found out some info for the game and this is where the maths stuff comes into it.
stomine1.png
stomine2.png
As you can see from the pics there is a red triangle and a white triangle, you control the white triangle. You need to match size and angle to the red triangle to increase the points you get.

Size:
This is a piece of cake, float values increase and decrease.

Angle:
Ok this is easy enough in a way but to make it more efficient is a little tricky.
So being a triangle you can imagine 3 times in a 360 degree rotation it will be the same as the red triangle.
From my calculations you get 9 adjustments X 3 to make the 360 degrees.

Here is the float values.

Code: Select all

1.00   0.97  0.89  0.77   0.60  0.40   0.17 -0.06  -0.29 
-0.50 -0.69 -0.84 -0.94  -0.99 -0.99  -0.94 -0.84  -0.69 
-0.50 -0.29 -0.06  0.17   0.40  0.60   0.77  0.89   0.97
So 27 (9 x 3) values there and then goes back to start again.

I have the red triangle value, example 0.77 and so to make the white triangle match I could just turn it to be 0.77 but it may have been posible to match triangles before turning that much, as example 0.17 and -0.94 are also a matching angle.

So would it be easier to just do a table of the angles or can I do some fancy maths stuff to do the same job, just incase the values aren't always exactly as recorded. I have noticed the float values kind of flicker when changing, so going from 0.60 to 0.77 it might flicker value at 0.76 before being 0.77

Or maybe I should use the byte values instead of float values?
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: maths stuff

#2 Post by lisa » Sat Jun 28, 2014 10:50 pm

decided to not make it perfectly efficient, it turns left until triangles match.

Manually I score 850-950 without any hassle and once I scored 1030, first time through with the following code it scored 1220, so yeah it is working good enough. Next 5 tries were all 1200+ aswell.

Only issue I really had was MM wasn't doing "arrow" keys to the game while attached, normal characters worked fine but not arrow keys. So I just didn't attach MM to game and I make sure that the game has focus.

Code: Select all

		repeat
			if memoryReadRepeat("float",proc,startadd + 0x10) > memoryReadRepeat("float",proc,startadd + 0x120 + 0x10) then
				keyboardPress(key.VK_DOWN)
			else
				keyboardPress(key.VK_UP)
			end
			yrest(50)
			local dist = memoryReadRepeat("float",proc,startadd + 0x10) - memoryReadRepeat("float",proc,startadd + 0x120 + 0x10)
			if 0 > dist then
				dist = 0-dist
			end
		until 0.4 > dist
		print("size is ok")
		if memoryReadRepeat("int",proc,startadd + 0x200) == 0 then
			repeat
				keyboardPress(key.VK_LEFT)
				yrest(20)
			until memoryReadRepeat("int",proc,startadd + 0x200) ~= 0
		end
		print("working well")
		repeat 
			yrest(100)
		until memoryReadRepeat("int",proc,startadd + 0x200) == 0  
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: maths stuff

#3 Post by rock5 » Sun Jun 29, 2014 9:43 am

I don't think the mouse clicking ever worked on attached processes. Maybe you should try using MM2. That looks like it has more options, ie. virtual mouse.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: maths stuff

#4 Post by Administrator » Sun Jun 29, 2014 11:35 am

There's probably a variable somewhere that records the rotation of the target triangle. You could probably try to match up to that instead of constantly checking the score. That might be a hard one to find, though! What happens if you memory-set your score to 1.0? Is it server sided or client sided?

Do you have control of the rotation speed? This could be a case where linear interpolation would come in handy for speed and accuracy. In essence, you can have it rotate faster when its further off, but when it gets closer it slows down for accuracy.
lisa wrote: Only issue I really had was MM wasn't doing "arrow" keys to the game while attached, normal characters worked fine but not arrow keys. So I just didn't attach MM to game and I make sure that the game has focus.
Most likely those keys are coded to use different input. I see it all the time. As you probably seen from my other post in the off-topic section, I've been playing Black Gold Online. When flying a helicopter or plane, I noticed that when typing in chat my altitude would sometimes drop. It was because the SHIFT key drops you down, and I was tapping it while typing. I then noticed that even if the game doesn't have focus, it picks up on modifiers (such as SHIFT). Looks like it uses GetKeyState() for those, while other keys use DirectInput.

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: maths stuff

#5 Post by lisa » Sun Jun 29, 2014 7:15 pm

Administrator wrote:There's probably a variable somewhere that records the rotation of the target triangle. You could probably try to match up to that instead of constantly checking the score. That might be a hard one to find, though! What happens if you memory-set your score to 1.0? Is it server sided or client sided?Do you have control of the rotation speed? This could be a case where linear interpolation would come in handy for speed and accuracy. In essence, you can have it rotate faster when its further off, but when it gets closer it slows down for accuracy.
It's ok there is no benefit to getting a really high score, basically anything over 750 gets the same rewards, I was just sick of doing it manually.

Something I am having issue with atm is with getModuleAddress, it seems to return 0 all the time even when I know it shouldn't be, I figure it is to do with the values I am using for the arguments.

I get the window just fine as this works "showWindow(__WIN,1)", so it must be the second argument that is causing the issue.

Code: Select all

getModuleAddress(__WIN, "GameClient.exe")
I tried with "*" for second arg but it still returns 0, my testing in CE shows it varies each startup and it has been 830000, 1f0000 so it should deffinately have a value of not 0.
Surely having the window is enough to get what is needed, I don't see why it needs the second arg.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: maths stuff

#6 Post by Administrator » Sun Jun 29, 2014 10:49 pm

getModuleAddress() expects the process ID, not the handle to window. I think that's your problem.

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: maths stuff

#7 Post by rock5 » Sun Jun 29, 2014 10:50 pm

I'm guessing a process can have more than 1 module?
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: maths stuff

#8 Post by lisa » Sun Jun 29, 2014 11:15 pm

Administrator wrote:getModuleAddress() expects the process ID, not the handle to window. I think that's your problem.
yep that was the issue.

Code: Select all

getModuleAddress(findProcessByWindow(getWin()), "GameClient.exe")
fixed it.
This works on current version on 32bit windows, just stand at the spot where you can start it and use it in MM, it will automatically make the game have focus.

Mostly posting this so I can just copy paste it to my other PC, which uses different pointer/offsets as it is a 64bit machine.

Code: Select all

local windowList = findWindowList("*","CrypticWindowClassDX1")
if( #windowList == 0 ) then
	print("You need to run STO first!");
	return 0;
end

function getWin()
	if( __WIN == nil ) then
  		__WIN = windowList[1]
	end
	return __WIN;
end	

function getProc()
	if __PROC == nil then
		if( __PROC ) then closeProcess(__PROC) end;
		__PROC = openProcess(findProcessByWindow(getWin()))
	end

	return __PROC;
end

function memoryReadRepeat(_type, proc, address, offset)
	local readfunc;
	local ptr = false;
	local val;
	if( type(proc) ~= "userdata" ) then
		error("Invalid proc", 2);
	end
	if( type(address) ~= "number" ) then
		error("Invalid address", 2);
	end
	if( _type == "int" ) then
		readfunc = memoryReadInt;
	elseif( _type == "uint" ) then
		readfunc = memoryReadUInt;
	elseif( _type == "float" ) then
		readfunc = memoryReadFloat;
	elseif( _type == "byte" ) then
		readfunc = memoryReadByte;
	elseif( _type == "string" ) then
		readfunc = memoryReadString;
	elseif( _type == "ustring" ) then
		readfunc = memoryReadUString;
	elseif( _type == "intptr" ) then
		readfunc = memoryReadIntPtr;
		ptr = true;
	elseif( _type == "uintptr" ) then
		readfunc = memoryReadUIntPtr;
		ptr = true;
	elseif( _type == "byteptr" ) then
		readfunc = memoryReadBytePtr;
		ptr = true;
	elseif( _type == "floatptr" ) then
		readfunc = memoryReadFloatPtr;
		ptr = true;		
	else
		return nil;
	end
	for i = 1, 10 do
		showWarnings(false);
		if( ptr ) then
			val = readfunc(proc, address, offset);
		else
			val = readfunc(proc, address);
		end
		showWarnings(true);

		if( val ) then i = 11; end; -- Get out of loop
	end
	if( val == nil ) then
		local info = debug.getinfo(2);
		local name;
		if( info.name ) then
			name = info.name .. '()';
		else
			name = '<unknown>';
		end
		local msg = sprintf("Error reading memory in %s from %s:%d", name, info.short_src, info.currentline or 0);
		error(msg, 2)
	end
	return val
end

setStartKey(key.VK_F5)
setStopKey(key.VK_F6)
local gamebase = getModuleAddress(findProcessByWindow(getWin()), "GameClient.exe")

local proc = getProc()
local startadd = memoryReadRepeat("uintptr",proc, gamebase + 0x24D88C0,{0x14,0x194,0x188})  --32bit
--local startadd = memoryReadRepeat("uintptr",proc, gamebase + 0x25C6878,{0x34,0x18,0x38,0x648}) --64 bit
startadd = startadd + 0xA0
printf("game base: 0x%x, start address: 0x%x\n",gamebase,startadd)
showWindow(__WIN,1)
yrest(1000)
keyboardPress(key.VK_F)
repeat
	yrest(500)
until memoryReadRepeat("int",proc,startadd + 0x4) ~= 0
	
function main()
	local starttime = getTime()
	repeat
		repeat
			if memoryReadRepeat("float",proc,startadd + 0x10) > memoryReadRepeat("float",proc,startadd + 0x120 + 0x10) then
				keyboardPress(key.VK_DOWN)
			else
				keyboardPress(key.VK_UP)
			end
			yrest(50)
			local dist = memoryReadRepeat("float",proc,startadd + 0x10) - memoryReadRepeat("float",proc,startadd + 0x120 + 0x10)
			if 0 > dist then
				dist = 0-dist
			end
		until 0.4 > dist or deltaTime(getTime(),starttime) >= 59000
		print("size is ok")
		if memoryReadRepeat("int",proc,startadd + 0x200) == 0 then
			repeat
				keyboardPress(key.VK_LEFT)
				yrest(20)
			until memoryReadRepeat("int",proc,startadd + 0x200) ~= 0 or deltaTime(getTime(),starttime) >= 59000
		end
		print("working well")
		repeat 
			yrest(100)
		until memoryReadRepeat("int",proc,startadd + 0x200) == 0 or deltaTime(getTime(),starttime) >= 59000
	until deltaTime(getTime(),starttime) >= 59000
end
startMacro(main,true)
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: maths stuff

#9 Post by BlubBlab » Mon Jun 30, 2014 4:16 am

Wooha niece done when you realize this mini-game was designed especially to make botting hard in STO.
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: maths stuff

#10 Post by lisa » Mon Jun 30, 2014 5:26 pm

BlubBlab wrote:Wooha niece done when you realize this mini-game was designed especially to make botting hard in STO.
lol seriously?
I thought it was farely basic to do in the end, when I decided not to worry about getting best score possible.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: maths stuff

#11 Post by BlubBlab » Tue Jul 01, 2014 5:18 am

Okay perhaps the game changed but in the past the pattern often changed randomly so I thought It would be very difficult to bot or at the least I can say it was one part which had one of the highest complexity in the game.

I think only ground PvP would be more complex, in PWE other game NW you need for the same daily activity do group stuff so they realized that such mini-games aren't complex enough.(and WOI have a in-build bot for everyone)
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: maths stuff

#12 Post by lisa » Tue Jul 01, 2014 7:36 am

It does change randomly but it wasn't hard to work.

Its funny but i never intended to try to bot STO.

So if you buy the lifetime thingy they give you 500 Zen a month.

But Each character you have can easily farm 3480 dil per day (depending on fleet lvl), around 30 mins time each char which equates to 600 zen/month per character. So I am very tempted to make a couple of alts to farm dil like this.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: maths stuff

#13 Post by BlubBlab » Tue Jul 01, 2014 12:18 pm

I still have STO on my Hard Disk I haven't played the game since I was in the dyson sphere and got obliterated.
I do more serious stuff at the moment:
http://en.wikipedia.org/wiki/Canny_edge_detector
http://en.wikipedia.org/wiki/Hough_transform
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest