View Single Post
  #7  
Old 06-06-2009, 07:14 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by thatdwarf View Post
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//////////////////// 
Hm, you only replaced part of it with player.gmap.name

You I was mostly talking about the if statement.

PHP Code:
///////////////////Movement//////////////////////

function getObjectLevel(obj) {
  if (
obj.gmap.name != NULL) {
    return 
obj.gmap;
  }else
    return 
obj.level;
}

function 
followPlayer(){
  
pet.dir player.dir;
  
  
temp.petlevel getObjectLevel(pet);
  
temp.playerlevel getObjectLevel(player);

  if (
temp.petlevel.name != temp.petlevel.name){
    if(!
inPrefix(temp.playerlevel.name) && pet.lvlBlock.index(temp.playerlevel.name)==-1){
      
warpto(temp.playerlevel.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//////////////////// 
Maybe something like that would work. If not, try
PHP Code:
      warpto(player.level.name,player.x+(vecx(player.dir))%64,player.y+(vecy(player.dir))%64); 
instead.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote