New function: RoMScript

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
droppen
Posts: 179
Joined: Mon Aug 03, 2009 10:32 pm

New function: RoMScript

#1 Post by droppen » Sun Aug 30, 2009 10:12 pm

This function will probably revolutionize rom botting. (unless the address is not a static after all)

add this to adresses.lua

Code: Select all

macro_address = 0x033B0110;

add this to functions.lua

Code: Select all

--- Run rom scripts, usage: RomScript("AcceptResurrect();");
function RoMScript(script)
	local text = "/script " .. script;

	for i = 0, 254, 1 do
		local byte = string.byte(text, i+1);
		if byte == null then
			byte = 0;
		end
		memoryWriteByte(getProc(), macro_address+i, byte);
	end

	if( settings.profile.hotkeys.MACRO ) then
		keyboardPress(settings.profile.hotkeys.MACRO.key);
 	end
end
add this to your profile:

Code: Select all

<hotkey name="MACRO" key="VK_7" />
Then, make a macro, it MUST be on the first slot on macro window. and put it in your defined hotkey.
Image


Then, you can run RoM scripts from your path!
Usage:

Code: Select all

RoMScript("ClickRepairAllButton();");

User avatar
droppen
Posts: 179
Joined: Mon Aug 03, 2009 10:32 pm

Re: New function: RoMScript

#2 Post by droppen » Sun Aug 30, 2009 10:43 pm

Oh my gosh, the stuff you can do with this is limitless!
heres a list of functions: http://theromwiki.com/index.php/List_of_Functions


Example 1: Repairing without streamline addon:

Code: Select all

	<!-- #34 --><waypoint x="-2818" z="9295">
	player:target_NPC("Ottade");
	player:rest(2);
	RoMScript("ChoiceOption(1)");
	player:rest(2);
	RoMScript("ClickRepairAllButton();");
	</waypoint>

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

Re: New function: RoMScript

#3 Post by Administrator » Sun Aug 30, 2009 11:03 pm

Great find, but I don't think it's static. Can you describe, in detail, how you found that address?

If we can get this to work, it will, indeed, revolutionize the bot.

User avatar
droppen
Posts: 179
Joined: Mon Aug 03, 2009 10:32 pm

Re: New function: RoMScript

#4 Post by droppen » Sun Aug 30, 2009 11:25 pm

Administrator wrote:Great find, but I don't think it's static. Can you describe, in detail, how you found that address?

If we can get this to work, it will, indeed, revolutionize the bot.
I just wrote a macro that says "asdfggfsdgsdg" and searched it with cheat engine, too simple isn't it? i don't think macros are hidden in any way in the memory. i tested it by closing the bot and logging in with other accounts, and it works perfect!

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

Re: New function: RoMScript

#5 Post by Administrator » Sun Aug 30, 2009 11:40 pm

Nope, it wasn't static. But here's all the information needed:

Code: Select all

staticmacrobase_address = 0x92F8F0;
macro_offset = 0x110;

Code: Select all

local macro_address = memoryReadUInt(getProc(), staticmacrobase_address) + macro_offset;

User avatar
droppen
Posts: 179
Joined: Mon Aug 03, 2009 10:32 pm

Re: New function: RoMScript

#6 Post by droppen » Sun Aug 30, 2009 11:55 pm

Administrator wrote:Nope, it wasn't static. But here's all the information needed:

Code: Select all

staticmacrobase_address = 0x92F8F0;
macro_offset = 0x110;

Code: Select all

local macro_address = memoryReadUInt(getProc(), staticmacrobase_address) + macro_offset;
Viva la revolution! :D

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

Re: New function: RoMScript

#7 Post by Administrator » Mon Aug 31, 2009 12:14 am

A few changes have been committed to SVN. RES_MACRO and LOGOUT_MACRO have been deprecated, and now rely on this system. Also, your RoMScript() function has been fixed up a bit for better performance.

User avatar
droppen
Posts: 179
Joined: Mon Aug 03, 2009 10:32 pm

Re: New function: RoMScript

#8 Post by droppen » Mon Aug 31, 2009 12:54 am

Thanks for the upload/update! I made an improvement to the function, you can now read the return value too.

Code: Select all

--- Run rom scripts, usage: RoMScript("AcceptResurrect();");
function RoMScript(script)
	--- Get the real offset of the address
    local macro_address = memoryReadUInt(getProc(), staticmacrobase_address) + macro_offset;

	--- Macro length is max 255, and after we add the return code,
	--- we are left with 120 character limit.
	local text = "/script r='' a={} a[0],a[1],a[2],a[3],a[4] = " .. script
			.. " for i=0, 4, 1 do if a[i] then r = r..a[i]..'@' end end"
			.. " EditMacro(2,'',16,r);";

	--- Write the macro
	for i = 0, 254, 1 do
		local byte = string.byte(text, i+1);
		if byte == null then
			byte = 0;
		end
		memoryWriteByte(getProc(), macro_address+i, byte);
	end
	
	--- Execute it
	if( settings.profile.hotkeys.MACRO ) then
		keyboardPress(settings.profile.hotkeys.MACRO.key);
 	end
 	
 	--- Wait for RoM to process it, so that we can read the outcome.
 	yrest(200);
 	
 	--- Read the outcome from macro 2
	read = ""
	ret = {false, false, false, false, false, false, false, false, false, false}
	cnt = 0;
	for i = 0, 254, 1 do
		local byte = memoryReadByte(getProc(), macro_address+0x508+i);
		
		if byte > 0 then
		    if byte == 64 then -- Use @ to seperate
		        ret[cnt] = read;
		        cnt = cnt+1;
		        read = "";
			else
				read = read .. string.char(byte);
			end
		end
	end
	
	return ret[0],ret[1],ret[2],ret[3],ret[4],ret[5],ret[6],ret[7],ret[8],ret[9];
end

Usage:

Code: Select all

local bagid, icon, name, itemCount = RoMScript("GetBagItemInfo(1);");


Edit: From 5 to 10 possible return values
Last edited by droppen on Mon Aug 31, 2009 1:50 am, edited 1 time in total.

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

Re: New function: RoMScript

#9 Post by Administrator » Mon Aug 31, 2009 1:25 am

Wow, that's definitely creative. Now, I'm assuming that the 0x508 is the offset for macro slot 2?

User avatar
droppen
Posts: 179
Joined: Mon Aug 03, 2009 10:32 pm

Re: New function: RoMScript

#10 Post by droppen » Mon Aug 31, 2009 1:36 am

Administrator wrote:Wow, that's definitely creative. Now, I'm assuming that the 0x508 is the offset for macro slot 2?
Yeap! 0x508*2 is the 3rd and so on.
The macro made with micromacro makes another macro that has the return values. I would have used the first slot for the return value, but RoM crashes if I do that. Macros cant overwrite themselves.

d003232
Posts: 1252
Joined: Wed Jun 03, 2009 4:27 pm

Re: New function: RoMScript

#11 Post by d003232 » Mon Aug 31, 2009 5:26 am

Thats great! Are there also some makros we can use to accept the Qs from the blackboard? I tried it once with

Code: Select all

/script ChoiceOption(1)
but that don't seems to work?

And for the two basic macros:

Code: Select all

<hotkey name="RES_MACRO" key="VK_7" />
<hotkey name="LOGOUT_MACRO" key="VK_C" />
i was trying to send the marco line via chat like:

Code: Select all

keyboardType("\n/script AcceptResurrect();\n");
That would have the advantage to work all the time, in background and without the necessity for the user to define a macro/empty macro. I personaly would prefer that for the two basic functions even for the

Code: Select all

RoMScript("AcceptResurrect();");
solution. Because if it works without any configuration it will result in less user problem/questions in the forum.

The 'keyboardType' doesn't work because MM seems to send only lower letters. Mens if you send '/script AcceptResurrect()' it would result in '7script acceptresurrect89'. Is that a bug in MM?
The RoM Bot Online Wiki needs your help!

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

Re: New function: RoMScript

#12 Post by Administrator » Mon Aug 31, 2009 5:41 am

d003232 wrote:Thats great! Are there also some makros we can use to accept the Qs from the blackboard? I tried it once with

Code: Select all

/script ChoiceOption(1)
but that don't seems to work?
Don't include the /script part. Just:

Code: Select all

RoMScript("ChoiceOption(1)");
The 'keyboardType' doesn't work because MM seems to send only lower letters. Mens if you send '/script AcceptResurrect()' it would result in '7script acceptresurrect89'. Is that a bug in MM?
Yes, it is. Well, in part anyways. It has to do with modifiers, which is still being worked on (as you already know). Good progress has already been made.

d003232
Posts: 1252
Joined: Wed Jun 03, 2009 4:27 pm

Re: New function: RoMScript

#13 Post by d003232 » Mon Aug 31, 2009 5:45 am

Administrator wrote:
d003232 wrote:Thats great! Are there also some makros we can use to accept the Qs from the blackboard? I tried it once with

Code: Select all

/script ChoiceOption(1)
but that don't seems to work?
Don't include the /script part. Just:

Code: Select all

RoMScript("ChoiceOption(1)");
The

Code: Select all

ChoiceOption();
function seems not work at blackboard/quest NPCs. Only at normal NPC's like transporter.
The RoM Bot Online Wiki needs your help!

master121
Posts: 45
Joined: Mon Dec 29, 2008 10:40 am

Re: New function: RoMScript

#14 Post by master121 » Mon Aug 31, 2009 7:10 am

droppen you are a god for me :D
The other coders did great work with improving this function , too ;)

aasi888
Posts: 64
Joined: Fri May 15, 2009 5:13 am

Re: New function: RoMScript

#15 Post by aasi888 » Mon Aug 31, 2009 7:14 pm

Admin could you add links to this post from the RoM Bot thread. And possibly to all features that are not explained there.
Thx

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

Re: New function: RoMScript

#16 Post by Administrator » Mon Aug 31, 2009 8:28 pm

aasi888 wrote:Admin could you add links to this post from the RoM Bot thread. And possibly to all features that are not explained there.
Thx
It is unfinished right now. We are working on changing a lot of the code to use the new function (and have fixed the function multiple times). There's a lot of change coming.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 9 guests