Not for copying and pasting, it's more to give you an idea of some of the things you'll need.
PHP Code:
function onCreated(){
//set vars
this.respawnpos = {this.x, this.y};
setTimer(0.05);
}
function onTimeout(){
doMovement();
setTimer(0.05);
}
function doMovement(){
if (this.hp > 0){
//do checks to see if a player is in the baddies aggro radius
//then
//do movement
}
}
function onActionWa****(){
if (! (this.hp <= 0)){
this.hp -= 0.5;
} else doDead();
}
function doDead(){
//set animation to dead and add exp if thats what you're doing
scheduleevent(2, "Respawn", null);
}
function onRespawn(){
//set x and y to where you want it to respawn at each time
this.x = this.respawnpos[0];
this.y = this.respawnpos[1];
this.hp = this.maxhp;
}