use nearest waypoint when stuck
-
- Posts: 73
- Joined: Mon Aug 16, 2010 12:50 pm
use nearest waypoint when stuck
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?
is it possible to make my bot run to the nearest waypoint when he is stuck and cant get to his next waypoint?
Re: use nearest waypoint when stuck
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
Re: use nearest waypoint when stuck
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.
I couldn't find anything in bot.lua about it going nearest wp at 3.
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
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
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: use nearest waypoint when stuck
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?
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
Re: use nearest waypoint when stuck
hmm i show line 738 as being this
My bot.lua doesn't even go up to line 2000, it ends at line 897.
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
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
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
-
- Posts: 73
- Joined: Mon Aug 16, 2010 12:50 pm
Re: use nearest waypoint when stuck
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
i'll give this code a try when i'm back from office.
thanks guys
Re: use nearest waypoint when stuck
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.lisa wrote:My bot.lua doesn't even go up to line 2000, it ends at line 897.
- 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
Re: use nearest waypoint when stuck
Ahh now I see where you are.
ok so in classes/player.lua line 2002 I added this.
it is directly after
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
At both the first waypoint down bottom and also at the first waypoint I want to actually use. Then at last waypoint add.
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.
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;
Code: Select all
function CPlayer:unstick()
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);
Code: Select all
__WPL:setDirection(WPT_BACKWARD);
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
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: use nearest waypoint when stuck
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.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 aAt 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_FORWARD);
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.Code: Select all
__WPL:setDirection(WPT_BACKWARD);
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
Re: use nearest waypoint when stuck
Ok I'll use 2 examples
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.
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.
Hope this helps
Code: Select all
7 6 5 4 3 2 1
8
9 10 11 12 13
20 14
19 18 17 16 15
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
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>
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
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: use nearest waypoint when stuck
thank you for explaining that for me. yes it did help.lisa wrote: Hope this helps
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
Re: use nearest waypoint when stuck
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
If you fell off cliff and your current coords were
It might say you were closer to the waypoint up at y="224" and try to move to it.
example
Code: Select all
<waypoint x="-3758" z="-8499" y="224">
<waypoint x="-3600" z="-8300" y="130">
Code: Select all
x="-3740" z="-8470" y="130"
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
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: use nearest waypoint when stuck
Instead of those __WPL:setDirection(WPT_FORWARD); at the bottom of the cliff you could just uselisa 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>
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
Re: use nearest waypoint when stuck
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?
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
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: use nearest waypoint when stuck
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.It might be an idea to just add it to getNearestWaypoint.
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
- 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
Re: use nearest waypoint when stuck
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)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.It might be an idea to just add it to getNearestWaypoint.Code: Select all
-- Check height difference if( math.abs(target.Y - player.Y) > 45 ) then return false; end
look in screenshot
Re: use nearest waypoint when stuck
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
Re: use nearest waypoint when stuck
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
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 1 guest