Time-Function

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
mattstar81
Posts: 42
Joined: Tue Feb 02, 2016 5:14 pm

Time-Function

#1 Post by mattstar81 » Wed Feb 16, 2022 8:05 am

Hello :D
Is it possible to add a time function? that the bot e.g. go to an npc after 60 min ?

how could something like this look like ?

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

Re: Time-Function

#2 Post by Administrator » Fri Feb 18, 2022 5:08 pm

You can probably handle that with a bit of trickery in your waypoints. For example, something like this:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<waypoints>
	<!-- Put this at the top of your waypoints script -->
	<onLoad><![CDATA[
	last_npc_visit = os.time()
	visit_npc_minutes = 60
	
	function reset_last_npc_visit()
		last_npc_visit = os.time()		
	end
	
	function should_visit_npc()
		if( (os.time() - last_npc_visit)/60 > visit_npc_minutes ) then
			return true
		else
			return false
		end
	end
	]]></onLoad>
</waypoints>

	<!-- Put your actual waypoints here. For example: -->
	<!-- # 1 --><waypoint ...></waypoint>
	<!-- # 2 --><waypoint ...></waypoint>
	<!-- # 3 --><waypoint ...></waypoint>

	<!-- At the last waypoint in your loop (or whichever waypoint you want to use), we can check if it's time to go back to NPC -->
	<waypoint ...>
		if( should_visit_npc() ) then
			reset_last_npc_visit()
			loadPath("path_to_npc_and_back")
		end
	</waypoint>
Then create your path (path_to_npc_and_back) which travels to the NPC, does whatever you need to do, then walks back.
Then your path_to_npc_and_back waypoints could look something like this:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<waypoints>
	<!-- # 1 --><waypoint ...></waypoint> <!-- Example, Walking to the NPC -->
	<!-- # 2 --><waypoint ...></waypoint> <!-- Example, Interact with the NPC -->
	<!-- # 3 --><waypoint ...></waypoint> <!-- Example, Walk back from NPC -->

	<!-- At the last waypoint, reload your original waypoints-->
	<waypoint ...>
		loadPath("original_waypoints")
	</waypoint>

mattstar81
Posts: 42
Joined: Tue Feb 02, 2016 5:14 pm

Re: Time-Function

#3 Post by mattstar81 » Sun Feb 20, 2022 5:03 am

thank you very much, I'll have to try that right away :D

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 36 guests