Page 1 of 1
Questions re waypointlist and other stuff
Posted: Tue Jul 24, 2012 4:10 am
by Jandrana
Just working on a script to do the butterfly dailies. To make the script behave like a real player, it needs to do different things depending on which part of the waypoint list the char currently is. I was looking for a way to determine the current waypoint index in my code, but didn't find anything. Currently I've extended the waypointlist.lua this way:
Code: Select all
function CWaypointList:getWaypointIndex()
return self.CurrentWaypoint;
end
Did I miss a something to do this any other way? If not, could you add this new function in the next release?
---
Second question:
In the player profile there is an section to define code when leaving combat:
<onLeaveCombat><![CDATA[
-- Additional Lua code to execute after killing an enemy
]]></onLeaveCombat>
I tried to use this section in my waypoint script too. But currently without success. Adding code for a specific script to onLeaveCombat in the profile file, is not a viable solution.
What I like to do: if the char is on the way from quest giver to the laby and is being attacked, it should kill the mob. After leaving combat, it should mount it's horse again. Currently I've added a function at each waypoint that checks if being mounted, but this is crude and not like I wanted it to be. Any comments how to do this?
Re: Questions re waypointlist and other stuff
Posted: Tue Jul 24, 2012 4:30 am
by Jandrana
Maybe I found a solution for my 2nd question myself.
Overriding the onLeaveCombat function this way:
Code: Select all
settings.profile.events.onLeaveCombat = function()
-- do something
end
Correct me, if I'm wrong.
Re: Questions re waypointlist and other stuff
Posted: Tue Jul 24, 2012 5:02 am
by lisa
Code: Select all
local wpoint = CWaypointList();
print(wpoint.CurrentWaypoint)
that will print the current waypoint number you are on in the file.
Things you can use are
Code: Select all
Radius:
OrigX:
Type:
ForcedType:
ExcludeZones: table
CurrentWaypoint:
LastWaypoint:
Waypoints: table
KillZone: table
Mode:
Direction:
OrigZ:
and yes
Code: Select all
settings.profile.events.onLeaveCombat = function()
-- do something
end
will override any onleavecombat code in your profile.
Re: Questions re waypointlist and other stuff
Posted: Tue Jul 24, 2012 5:42 am
by lisa
actually it is already defined in functions.lua
is all you need.
Re: Questions re waypointlist and other stuff
Posted: Wed Jul 25, 2012 1:33 pm
by rock5
lisa wrote:actually it is already defined in functions.lua
is all you need.
I was about to say.
I word about
__WPL.CurrentWaypoint. When you are walking to a waypoint, the one you are walking to is the currentwaypoint. When you reach the waypoint and start to execute any code there, currentwaypoint is now the next waypoint. The waypoint you are currently at will be
__WPL.LastWaypoint.
Re: Questions re waypointlist and other stuff
Posted: Thu Jul 26, 2012 6:16 am
by Jandrana
I word about __WPL.CurrentWaypoint. When you are walking to a waypoint, the one you are walking to is the currentwaypoint. When you reach the waypoint and start to execute any code there, currentwaypoint is now the next waypoint. The waypoint you are currently at will be __WPL.LastWaypoint.
Thanks for this! Maybe this explains some oddness in my butterfly script. Will change to __WPL.LastWaypoint and see if it gets better.
Another thing:
I changed the onLeaveCombat function to my needs and I'd like to do two things after leaving combat:
1.) loot dead mobs
2.) mount horse
Currently my onLeaveCombat only mounts a horse, because I expected looting being done by the bot. But the loot code done by the bot happens after calling onLeaveCombat function. In my case this causes my char to dismount.
Is it safe to call "player:loot()" or "player:lootAll" in onLeaveCombat, or will this cause trouble with the loot code done by the bot?
Re: Questions re waypointlist and other stuff
Posted: Thu Jul 26, 2012 6:37 am
by rock5
Both should work I think.
Re: Questions re waypointlist and other stuff
Posted: Fri Jul 27, 2012 7:04 am
by Jandrana
I have two issues with my butterfly script and I'm looking for hints and solutions:
First thing is a general thing, how the bot processes waypoints. If the bot should kill and loot mobs, it moves away from the defined waypoints. There is a logic to determine the closest waypoint and so the bot will try to walk a new route to the next waypoint. This way it can happen, that the char will get stuck somewhere, because an obstacle prevents reaching the closest waypoint from the current position. Currently there is internal logic to unstuck the player and logout if this does not work after 10 tries.
I would suggest two things here:
- when determining the next closest waypoint, the Z difference should be used to determine the slope between the current char position and the next waypoint. If the slope exceeds a certain value, the bot should use a "backtrack" list (see next point).
- the bot should maintain a queue with the last 2-3 visited waypoints - (may be also add dynamic positions - like the position where you had looted, killed the last mob).
First thing should prevent, that the bot tries to run against ascending slopes several times (which looks quite bottish). The backtrack list should prevent, that the bot gets stuck. If the backtrack list leads the character back to a position that is assigned to a waypoint, the bot should be able to recover (if the waypoints are not bullshit).
----
The second thing is a strange thing, that happens in my butterfly script. The first part of this script is plain list of waypoints from the quest NPC to the labyrinth, where the butterflies spawn. In ~9 out of 10 runs, everthing is ok. But sometimes it happens, that the bot gets stuck, because he misses on of the portals or falls off the ramp at the end of the first gangway. In the MM windows he prints the correct waypoint, but my assumption is, that internally he is calculating a route to the next but one waypoint. Any ideas, how this can happen? Better, how to prevent this?
Re: Questions re waypointlist and other stuff
Posted: Fri Jul 27, 2012 8:02 am
by lisa
The bot doesn't keep track of your locations as you travel, if it did there would be 1000's of stored coords every minute, that is why we create our own set of coords to follow with the waypoint files.
Jandrana wrote: the Z difference should be used to determine the slope between the current char position and the next waypoint. If the slope exceeds a certain value, .
Issue is that not everyone follows the rules of not being able to go directly up (flying or wall climbing), I know I have done it in a few of my waypoints so to make it default bot behaviour to not go in a direction would be limiting.
I will attach my leacher WP for butterflies, I am sure it is posted elsewhere but I'm not going to look for it.
If you want it to kill then just add in more sets of coords for the killing part.
Another thing you might appreciate is that the default bot has inbuilt into it adaptability for people to do their own unstick codes at 3,6,9 unstick tries.
Just create a function with the name
unStick3()
unStick6()
unStick9()
and those functions will be performed at the unstick tries of 3,6,9.
You can create 1,all or none of them, it's up to you.
Re: Questions re waypointlist and other stuff
Posted: Fri Jul 27, 2012 8:49 am
by Jandrana
The bot doesn't keep track of your locations as you travel, if it did there would be 1000's of stored coords every minute
If it is done a smart way, it should be no problem. I would only add locations to a queue, if you had moved a certain distance. Of course the queue should have a limit - as I wrote: may be only ~3.
to make it default bot behavior to not go in a direction would be limiting.
There could be an option to disable it, if you like to do things like swimhack or similar.
If you want it to kill then just add in more sets of coords for the killing part.
As I wrote, my butterfly bot works 90% of the time. Maybe I should add more waypoints for the route from quest NPC to the butterfly spawn location, which could reduce the problem getting stuck on this route.
Thanks for your comments and pointing me to the unstick() functions. Perhaps I will try to modify the bot code myself and include my ideas and see if there is any improvement.
Re: Questions re waypointlist and other stuff
Posted: Fri Jul 27, 2012 9:01 am
by lisa
Jandrana wrote:I would only add locations to a queue, if you had moved a certain distance. Of course the queue should have a limit - as I wrote: may be only ~3.
The bot is updating player coords very very very often, that is why I said 1000's per minute, it constantly does distance checks to many things and each time it updates the player coords. Moving to a waypoint or fighting mobs
the coords are updated constantly.
Jandrana wrote:Perhaps I will try to modify the bot code myself and include my ideas and see if there is any improvement.
You are welcome to try, just keep in mind what might work really well for one WP might be really bad for others

Re: Questions re waypointlist and other stuff
Posted: Fri Jul 27, 2012 9:28 am
by rock5
lisa wrote:Jandrana wrote:I would only add locations to a queue, if you had moved a certain distance. Of course the queue should have a limit - as I wrote: may be only ~3.
The bot is updating player coords very very very often, that is why I said 1000's per minute, it constantly does distance checks to many things and each time it updates the player coords. Moving to a waypoint or fighting mobs
the coords are updated constantly.
Actually, to be able to back track all you would need to do is record the coords of the destination of each moveTo. So between 2 waypoints you might attack a couple of mobs and it would record the coords it moved to to engage in combat with them. Then if it gets stuck it could backtrack to those 2 positions then back to the last waypoint. Then go forward from there. Problems with this are; you could also end up moving during combat so you would have to take that into account, if this is not the first thing that is tried you might be out of position to backtrack, if you attacked a lot of mobs between waypoints going back a few steps might not put you in a position to get to the nearest waypoint anyway.
Probably the best solution is to just use an unstick function and decide the best steps to take to get back on track, although I would be surprised if most of the time it doesn't already manage it on it's own.
Re: Questions re waypointlist and other stuff
Posted: Sun Jul 29, 2012 3:25 am
by Jandrana
I have discovered the reason, why my butterfly script gets stuck sometimes. This happens when you are entering combat. The bot prints "waiting for aggressive" enemies. During this time (1-2s maybe), the bot does not check if a new waypoint has been reached, but the char continues to move. So it can happen, that you leave the waypoint path on a "critical" point, which can lead to stuck problems.
Any ideas how to avoid, maybe fix it?
Re: Questions re waypointlist and other stuff
Posted: Sun Jul 29, 2012 3:52 am
by lisa
Jandrana wrote:The bot prints "waiting for aggressive" enemies.
That means something has attacked you first, so you were probably not trying to kill it yourself, so it is not within the profile settings that you want to kill or you have waypoint type as RUN.
Change waypoint type to travel and just keep going, ignoring the mob.
Re: Questions re waypointlist and other stuff
Posted: Mon Jul 30, 2012 3:19 am
by Jandrana
Thanks, Lisa.
Yes, I had waypoint type "RUN".
I never thought, that waypoint processing is affected by this. I consider this as a bug. Maybe it is not possible to do it differently, but still.
I switched to type "TRAVEL" now, and the first 10 daily runs worked without getting stuck. Sad it has to be this way, because I'd like to collect some dog meat on the way. But at least it seems to work now without getting stuck.
Re: Questions re waypointlist and other stuff
Posted: Mon Jul 30, 2012 3:44 am
by lisa
The issue is just for that area, you get an aoe damage from the mobs near the black orb things and it puts you in combat even though they arn't attacking you.
So you could make it travel for going past them and then make it normal when at the straight section where dogs are.