View Single Post
  #6  
Old 08-16-2013, 03:07 AM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by i8bit View Post
Can you give me an example of using the move() function?
using scripthelp:
TServerNPC.move(float, float, float, int) - moves the npc smoothly, parameters are delta x, delta y, time and options: cache type (0, 1-cache, 2-append) + blockcheck(4) + eventwhendone(8) + applydir(16)

example:
PHP Code:
function onCreated() {
  
this.image "block.png";
  
this.this.30;
  echo(
"Starting to move...");
    
//Move NPC by 2 tiles in the x, 2 tiles in the y within 0.5 secs
    //While the last parameter is 8 (check description above script example)
    //The event 'onMovementFinished()' will be called
  
move(220.58);
}
function 
onMovementFinished() {
  echo(
"Done moving!");

With some maths you can tweak around the delta x/y and have it move around the player easy.


Ps: This move example replaced something like this which does lag more on the server
PHP Code:
function onCreated() {
  
this.image "block.png";
  
this.this.30;
  echo(
"Starting to move...");
  
temp.time = (0.05/0.5); //steps divided by the time it should take
  
for (temp.i=0;temp.i<2;temp.i+=temp.time) {
    
this.+= temp.time;
    
this.+= temp.time;
  }
  echo(
"Done moving!");

__________________
MEEP!
Reply With Quote