_WPL:reverse(); does not work

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
filipsworks
Posts: 53
Joined: Mon May 10, 2010 10:37 am

_WPL:reverse(); does not work

#1 Post by filipsworks » Fri May 28, 2010 12:51 pm

Code: Select all

<!-- #  1 --><waypoint x="31630" z="2716"> __WPL:reverse(); </waypoint>
...
<!-- #350 --><waypoint x="27923" z="6789"> __WPL:reverse(); </waypoint>
When #350 is reached then bot try to go to (as he say) #1 point with coords x=0 y=0 (#1 is 31630;2716). Dunno what's wrong here...

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

Re: _WPL:reverse(); does not work

#2 Post by Administrator » Fri May 28, 2010 6:20 pm

Yeah, looks like this became a problem with one of the recent changes to the waypoint system. I had to re-order the advance, getNextWaypoint, and waypoint action code to correct another bug, but it looks like it only caused this.

Well, it's been "fixed" to a somewhat workable way. Be aware, though, that reversing like that will cause problems and there is nothing that can be done about it. The problem is that you can't guarantee that you will start at any specific waypoint or be going a specific direction. Basically, what I'm saying is, you reverse() on waypoint #1. What happens if you start nearest to waypoint #1? You'd reverse, heading to the last waypoint, which reverses to the first waypoint, which... you get the point.

Instead, you might consider checking if you're going the right direction first.

Code: Select all

if( __WPL.Direction == WPT_BACKWARD ) then
  __WPL:reverse(); -- Start going forward again.
end
There's another function, __WPL:setDirection(dir) (accepts WPT_FORWARD or WPT_BACKWARD), but this might need to be fixed as well (basically, to just do the above code).

filipsworks
Posts: 53
Joined: Mon May 10, 2010 10:37 am

Re: _WPL:reverse(); does not work

#3 Post by filipsworks » Sun May 30, 2010 2:15 am

Administrator wrote: There's another function, __WPL:setDirection(dir) (accepts WPT_FORWARD or WPT_BACKWARD), but this might need to be fixed as well (basically, to just do the above code).
Using __WPL:setDirection(WPT_BACKWARD); gives the same (no)result:/

Now only solution what I saw is use of that VBS:

Code: Select all

 Const ForReading = 1
 Const ForWriting = 2

 Dim arrLines()
 i = 0

 Set objFSO = CreateObject("Scripting.FileSystemObject")
 Set objFile = objFSO.OpenTextFile("c:\micromacro\scripts\rom\waypoints\pełnaścierzkadopliku.xml", ForReading)

 Do Until objFile.AtEndOfStream
     Redim Preserve arrLines(i)
     arrLines(i) = objFile.ReadLine
     i = i + 1
 Loop

 objFile.Close

 Set objFile = objFSO.OpenTextFile("c:\micromacro\scripts\rom\waypoints\pełnaścierzkadopliku_reversed.xml", ForWriting)

 For i = Ubound(arrLines) to LBound(arrLines) Step -1
     objFile.WriteLine arrLines(i)
 Next

 objFile.Close
correct of xml declaration and general <waypoints> </waypoints> tags and use of loadPaths("path_reversed.xml"); function :/

None of WP-reverse functions from Wiki works:/

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

Re: _WPL:reverse(); does not work

#4 Post by Administrator » Sun May 30, 2010 5:24 am

Try using __WPL:reverse() just for testing. Does that work or not (excluding the problem I mentioned before)?

Wundervice
Posts: 30
Joined: Fri Mar 12, 2010 6:40 pm

Re: _WPL:reverse(); does not work

#5 Post by Wundervice » Tue Jun 01, 2010 2:39 am

i actually came looking for an answer to this. I can verify that the standard methods of reversing DO NOT work. Im not even sure the workaround does (but i haven't confirmed).

jurafxp
Posts: 10
Joined: Fri Apr 30, 2010 4:08 am

Re: _WPL:reverse(); does not work

#6 Post by jurafxp » Wed Jun 02, 2010 3:30 am

i am using this:

Code: Select all

<!-- #  1 --><waypoint x="123" z="123">__WPL:reverse();__WPL:setWaypointIndex(2); </waypoint>
...
<!-- # 69 --><waypoint x="456" z="456">__WPL:reverse();__WPL:setWaypointIndex(68); </waypoint>

filipsworks
Posts: 53
Joined: Mon May 10, 2010 10:37 am

Re: _WPL:reverse(); does not work

#7 Post by filipsworks » Thu Jun 03, 2010 1:12 am

jurafxp wrote:i am using this:

Code: Select all

<!-- #  1 --><waypoint x="123" z="123">__WPL:reverse();__WPL:setWaypointIndex(2); </waypoint>
...
<!-- # 69 --><waypoint x="456" z="456">__WPL:reverse();__WPL:setWaypointIndex(68); </waypoint>
Good I see? __WPL:reverse(); have to be called 2 times (#69 call __WPL:reverse(); > then go to 68 (next will be 69) > __WPL:reverse(); ?)

What exacly is "__WPL:setWaypointIndex(68);"?

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: _WPL:reverse(); does not work

#8 Post by rock5 » Thu Jun 03, 2010 2:23 am

I had a look at _WPL:Reverse() and found what the problem was. It had checks when changing to backwards but no checks when changing to forward. I just applied the same checks for both directions and now it works perfectly.

To manually fix it while waiting for dev implements this fix, change the following.

In waypointlist.lua find the reverse function;

Code: Select all

-- Reverse your current direction
function CWaypointList:reverse()
	if( self.Direction == WPT_FORWARD ) then
		self.Direction = WPT_BACKWARD;
		self.CurrentWaypoint = self.CurrentWaypoint - 1;
		if( self.CurrentWaypoint <= 0 ) then
			self.CurrentWaypoint = #self.Waypoints - 1;
		end
	else
		self.Direction = WPT_FORWARD;
	end;
end
Change to match the following. Note you are only adding the 4 lines above the last 2 "end"s.

Code: Select all

-- Reverse your current direction
function CWaypointList:reverse()
	if( self.Direction == WPT_FORWARD ) then
		self.Direction = WPT_BACKWARD;
		self.CurrentWaypoint = self.CurrentWaypoint - 1;
		if( self.CurrentWaypoint <= 0 ) then
			self.CurrentWaypoint = #self.Waypoints - 1;
		end
	else
		self.Direction = WPT_FORWARD;
		self.CurrentWaypoint = self.CurrentWaypoint + 1;
		if( self.CurrentWaypoint >= #self.Waypoints ) then
			self.CurrentWaypoint = 2;
		end
	end;
end
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

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

Re: _WPL:reverse(); does not work

#9 Post by Administrator » Thu Jun 03, 2010 4:33 am

Thanks. I'll include it with the next commit.

I still think setDirection() might be broken and need to be changed to this:

Code: Select all

function CWaypointList:setDirection(wpt)
  if( wpt ~= WPT_FORWARD and wpt ~= WPT_BACKWARD ) then
    return; -- do nothing, invalid input
  end

  if( wpt ~= self.Direction ) then
    self:reverse();
  end
end
Is someone able to help me test this?

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: _WPL:reverse(); does not work

#10 Post by rock5 » Thu Jun 03, 2010 5:48 am

Administrator wrote:Is someone able to help me test this?
I can confirm that setdirection wasn't working.

With my fix to reverse and your fix to setdirection they are both working correctly.

Although I could never see the point of reverse. Setdirection should be all you need.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: _WPL:reverse(); does not work

#11 Post by rock5 » Sun Jun 06, 2010 7:57 am

I noticed you still haven't committed these changes. In the mean time I've been thinking. We have them back-to-front.

setdirection uses reverse but I think it should be reverse that uses setdirection. Makes more sense to me. So I changed them around and tested them, the code is below. They both work correctly. If you agree with me, feel free to add to next commit. Otherwise use the fixes above.

Code: Select all

-- Sets the "direction" (forward/backward) to travel
function CWaypointList:setDirection(wpt)
	-- Ignore invalid types
	if( wpt ~= WPT_FORWARD and wpt ~= WPT_BACKWARD ) then
		return;
	end;

	if( wpt ~= self.Direction ) then
		self.Direction = wpt
		if( wpt == WPT_BACKWARD ) then
			self.CurrentWaypoint = self.CurrentWaypoint - 1;
			if( self.CurrentWaypoint <= 0 ) then
				self.CurrentWaypoint = #self.Waypoints - 1;
			end
		else
			self.CurrentWaypoint = self.CurrentWaypoint + 1;
			if( self.CurrentWaypoint >= #self.Waypoints ) then
				self.CurrentWaypoint = 2;
			end
		end;
	end
end

-- Reverse your current direction
function CWaypointList:reverse()
	if( self.Direction == WPT_FORWARD ) then
		self:setDirection(WPT_BACKWARD);
	else
		self:setDirection(WPT_FORWARD);
	end;
end
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

filipsworks
Posts: 53
Joined: Mon May 10, 2010 10:37 am

Re: _WPL:reverse(); does not work

#12 Post by filipsworks » Tue Jun 08, 2010 12:35 am

rock5 wrote:I noticed you still haven't committed these changes. In the mean time I've been thinking. We have them back-to-front.

setdirection uses reverse but I think it should be reverse that uses setdirection. Makes more sense to me. So I changed them around and tested them, the code is below. They both work correctly. If you agree with me, feel free to add to next commit. Otherwise use the fixes above.
Confirmed - Works

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 22 guests