Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Object Movement (https://forums.graalonline.com/forums/showthread.php?t=72812)

Chandler 03-13-2007 11:36 PM

Object Movement
 
HTML Code:

function beginMovement()
  {
  this.getPosition();
  temp.movePosition = {
    (this.currentLocation[1] - this.x),
    (this.currentLocation[2] - this.y)
  };
  this.dir = getdir(temp.movePosition[0], temp.movePosition[1]);
  this.ani = "walk";
  temp.moveDirs = {
    {1, {1.7, 1}}, {0, {-1.7, 1}}, {2, {1.7, -1.7}}, {3, {-1.7, -1.7}}
  };
  this.chat = "Moving towards" SPC this.currentLocation[0] @"!";
 
  for (temp.currentDirection: temp.moveDirs)
    if (this.dir == temp.currentDirection[0])
      for (temp.newAmount: temp.currentDirection[1])
        temp.moveAmount.add(temp.newAmount); 
  move((temp.movePosition[0] + temp.moveAmount[0]), (temp.movePosition[1] + temp.moveAmount[1]), 1, 8+16);
  }
function getPosition()
  {
  temp.randomLocation = int(random(0, this.warpLocations.size()));
  temp.newLocation = this.warpLocations[temp.randomLocation];
  if (temp.newLocation[0] != this.currentLocation[0])
    this.currentLocation = temp.newLocation;
  else
    this.getPosition();
  }
function onMovementFinished()
  this.ani = "idle";

Well, it is supposed to run through levels. I've tried adding
PHP Code:

  this.canwarp();
  
this.canwarp2(); 

Neither seem to solve this! Any solutions?

contiga 03-14-2007 02:24 PM

Is it serverside or clientside?
And "canWarp();" should make it able to follow links.

Chandler 03-14-2007 08:40 PM

Serverside, doesn't seem to work I'm afraid :[

napo_p2p 03-14-2007 09:45 PM

Is it a level NPC, or a DB/putnpc2?

Chandler 03-14-2007 09:59 PM

Database

Admins 03-14-2007 10:34 PM

It should work if you do canwarp() and eventually also setshape() or showcharacter() so that the npc has a size and it can correctly check if the npc covers a link area

Chandler 03-15-2007 12:02 AM

Still nothing.
Era:
The script of NPC c_airShop has been updated by Chandler

Chandler 03-18-2007 05:29 PM

Anyone? Thanks

contiga 03-18-2007 08:12 PM

I'm not sure, but maybe make it join a class that handles the movement, tho I don't think it will make any difference, it's just how we done it on 2k1.

Chandler 03-19-2007 08:05 PM

Make the movement in a class?

napo_p2p 03-19-2007 08:44 PM

It looks like it should work to me as long as it's a DB-NPC and you've set a shape and have the gmap in serveroptions and the level list. (Keep canwarp() in there too). The only problems I have ever had with something like this is that sometimes the npc takes a while to update its position for the client.

Chandler 03-19-2007 08:58 PM

Quote:

Originally Posted by napo_p2p (Post 1290619)
It looks like it should work to me as long as it's a DB-NPC and you've set a shape and have the gmap in serveroptions and the level list. (Keep canwarp() in there too). The only problems I have ever had with something like this is that sometimes the npc takes a while to update its position for the client.

Even though move is being controlled over levels? [If you get this]


All times are GMT +2. The time now is 05:13 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.