here is a very basic script for clientside NPC movement.
NPC Code:
//#CLIENTSIDE
function onCreated()
{
showcharacter();
headimg = "head.png";
bodyimg = "body.png";
swordimg = "sword1.png";
shieldimg = "shield1.png";
this.speed = 0.5;
setTimer(0.1);
}
function onTimeout()
{
setcharani("walk", NULL);
for(pl: players) {
this.dir = getdir(pl.x - this.x, pl.y - this.y);
this.angle = getangle(pl.x - this.x, pl.y - this.y);
this.x = this.x + (cos(this.angle) * this.speed);
this.y = this.y - (sin(this.angle) * this.speed);
}
setTimer(0.05);
}
and to make it serverside its basically the same exact thing.
NPC Code:
function onCreated()
{
showcharacter();
headimg = "head.png";
bodyimg = "body.png";
swordimg = "sword1.png";
shieldimg = "shield1.png";
this.speed = 0.5;
setTimer(0.1);
}
function onTimeout()
{
setcharani("walk", NULL);
for(pl: players) {
this.dir = getdir(pl.x - this.x, pl.y - this.y);
this.angle = getangle(pl.x - this.x, pl.y - this.y);
x = this.x + (cos(this.angle) * this.speed);
y = this.y - (sin(this.angle) * this.speed);
}
setTimer(0.05);
}