View Single Post
  #26  
Old 01-06-2011, 03:28 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
Quote:
Originally Posted by fowlplay4 View Post
move doesn't work like that.

TServerNPC.move(float, float, float, int)
- moves the npc smoothly
- parameters:
delta x,
delta y,
time
options: cache type (0, 1-cache, 2-append) + blockcheck(4) + eventwhendone(8) + applydir(16)

move(dx, dy, time, flags);

I.e:

PHP Code:
//#CLIENTSIDE
function moveTo(tx, ty) {
  
// Delta = Final - Initial
  
temp.dx = tx - this.x;
  
temp.dy = ty - this.y;
  
temp.speed = 1; // Tiles per second
  
temp.time = getDistance(this.x, this.y, tx, ty) / temp.speed;
  
move(temp.dx, temp.dy, temp.time, 8); 
}

function 
onMovementFinished() {
  
// Your other code..
}

function 
GetDistance(temp.x1, temp.y1, temp.x2, temp.y2) {
  
temp.toreturn = (temp.x2 - temp.x1) ^ 2 + (temp.y2 - temp.y1) ^ 2;
  return (
temp.toreturn) ^ .5;
} 
hmm.. interesting i should have looked up syntax earlier lol.. i thought i was doing it strange.. but still would i do similar to how i posted before because of using move() wrong without the check if movement ended.. ?
Reply With Quote