RoM Working with waypoint files

From SolarStrike wiki
Jump to: navigation, search

Here some examples how to work with waypoint files. It shows examples for different types of waypoint files and some special solutions.


LUA code within a waypoint file

You can use you own lua code within the <waypoint></waypoint> tags. By doing that you can do nearly everything. And there are some prefabricated functions:

To use some of that functions, simply put them into the waypoint tag:
<!-- #20 --><waypoint x="799" z="-426">player:restrnd(20, 1, 10);</waypoint>

Caution!!! You must place the codes within the '<waypoint></waypoint>' tag. Not before and not after.

This is wrong:

<waypoints type="TRAVEL" >player:harvest();
	<!-- # 1 --><waypoint x="-2060" z="-8216"></waypoint>
</waypoints>

List of functions

player:harvest();
Scan that waypoint for a harverst node and harvest that (at the moment only working if the RoM window is in foreground)
load_paths( [path] [,returnpath] );
Load a new waypoint file and if available the default return path to that file. e.g. 'load_paths("l7-9");' will load the waypoint path 'l7-9.xml' and if available the return path 'l7-9_return.xml'.
if( player.Level > 9 ) then
	printf("do some other coding stuff");
end;
Do something only if you have a given level. Can be usefull to load a new waypoint file only after you get that level.
__WPL:reverse();
Resort the waypoints. Means after running from 1 to 20 you can now run from 20 - 1. It is strongly recommended to use '__WPL:setDirection(..)' instead of this function.


__WPL:setDirection( [WPT_FORWARD | WPT_BACKWARD] );
Set the direction in which order the waypoints should be proccessed. It is usefull to put that at the first and at the last waypoint if you want to run between two places. Remember to use WPT_FORWARD at the first and WPT_BACKWARD at the last waypoint to run between them. Use this instead of '__WPL:reverse()' to avoid problems in your waypoint file.


__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.
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:
<option name="HP_REST" value="15" />
<option name="MP_REST" value="15" />

Default value if not defined is 15% each.

e.g. 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


stopPE();
Pause the bot at that waypoint. The bot will not react anymore. Press DEL if you want to resume the bot. Similar functions are 'player.restrnd()' and 'player.sleep()'.
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.
if( os.difftime(os.time(), player.BotStartTime) > 3600 ) then
	printf("do some other coding stuff");
end;
Do something, if the bot is running for more then 1 hour (= 3600 seconds). If you pause the bot, the BotStartTime will be reseted.
player:target_NPC( [npc_name] );
It will try to target the NPC 'npc_name' and open the dialog window. If it is a merchant and you have a ingame autorepair addon (e.g. Streamline), it will autorepair.
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.
__WPL:getFileName();
Returns the name of the waypoint file as string (e.g. "l1t_start.xml"). The string will not contain any information about the path of the file.

How to use the bot for running between the and NPC <-> blackboard for delivering of daily quests

It starts in Harf. There you have the quest 'Winterspinnenarten' from the blackboard where you deliver 10 winter spider body liquids to the 'Lager im Winternachttal'.

The waypoints are from the blackbard in Harf up to the camp. After each end of the waypoint file is a PAUSE. So you can handle with the NPC/blackboard and after that press 'DEL' to reverse the waypoints and run back.
<waypoints type="RUN">
	<!-- # 1 --><waypoint x="-14389" z="-380" type="TRAVEL">__WPL:setDirection( WPT_FORWARD );
	player:sleep();</waypoint>
	<!-- # 2 --><waypoint x="-14531" z="-253"></waypoint>
	...
	<!-- #21 --><waypoint x="-18500" z="-2516 type="TRAVEL" >__WPL:setDirection( WPT_BACKWARD );
	player:sleep();
	</waypoint>
</waypoints>

The type of the waypoints is 'RUN' so the bot will not stop and not fight back, if getting aggro. Only the first an the last WP has type TRAVEL to fight back still sticking mobs.

Some hints: If you deliver the quest with a low level char, than set your loot option (<option name="LOOT" value="true" />) in your profile to 'false'. That will prevent from coming closer to mob groups while looting. It also could be helpful, to reduce your option 'WAYPOINT_DEVIATION' or set it to 0 (and set back to a higher value for normal botting).

Automatic leveling with the Bot

Thats an example how to start with level 1 and change the botting place depending from your level.

We start at the spawn point:
<waypoints type="TRAVEL" >
	<!-- # 3 --><waypoint x="-3779" z="-8480"></waypoint>
	...
	<!-- # 8 --><waypoint x="-3034" z="-9034">load_paths("l2-3.xml");</waypoint>
</waypoints>
At the last waypoint, we load the waypoint path file 'l2-3.xml' and if available the default returnpath 'l2-3_return.xml" and go to the closest waypoint from that waypoint file. We use waypoint type TRAVEL to not targeting mobs while moving to our area (not really neccessary here :-) )

Now we are at that place:

<waypoints type="NORMAL" >
	<!-- # 1 --><waypoint x="-2206" z="-9648"></waypoint>
	<!-- # 2 --><waypoint x="-2133" z="-9796">player:restrnd(20, 1, 10);</waypoint>
	<!-- # 3 --><waypoint x="-2224" z="-9882">player:restrnd(20, 1, 10);</waypoint>
	...
	<!-- # 7 --><waypoint x="-2391" z="-9639">
		if( player.Level > 4 ) then
			load_paths("l5_goto_6.xml");
	  	end;
	</waypoint>
</waypoints>

If we reach level 5, we load the next waypoint file. Read here for more Informations about automatic leveling

Read here for further informations about autorepair.