moving a set distance
moving a set distance
Say you have a waypoint at point A, and your character is standing at point B, how would you go about moving 200 distance towards A from B? I figured you can use 'local playerX, playerY, playerZ = player.X, player.Y, player.Z' to get the current position but i'm not sure how to go about moving 200 distance towards A from that location. Any help would be great 
Re: moving a set distance
Well there is a function player:moveInRange(target,range,ignoreCycleTargets) but it works with range to target not range from start. But you could get the distance to the target and then minus 200 from it to give you the range to target. Eg.
Code: Select all
dist = distance(targetWP,player)
range = dist - 200
player:moveInRange(targetWP, range, true)- 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
- Administrator
- Site Admin
- Posts: 5344
- Joined: Sat Jan 05, 2008 4:21 pm
Re: moving a set distance
You can use some simple trigonometry to get a point based on distance and angle.
Code: Select all
local tx, ty;
local angle = math.ytan2(B.y - A.y, B.x - A.x);
local dist = 200;
tx = math.sin(angle)*dist;
ty = math.cos(angle)*dist;
Re: moving a set distance
I was trying to avoid that. Doing those annoys me. So i used a function that already does it. I guess both solutions should be similar.
- 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