View Single Post
  #6  
Old 06-06-2009, 07:05 AM
thatdwarf thatdwarf is offline
Former UN Dev Admin
Join Date: Nov 2005
Posts: 42
thatdwarf is on a distinguished road
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.temp.lx);
  
temp.dy int(pet.temp.ly);
 
  if(
temp.dx in |0pet.walkSpeed|){
    if(
temp.dy in |0pet.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..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.temp.nx;
    
pet.temp.ny;
  }else if(!
onwall2(temp.nx+pet.atx,pet.y+pet.aty,pet.wv,pet.hv)){
    
pet.temp.nx;
  }else if(!
onwall2(this.x+pet.atx,temp.ny+pet.aty,pet.wv,pet.hv)){
    
pet.temp.ny;
  }
 
//need to handle water
}
////////////////////End Movement//////////////////// 
Reply With Quote