Execute code before first waypoint - requesting explanation

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
Nero
Posts: 98
Joined: Wed Aug 10, 2011 9:07 am

Execute code before first waypoint - requesting explanation

#1 Post by Nero »

Hello.

I've found myself in need of a waypoint that will execute some code without it going to the first waypoint. I've seen a few files that do it (for example, CoT with teleport, it checks for zone_id without going to the first WP) but I have no idea how they work. It should work regardless of class, zone_id or any other variable in this case.

So, let's start with something simple - suppose that I want to check whether I have more than 50 of item with ID 100000, and if I do, it should use 'recall', otherwise it should load waypoint file 'less than 50 items'.

Code for executing it in a waypoint would look like that

Code: Select all

		   local questitem = inventory:getItemCount(100000) -- item ID
			if  questitem >  49  	then		-- checks if at least 50
				RoMScript('CastSpellByName("Recall Transport Spell")')	-- not sure if correct name
			  else
				loadPaths("less than 50 items");	
  	    end
Now that I wrote it, I don't know how to cast recall via romscript... Using heffner teleport is here
http://solarstrike.net/phpBB3/viewtopic ... a97#p28641
but it's a different name that the one in-game - I've pretty much made-up the name in that code.


So, how do I do this?
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Execute code before first waypoint - requesting explanat

#2 Post by lisa »

using recall is

Code: Select all

sendMacro("UseSkill(1,2);");
a more advanced version would check if recall is on cooldown or not.

Code: Select all

										local cooldown, remaining = sendMacro("GetSkillCooldown(1,2);")
										if remaining > 1 then -- recall is on cooldown
							
											RoMScript("Logout();"); --just logged out instead
											error("Recall was on cooldown, so logged out.")	
										else
											player:update()
											local X = player.X
											local Z = player.Z
											repeat
												sendMacro("UseSkill(1,2);");
												yrest(1000)
												player:update()
											until memoryReadBytePtr(getProc(), addresses.loadingScreenPtr, addresses.loadingScreen_offset) ~= 0 or 
											distance(player.X, player.Z, X, Z) > 100 or 
											keyPressedLocal(settings.hotkeys.START_BOT.key)
										end
to make code be done before the first set of coords you just use onLoad tags

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
<onload>
--somecode
</onload>
<!-- #  1 --><waypoint
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Post Reply