use nearest waypoint when stuck

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
Personalausweis
Posts: 73
Joined: Mon Aug 16, 2010 12:50 pm

use nearest waypoint when stuck

#1 Post by Personalausweis » Mon Jan 31, 2011 2:34 am

hi there,

is it possible to make my bot run to the nearest waypoint when he is stuck and cant get to his next waypoint?

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

Re: use nearest waypoint when stuck

#2 Post by rock5 » Mon Jan 31, 2011 3:01 am

I think it already does that, around the 3rd unstick.
  • 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
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: use nearest waypoint when stuck

#3 Post by lisa » Mon Jan 31, 2011 3:07 am

It would involve changing the bot.lua but yes it is possible.

As it is it gets to the unstuck count of 11 which is greater then the value set by default as 10 and then logs out.

You could add in at say unstuck count of 5 to then go to nearest WP.

You could add something like this at around line 737, it's untested but should work.

Code: Select all

if player.Unstick_counter == 5 then
__WPL:setWaypointIndex(__WPL:getNearestWaypoint(player.X, player.Z, player.Y));
end
I couldn't find anything in bot.lua about it going nearest wp at 3.
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

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

Re: use nearest waypoint when stuck

#4 Post by rock5 » Mon Jan 31, 2011 6:11 am

When they said they couldn't go to the next waypoint I thought they wanted to go to the previous waypoint. I see the benefit now of going to the 'nearest' waypoint.

Line 737? The unstick function is around line 2000. Shouldn't that go in about line 2011?
  • 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
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: use nearest waypoint when stuck

#5 Post by lisa » Mon Jan 31, 2011 6:35 am

hmm i show line 738 as being this

Code: Select all

					-- Too many tries, logout
					if( settings.profile.options.MAX_UNSTICK_TRIALS > 0 and
						player.Unstick_counter > settings.profile.options.MAX_UNSTICK_TRIALS ) then
						cprintf(cli.yellow, language[55],
						  player.Unstick_counter,
						  settings.profile.options.MAX_UNSTICK_TRIALS );	-- max unstick reached
My bot.lua doesn't even go up to line 2000, it ends at line 897.
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

Personalausweis
Posts: 73
Joined: Mon Aug 16, 2010 12:50 pm

Re: use nearest waypoint when stuck

#6 Post by Personalausweis » Mon Jan 31, 2011 6:56 am

yaeh, problem with my bot is that he farms near a cave and sometime he fell down und then tries to go to to his waypoint on the upper level. would be perfect if he goes to the nearest waypoint (on the lower level) when he cant reach his last waypoint three or four times.

i'll give this code a try when i'm back from office. :)

thanks guys

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

Re: use nearest waypoint when stuck

#7 Post by rock5 » Mon Jan 31, 2011 8:00 am

lisa wrote:My bot.lua doesn't even go up to line 2000, it ends at line 897.
Ah, I went directly to the unstick function which is part of the player class. I didn't realize you were talking about bot.lua. It would probably work at both locations but I'd probably put it with the other "if( self.Unstick_counter == " conditions.
  • 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
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: use nearest waypoint when stuck

#8 Post by lisa » Mon Jan 31, 2011 9:19 am

Ahh now I see where you are.

ok so in classes/player.lua line 2002 I added this.

Code: Select all

-- after 1x unsuccesfull unsticks try to reach nearest waypoint
	if( self.Unstick_counter == 2 ) then
	__WPL:setWaypointIndex(__WPL:getNearestWaypoint(player.X, player.Z, player.Y));
	end;
it is directly after

Code: Select all

function CPlayer:unstick()
If you don't see lines you can just do a search.

So if you fall off a cliff it should do one unstick and then go to nearest waypoint, aslong as nearest waypoint is the one at your current height. I like this idea as I do some farming near cliffes aswell.

I'm going to make a waypoint run along the bottom of the cliff edge and then run it back up. Add in a

Code: Select all

__WPL:setDirection(WPT_FORWARD);
At both the first waypoint down bottom and also at the first waypoint I want to actually use. Then at last waypoint add.

Code: Select all

__WPL:setDirection(WPT_BACKWARD);
So it will go back and forth between the waypoints I want and if falls off cliff it will just walk back up and continue.

Hope that helps you Personalausweis.
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

kx9488
Posts: 60
Joined: Wed Jan 26, 2011 6:27 pm

Re: use nearest waypoint when stuck

#9 Post by kx9488 » Mon Feb 07, 2011 9:04 pm

lisa wrote: I'm going to make a waypoint run along the bottom of the cliff edge and then run it back up. Add in a

Code: Select all

__WPL:setDirection(WPT_FORWARD);
At both the first waypoint down bottom and also at the first waypoint I want to actually use. Then at last waypoint add.

Code: Select all

__WPL:setDirection(WPT_BACKWARD);
So it will go back and forth between the waypoints I want and if falls off cliff it will just walk back up and continue.
this is going to sound stupid, but how would this look in a waypoint file? i understand you added in the first part to the player.lua file.. i've done that.
but how would this look in the waypoint file, i'm not sure where you're putting these.

this would help me a great deal. often times my farmer goes into unstick player trials for no reason and jumps off of hillsides and cliffs. i have a string of waypoints at the bottom as part of the farming path but my char humps the hillside instead of moving on and skipping the next 5-10 waypoints to the bottom of the hill near where he fell.

ty
Image

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: use nearest waypoint when stuck

#10 Post by lisa » Mon Feb 07, 2011 9:40 pm

Ok I'll use 2 examples

Code: Select all

             7 6 5 4 3 2 1
             8
             9 10 11 12 13
            20           14
            19 18 17 16 15
In this example 9 - 20 are the farm waypoint that the bot will loop and basically ignore 1-8 the majority of the time. If you fall off the cliff at say 12 you will land near 3. So after the unsticks you then start from waypoint 3 and it will walk up to 9 and continue on as normal. This wouldn't require any more coding.
At most you might need a tag at waypoint 9 and have waypoint 20 tell the bot to go to that tag.


Code: Select all

	7 6 5 4 3 2 1
	8
	9 10 11 12 13
		          14
		          15
	  19 18 17 16
This example doesn't have a loop but what you can do is have some code to make it work. Farm area is 9 - 19 & 19 - 9, 1-8 is the walk back up.

Code: Select all

	<!-- #  1 --><waypoint x="XXXX" z="XXXX" y="XXX">	__WPL:setDirection(WPT_FORWARD); </waypoint>

Code: Select all

	<!-- #  9 --><waypoint x="XXXX" z="XXXX" y="XXX">	__WPL:setDirection(WPT_FORWARD); </waypoint>

Code: Select all

	<!-- #  19 --><waypoint x="XXXX" z="XXXX" y="XXX"> __WPL:setDirection(WPT_BACKWARD); </waypoint>
Hope this helps
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

kx9488
Posts: 60
Joined: Wed Jan 26, 2011 6:27 pm

Re: use nearest waypoint when stuck

#11 Post by kx9488 » Mon Feb 07, 2011 10:00 pm

lisa wrote: Hope this helps
thank you for explaining that for me. yes it did help.

so basically the additional code only pushes the char up the lower waypoints if it finds itself down there, in my case i actually wouldn't need them in a couple areas, because i farm them.

is rombot sapposed to skip to close waypoints already? before i added the code u made for the player.lua i have fallen close to part of my waypoint farm path like you have illustrated in your scenarios and i just try to climb the wall and unstick reaches 10, and my char never turns around to the waypoint behind him.
other times i have been at the bottom of the path and the mob or unstick made me run too close to the foot of the hillside/cliff and i have gotten stuck trying to run up because forwhatever reason it has skipped the wrong way.
it would be pretty much the same scenario as if i was farming at waypoint 9 in your second diagram, and the waypoint skipped to #20.

this doesn't happen enough to say it wont again with this code, but my hopes are high.

thank you
Image

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: use nearest waypoint when stuck

#12 Post by lisa » Mon Feb 07, 2011 11:01 pm

I would run a set of waypoints along the bottom edge of the cliff, if your walk up coords arn't right where you fall down then it may not tell the bot to use them instead.


example

Code: Select all

<waypoint x="-3758" z="-8499" y="224">
<waypoint x="-3600" z="-8300" y="130">
If you fell off cliff and your current coords were

Code: Select all

x="-3740" z="-8470" y="130"
It might say you were closer to the waypoint up at y="224" and try to move to it.
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

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

Re: use nearest waypoint when stuck

#13 Post by rock5 » Tue Feb 08, 2011 1:03 am

lisa wrote:

Code: Select all

	<!-- #  1 --><waypoint x="XXXX" z="XXXX" y="XXX">	__WPL:setDirection(WPT_FORWARD); </waypoint>

Code: Select all

	<!-- #  9 --><waypoint x="XXXX" z="XXXX" y="XXX">	__WPL:setDirection(WPT_FORWARD); </waypoint>

Code: Select all

	<!-- #  19 --><waypoint x="XXXX" z="XXXX" y="XXX"> __WPL:setDirection(WPT_BACKWARD); </waypoint>
Instead of those __WPL:setDirection(WPT_FORWARD); at the bottom of the cliff you could just use

Code: Select all

   <onUnstickFailure><![CDATA[
      __WPL:setDirection(WPT_FORWARD);
      then whatever the command is to goto nearest waypoint
   ]]></onUnstickFailure>
  • 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
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: use nearest waypoint when stuck

#14 Post by lisa » Tue Feb 08, 2011 1:14 am

True but the event only occurs when max unsticks is reached. We set up the code earlier for after 3 unsticks to go to nearest waypoint, trouble is that the "nearest" waypoint isn't always the one you want. You want the way point that can be walked to as in not up a cliff face. So even with going to nearest waypoint after 10 unsticks it would still try to walk up the cliff face.

I'm thinking need to put in a calculation for the y value, so it goes to nearest waypoint but only checks waypoints within a range of the current y position of character.
So for y within a range of +- 50 then nearest waypoint within that range.

What you think?
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

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

Re: use nearest waypoint when stuck

#15 Post by rock5 » Tue Feb 08, 2011 2:18 am

getNearestWaypoint does use the 'y' value. That was one of the main reasons I added them. As long as you mark enough points along the bottom of the cliff it should work. Of course if you are using an old waypoint file with only x and z values you would have to redo it.

A height check wouldn't be a bad idea though. evalTargetDefault uses one.

Code: Select all

	-- Check height difference
	if( math.abs(target.Y - player.Y) > 45 ) then
		return false;
	end
It might be an idea to just add it to getNearestWaypoint.
  • 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

j19861986
Posts: 37
Joined: Sun Jan 16, 2011 1:01 am

Re: use nearest waypoint when stuck

#16 Post by j19861986 » Thu Apr 07, 2011 10:31 am

rock5 wrote:getNearestWaypoint does use the 'y' value. That was one of the main reasons I added them. As long as you mark enough points along the bottom of the cliff it should work. Of course if you are using an old waypoint file with only x and z values you would have to redo it.

A height check wouldn't be a bad idea though. evalTargetDefault uses one.

Code: Select all

	-- Check height difference
	if( math.abs(target.Y - player.Y) > 45 ) then
		return false;
	end
It might be an idea to just add it to getNearestWaypoint.
I am really interested in that... but I got an error saying "Wrong value returned in update of item id 520003 and attempt to index global 'target' (a nil value)

look in screenshot
Attachments
Please help me with unsticking correctly
Please help me with unsticking correctly

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

Re: use nearest waypoint when stuck

#17 Post by rock5 » Thu Apr 07, 2011 7:12 pm

Maybe you didn't do it right. It should look like this, I think.

Code: Select all

-- Returns an index to the waypoint closest to the given point.
function CWaypointList:getNearestWaypoint(_x, _z, _y)
	local closest = 1;

	for i,v in pairs(self.Waypoints) do
		local oldClosestWp = self.Waypoints[closest];

		if( distance(_x, _z, _y, v.X, v.Z, v.Y) < distance(_x, _z, _y, oldClosestWp.X, oldClosestWp.Z, oldClosestWp.Y) ) and
			 ( math.abs(_y - v.Y) < 45 ) then
			closest = i;
		end
	end

	return closest;
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
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: use nearest waypoint when stuck

#18 Post by rock5 » Sat Apr 09, 2011 9:02 pm

I been thinking about this and it's not a good solution. For starters, if a waypoint is below you, you should still be able to go to it. And what if you have a waypoint at the top of a ramp? It could be more that 45 above you but it should still be valid. I think what we need is an angle check instead. Something like, if the waypoint is more than about 45 degrees above you skip it. What do you think?
  • 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

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Semrush [Bot] and 0 guests