moving a set distance

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
ZZZZZ
Posts: 513
Joined: Sun Oct 21, 2012 1:42 am

moving a set distance

#1 Post by ZZZZZ »

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 :)
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: moving a set distance

#2 Post by rock5 »

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
User avatar
Administrator
Site Admin
Posts: 5344
Joined: Sat Jan 05, 2008 4:21 pm

Re: moving a set distance

#3 Post by Administrator »

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

Re: moving a set distance

#4 Post by rock5 »

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
Post Reply