All of this is clientside
PHP Code:
///////////////////Movement//////////////////////
function followPlayer(){
pet.dir = player.dir;
if(pet.level.name != player.level.name){
if(!inPrefix(player.level.name) && pet.lvlBlock.index(player.level.name)==-1){
warpto((player.gmap.name == NULL) ? player.level.name : player.gmap.name,player.x+(vecx(player.dir))%64,player.y+(vecy(player.dir))%64);
pet.dir = player.dir;
storeLocation();
return(null);
}else{
pet.state = STAY;
return(null);
}
}
moveTo(player.x+(vecx(player.dir)*-1),player.y+(vecy(player.dir)*-1));
}
function moveTo(lx,ly){
temp.dx = int(pet.x - temp.lx);
temp.dy = int(pet.y - temp.ly);
if(temp.dx in |0, pet.walkSpeed|){
if(temp.dy in |0, pet.walkSpeed|){
setcharani("okiepet_idle",null);
return(null);
}
}
setcharani("okiepet_walk",null);
temp.nx = pet.x;
temp.ny = pet.y;
if(temp.dx != 0){
if(temp.dx > 0){
temp.nx -= 1*(pet.walkSpeed);
}else{
temp.nx += 1*(pet.walkSpeed);
}
}
if(temp.dy != 0){
if(temp.dy > 0){
temp.ny -= 1*(pet.walkSpeed);
}else{
temp.ny += 1*(pet.walkSpeed);
}
}
pet.dir = getdir(-temp.dx,-temp.dy);
temp.e = .0002;//.0002 is the error value between a tile and pos
temp.e2 = this.e*2;
if(!onwall2(temp.nx+pet.atx,temp.ny+pet.aty,pet.wv,pet.hv)){
pet.x = temp.nx;
pet.y = temp.ny;
}else if(!onwall2(temp.nx+pet.atx,pet.y+pet.aty,pet.wv,pet.hv)){
pet.x = temp.nx;
}else if(!onwall2(this.x+pet.atx,temp.ny+pet.aty,pet.wv,pet.hv)){
pet.y = temp.ny;
}
//need to handle water
}
////////////////////End Movement////////////////////