possible to edit class function from within waypoint onLoad section? Yes it is!

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

possible to edit class function from within waypoint onLoad section? Yes it is!

#1 Post by noobbotter » Tue Mar 29, 2016 10:29 am

Is it possible to change a function in a waypoint onLoad section which is normally loaded through one of the "class" lua files? For example, I'm curious if it's possible for one specific waypoint file I'm making to add something to happen after every waypoint location prior to moving to the next waypoint, without having to add the function in at every waypoint. In the waypointlist.lua file there is this function:

Code: Select all

function CWaypointList:advance()
	self.LastWaypoint = self.CurrentWaypoint
	if( self.Direction == WPT_FORWARD ) then
		self.CurrentWaypoint = self.CurrentWaypoint + 1;
		if( self.CurrentWaypoint > #self.Waypoints ) then
			self.CurrentWaypoint = 1;
		end
	else
		self.CurrentWaypoint = self.CurrentWaypoint - 1;
		if( self.CurrentWaypoint < 1 ) then
			self.CurrentWaypoint = #self.Waypoints;
		end
	end
end
Is there a way that I can edit that function from my onLoad section, sort of like the way you can change the profile.settings.onLeaveCombat function from within the onLoad section? That way it is only different for this specific waypoint file?
Last edited by noobbotter on Wed Mar 30, 2016 7:12 am, edited 1 time in total.

noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

Re: possible to edit class function from within waypoint onLoad section?

#2 Post by noobbotter » Wed Mar 30, 2016 7:09 am

Last night I figured out how to do what I was wanting to do. So basically, I took that previously posted section from the waypoints.lua file, and in my onload section, I add this version of that function:

Code: Select all

function CWaypointList:advance()
	findChests() -- I added this function which is defined in my onLoad section
	__WPL.LastWaypoint = __WPL.CurrentWaypoint -- and then changed all references of "self" to "__WPL""
	if( __WPL.Direction == WPT_FORWARD ) then
		__WPL.CurrentWaypoint = __WPL.CurrentWaypoint + 1;
		if( __WPL.CurrentWaypoint > #__WPL.Waypoints ) then
			__WPL.CurrentWaypoint = 1;
		end
	else
		__WPL.CurrentWaypoint = __WPL.CurrentWaypoint - 1;
		if( __WPL.CurrentWaypoint < 1 ) then
			__WPL.CurrentWaypoint = #__WPL.Waypoints;
		end
	end
end
So now what that allows me to do is define anything I want to do at every waypoint without going in and typing my function into every waypoint, such as mirrorworld search for and open chests. BTW, I have that part written as well but of course, couldn't test it yesterday. I tested it using harvest nodes and it works. I have it where it will look for a nearby chest after combat, and after every waypoint. Also, when it sees a chest, it will save current player location, go get the chest, then go back to player location prior to moving on, that will help prevent it from moving off waypoint path to kill a mob, then see a chest to open, and end up with an obstacle between player and waypoint path. This would help minimize that. I will put it into a mirrorworld instance waypoint and test it next time one is open.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: possible to edit class function from within waypoint onLoad section? Yes it is!

#3 Post by beanybabe » Wed Mar 30, 2016 8:03 am

I found those chests all over behind and around sides of things. I was worried about getting stuck and thought it be best to do the hunt for chests on the way out. Interesting idea you have its a bit over my head but I kind of understand it.

noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

Re: possible to edit class function from within waypoint onLoad section? Yes it is!

#4 Post by noobbotter » Wed Mar 30, 2016 8:34 am

Pretty much all the chests tend to be along the perimeter walls. I was thinking of getting the chests while going through and killing mobs, that way, if they patch it and create an exit near the boss, then you wouldn't have to modify the code later.

I'm thinking of modifying my findChests() function... Maybe add use of a variable for how close the chest has to be in order to go get it. Then at different sections of the waypoint, depending on how open or tight the area is, you can increase or decrease the search range for chests. I don't know if those will be open again this weekend or not but if it is, I'll see what I can do with it. Once I get one built, I'll share it and then others can help build any other instances they want.

leroy
Posts: 19
Joined: Thu Sep 19, 2013 11:57 am

Re: possible to edit class function from within waypoint onLoad section? Yes it is!

#5 Post by leroy » Fri Apr 08, 2016 3:47 pm

Function in onload:

Code: Select all

function getChest(dist)
	local chest = player:findNearestNameOrId(104529)
	if chest and dist > distance(chest,player) then
		player:target_NPC(104529) -- Mysterious Chest
		yrest(2000);
		player:target_NPC(104529) -- Mysterious Chest
		yrest(500);
	end
end
And use in waypoint with getChest(100) (or any number that best for the specific waypoint line).
And yes it means I have to put them in every line a chest might be close but some MW instances are just too bad with chest placing, u cant just "search the room".
If the chest is in a remote place i use player:moveTo(CWaypoint(x,y,z)) after the getChest() to move back to waypoint location, so like:

Code: Select all

<!-- # 1 --><waypoint x="100" z="200" y="300">
	getChest(200)
	player:moveTo(CWaypoint(100,200,300))
</waypoint>
It will take some runs to find all the possible chest locations :)

While on MW subject, does anyone know how to enter the instance using bot? So how to "click" the minimap button and Transport button?

dr-nuker
Posts: 145
Joined: Sun Oct 09, 2011 7:33 am

Re: possible to edit class function from within waypoint onLoad section? Yes it is!

#6 Post by dr-nuker » Sun Apr 10, 2016 5:36 am

I can recommend to check for distance and do a teleport if the chest is not too far away.
Before teleport save your position as local and teleport back once you opended the chest.

Does not always work but it's okay ;)

noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

Re: possible to edit class function from within waypoint onLoad section? Yes it is!

#7 Post by noobbotter » Sun Apr 10, 2016 6:56 am

Using teleport opens you up for GMs catching you. I'd recommend not using teleport. That's why I did it the way I did.

Post Reply

Who is online

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