-
Contributor
Simple Lua addon bot navigation
Hello, I'm trying to develop a simple bot-addon using protected lua functions in patch 7.1.5.
So far I've got rotations and all that jazz down and can record a set of waypoints to a table. Now, navigating to waypoints from the table is an entirely different matter, and I'm not sure how to pull this off.
I've been trying getting my distance to the x and y coordinates and using TurnLeftStart etc to change direction until my distance to the waypoint starts decreasing, but so far I get no decent results.
So I guess my question is this; using protected lua functions, how would you navigate to a series of waypoints in a simple manner?
Any help is greatly appreciated, thanks
Knowledge is often mistaken for intelligence. This is like mistaking a cup of milk for a cow.
-
-
You can calculate the yaw rotation required based off the source position (player) and destination position (waypoint) using atan2 or equivalent:
atan2(destination.Y - source.Y, destination.X - source.X)
When you have the angle you could use GetPlayerFacing() to find how much you need to turn. You turn (key-turning or TurnLeftStart etc.) the value of pi every second. You can easily find the exact amount of time to turn for.
Once you got that down you should consider adding Bezier curves so you don't have to stop, turn, then start moving after each waypoint.
-
Post Thanks / Like - 1 Thanks
Elitetech (1 members gave Thanks to Jadd for this useful post)
-
Contributor
Originally Posted by
Jadd
You can calculate the yaw rotation required based off the source position (player) and destination position (waypoint) using atan2 or equivalent:
atan2(destination.Y - source.Y, destination.X - source.X)
When you have the angle you could use GetPlayerFacing() to find how much you need to turn. You turn (key-turning or TurnLeftStart etc.) the value of pi every second. You can easily find the exact amount of time to turn for.
Once you got that down you should consider adding Bezier curves so you don't have to stop, turn, then start moving after each waypoint.
Thanks alot for the help! I was able to come up with exactly what I wanted, you're the man!
-
Post Thanks / Like - 1 Thanks
Jadd (1 members gave Thanks to Elitetech for this useful post)