Page 1 of 1

New function: RoMScript

Posted: Sun Aug 30, 2009 10:12 pm
by droppen
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();");

Re: New function: RoMScript

Posted: Sun Aug 30, 2009 10:43 pm
by droppen
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>

Re: New function: RoMScript

Posted: Sun Aug 30, 2009 11:03 pm
by Administrator
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.

Re: New function: RoMScript

Posted: Sun Aug 30, 2009 11:25 pm
by droppen
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!

Re: New function: RoMScript

Posted: Sun Aug 30, 2009 11:40 pm
by Administrator
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;

Re: New function: RoMScript

Posted: Sun Aug 30, 2009 11:55 pm
by droppen
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

Re: New function: RoMScript

Posted: Mon Aug 31, 2009 12:14 am
by Administrator
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.

Re: New function: RoMScript

Posted: Mon Aug 31, 2009 12:54 am
by droppen
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

Re: New function: RoMScript

Posted: Mon Aug 31, 2009 1:25 am
by Administrator
Wow, that's definitely creative. Now, I'm assuming that the 0x508 is the offset for macro slot 2?

Re: New function: RoMScript

Posted: Mon Aug 31, 2009 1:36 am
by droppen
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.

Re: New function: RoMScript

Posted: Mon Aug 31, 2009 5:26 am
by d003232
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?

Re: New function: RoMScript

Posted: Mon Aug 31, 2009 5:41 am
by Administrator
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.

Re: New function: RoMScript

Posted: Mon Aug 31, 2009 5:45 am
by d003232
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.

Re: New function: RoMScript

Posted: Mon Aug 31, 2009 7:10 am
by master121
droppen you are a god for me :D
The other coders did great work with improving this function , too ;)

Re: New function: RoMScript

Posted: Mon Aug 31, 2009 7:14 pm
by aasi888
Admin could you add links to this post from the RoM Bot thread. And possibly to all features that are not explained there.
Thx

Re: New function: RoMScript

Posted: Mon Aug 31, 2009 8:28 pm
by Administrator
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.