RoM Functions

From SolarStrike wiki
Revision as of 16:49, 22 January 2010 by 82.239.57.200 (talk) (Using of RoM API Functions)
Jump to: navigation, search

General Functions

     loadPaths( [path] [,returnpath] );

Load a new waypoint file and if available the default return path to that file. e.g. 'loadPaths("l7-9");' will load the waypoint path 'l7-9.xml' and if available the return path 'l7-9_return.xml'.


changeProfileOption(_option, _value);

change profile options and print values in MM protocol

levelupSkill(_skillname [, _times] )

Levelup a Single Skill by Name. For the skillname look into the file /database/skills.xml. You can use that function only for skill, which have maintent the skilltab and skillnum values within the skills.xml entry. If the don't have that values, please look yourself for them and use the manual way.

levelupSkills1To10( ["loadonly"] );

That function will levelup a internal given selection of useful skills on your way from 1-10. The selection of the skills is hard coded within functions.lua. That function will also load the skill into your profile skill list and use that skill via the MACRO function. If you restart the bot and want also want to use that skills and don't want to enter them manual into the profile skill list, then just use that function with the parameter 'loadonly' within the onLoad event:

openGiftbags1To10( [[_player_level] , _maxslot] );

open the level 1-10 giftbags and equipt the items.


addMessage( message );

Send a message to the ingame system chat channel.


RoMScript( _script );

 example:
 local ret1, ret2 = RoMScript( "GetPlayerWorldMapPos();" );

Send a macro to the client and execute it ingame by pressing the MACRO hotkey. There are up to 10 return values possible.


sendMacro( _script );

Same as "RoMScript. Additionally you will see a message in the MM window.

Player Functions

     player:harvest(["test"|id]);

Use 'player:harvest()' to scan that waypoint for a harverst node and harvest that (at the moment only working if the RoM window is in foreground). Use 'player:harvest("test")' to list id's of objects in front of you (e.g. quest objects), use 'player:harvest(id-nr)' to scan and use/open a object with that given object-id.


     player:restrnd([probability [, minrest [, maxrest]]]);

e.g. 'player:restrnd(30, 3, 10);' Rest with a probability from 30% at that waypoint for between 3 and 10 seconds. The bot will fight back if attacked while resting and continue after that. Similar functions are 'stopPE()' and 'player:sleep()'.


     player:rest( minrest [, maxrest[, time|full[, restaddrnd]]]);

minrest ( min time to rest in sec) maxrest ( max time to in sec) resttype ( time | full ) time = rest the given time | full = stop resting after being full / default = time restaddrnd ( max random addition after being full in sec)

If using type 'full', the bot will only rest if HP or MP is below a defined level. You define that level in your profile with the options: Code:

     <option name="HP_REST" value="15" />
     <option name="MP_REST" value="15" />

Default value if not defined is 15% each.

     examples:
     player:rest(20) will rest for 20 seconds.
     player:rest(60, 20) will rest between 60 and 80 seconds.
     player:rest(90, 40, "full") will rest up to between 90 and 130 seconds, and stop resting if being full
     player:rest(90, 40, "time") will rest up to between 90 and 130 seconds, and not stop resting if being full
     player:rest(20, 40, "full, 20") will rest up to between 20 and 60 seconds, and stop resting if being full, and wait after that between 1-20 seconds


     player:sleep();

Pause the bot at that waypoint in a sleep mode. The bot will still fight back attackers and sleep again after doing that. Press DEL if you want to continue. Similar functions are 'player.restrnd()' and 'stopPE()'.


     player:logout([true]);

Logout from RoM. With 'player:logout(true)' you will also shutdown your pc after loging out.


     player:mouseclickL(x, y [RoM window wide, RoM window high]);

Left click a screen point and by that, interact with a NPC. x, y is relative to the RoM window. So it is your fiddly task to find the right values to click the right buttons. Remember the RoM windows size for that click positions. By doing that, we can later recalculate the mouse click points if we run the bot in a different RoM windows size.

Inventory and Item Functions

inventory:getItemCount(itemId)
examples:
if( inventory:getItemCount(214536) > 25 ) then
   loadPaths("deliver_quest");
end

Get the quantity for a item directly from the games client.

inventory:itemTotalCount(itemNameOrId)

Get the quantity for a item from the cached inventory. You have to be sure, that your inventory is up to date to get the right values. You can use the item-id or the name of the item

inventory:useItem(itemNameOrId)

Use a item from the cached inventory.

inventory:update()

Update the whole inventory from the games client. Depending from you slots, that takes about 10-15 seconds. Nevertheless from using that function, the bot updates the whole inventory at the bot starting time and about 3-4 slots after every fight and about 10-15 slots while the bot is looting.

By default the bot updates slot 1-60. If you want to use more slots please use the profile option

<option name="INV_MAX_SLOTS"	value="120" />	

Use the option

<option name="INV_MAX_SLOTS"	value="0" />	

if you want to deactivate the inventory update.

Waypoint File Functions

__WPL:reverse();

Resort the waypoints. Means after running from 1 to 20 you can now run from 20 - 1. It is usefull to put that at the first and at the last waypoint if you want to run between two places.


__WPL:setWaypointIndex( number);

Set the waypoint # 'number' as next waypoint to reach


__WPL:getNearestWaypoint(player.X, player.Z);

Get back the number of the closest waypoint.


__WPL:setForcedWaypointType( [["NORMAL"] | ["TRAVEL"] | ["RUN"]]);

Set a forced waypoint type. The waypoint type overwrites the type settings within the waypoint file. The forced waypoint type is valid until you load a new waypoint file or you call the function '__WPL:setForcedWaypointType();' without argument.

RoM API Functions

With the function sendMacro() or RoMScript() we can submit macros to the RoM API. For a complete list of RoM API functions, go to http://theromwiki.com/index.php/List_of_Functions

Here are some important API functions you can use:

sendMacro("SetSpellPoint( 4, 2 );");

Levelup a skill. First number is the tab (1=general, 2=general class skills, 4=only primary class skills). Second number is the number of the skill at the tab. You can test the numbers by entering following macro ingame:

/script _SkillName=GetSkillDetail(4,3); SendSystemChat(_SkillName);
That will print you the name of the given skill into the ingame system chat.


/script SendSystemChat(tonumber(string.sub(GetBagItemLink(GetBagItemInfo(1)), 8, 12), 16));

Print the itemid of slot-nr 1 into the system chat. Change the slot number to the item you want to get informations about or move that item to slot #1.


sendMacro("GetBagItemCount("..itemid..")")

Get back the quantity of an givem item ID in your bags.


occupiedSlots, totalSlots = sendMacro("GetBagCount();");

Get back the number of total slots in your bag and the number of the occupied slot in your bag.