View Single Post
  #3  
Old 08-26-2007, 02:09 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
The best way to do it would probably be to have the baddy already know the x and y of each wall tile in the area, and have precomputed paths to get around them, but that can be a pain for the scripters (though you could have a one-time function to compute and store the information). There's also Kaimetsu's checkpath function (would need to be adapted, it's for determining where a projectile would stop).

PHP Code:
function CheckPath() {
 
tx int(arg[0]); ty int(arg[1]);

 
stepx vxstepy vy;

 if (
stepx 0) {dirx = -1stepx = -stepx; }
 else 
dirx 1;
 if (
stepy 0) {diry = -1stepy = -stepy; }
 else 
diry 1;

 
tempx arg[0] - tx; if (dirx == -1tempx 1-tempx;
 
tempy arg[1] - ty; if (diry == -1tempy 1-tempy;
 
bankx stepx * (1-tempx);
 
banky stepy * (1-tempy);

 
dist 0;

 while(
true) {
  if (
bankx banky) {dist += bankxtemp 0;}
  else {
dist += bankytemp 1;}
  if (
dist mag) break;
  if (
temp == 0) {
   
banky -= bankxbankx stepx;
   
tx+=dirx;
  }
  else {
   
bankx -= bankybanky stepy;
   
ty+=diry;
  }

  if (
tx || tx 63 || ty || ty 63) break;
  if (
onwall(txty)) {
   
tx arg[0] + vx dist;
   
ty arg[1] + vy dist;
   if(
temp == 0) {tempx dirxtempy 0;}
   else {
tempx 0tempy diry;}
   
= {txtytempxtempy}; 0;
   return;
  }
 }
 
= -1;

__________________
Reply With Quote