View Single Post
  #4  
Old 08-22-2006, 10:50 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Okay, using the "hearts" variable now, so I can use hitobjects()
Still doesn't work well.
It might have something to do with the timeout, but I don't want to slow it down too much =(
PHP Code:

//#CLIENTSIDE
function onCreated()
{
  
this.direct=2;
  
setimg("dr_baddy_spider.png");
  
setshape(1,32,32);
  
hearts=int(random(15,25));
  
onTimeout();
}
function 
onPlayertouchsme()
{
  
setani("hurt",NULL);
  
triggeraction(0,0,"serverside","-System","hurt","secure",1);
}
function 
onTimeout()
{
  
chat=hearts;
  
this.hp=hearts;
  if(
hearts==&& this.hp==0)
  {
    
this.dead=1;
    
hide();
    
triggeraction(0,0,"serverside","-System","exp",1,"secure");
    
sleep(random(10,15));
    
this.dead=0;
    
onCreated();
  }  
  if(
this.dead==0)
  {
    if(
this.walk==0)
    {
      
this.shoot=1;
      
this.walk=int(random(20,40));
    }
    else
    {
      
this.walk--;
      if(
abs(x-player.x)>=abs(y-player.y))
      {
        if(
player.x<x)
        {
          
this.direct=1;
        }
        if(
player.x>=x)
        {
          
this.direct=3;
        }
      }
      else if(
abs(x-player.x)<abs(y-player.y))
      {
        if(
player.y>y)
        {
          
this.direct=2;
        }
        if(
playery<=y)
        {
          
this.direct=0;
        }
      }  
      if(
player.x+.5<x)
      {
        if(!
onwall(x-.2,y) && !onwall(x-.2,y+2))
        {
          
x-=.2;
        }
      }
      else if(
player.x+.5>=x)
      {
        if(!
onwall(x+2.2,y) && !onwall(x+2.2,y+2))
        {
          
x+=.2;
        }
      }
      if(
player.y+1<y)
      {
        if(!
onwall(x,y-.2) && !onwall(x+2,y-.2))
        {
          
y-=.2;
        }
      }
      else if(
player.y+1>=y)
      {
        if(!
onwall(x,y+.2) && !onwall(x+2,y+.2))
        {
          
y+=.2;
        }
      }
      if(
int(this.walk/2)<(this.walk/2))
      {  
        if(
this.direct==0)
        {
          
setimgpart("dr_baddy_spider",0,0,32,32);
        }
        if(
this.direct==1)
        {
          
setimgpart("dr_baddy_spider",32,0,32,32);
        }
        if(
this.direct==2)
        {
          
setimgpart("dr_baddy_spider",64,0,32,32);
        }
        if(
this.direct==3)
        {
          
setimgpart("dr_baddy_spider",96,0,32,32);
        }  
      }
      else
      {
        if(
this.direct==0)
        {
          
setimgpart("dr_baddy_spider",0,32,32,32);
        }
        if(
this.direct==1)
        {
          
setimgpart("dr_baddy_spider",32,32,32,32);
        }
        if(
this.direct==2)
        {
          
setimgpart("dr_baddy_spider",64,32,32,32);
        }
        if(
this.direct==3)
        {
          
setimgpart("dr_baddy_spider",96,32,32,32);
        } 
      }
      if(
abs(x-player.x) <  && abs(y-player.y) < 1
      {
        
triggeraction(0,0,"serverside","-System","hurt","secure",1);
        
setani("hurt",NULL);
      }
    }
    if(
this.shoot==1)
    {
      if(
this.direct==0)
      {
        
sleep(.1);
        
shootball();  
        
this.shoot=0;
      }
      if(
this.direct==1)
      {
        
setimgpart("dr_baddy_spider.png",32,64,32,32);
        
sleep(.1);
        
setimgpart("dr_baddy_spider.png",32,96,32,32); 
        
shootball();  
        
this.shoot=0;
      }
      if(
this.direct==2)
      {
        
setimgpart("dr_baddy_spider.png",64,64,32,32);
        
sleep(.1);
        
setimgpart("dr_baddy_spider.png",0,64,32,32); 
        
shootball();  
        
this.shoot=0;
      }
      if(
this.direct==3)
      {
        
setimgpart("dr_baddy_spider.png",96,64,32,32);
        
sleep(.1);
        
setimgpart("dr_baddy_spider.png",96,96,32,32); 
        
shootball();  
        
this.shoot=0;
      }
    }
  }
  
setTimer(.05);

Reply With Quote