Thread: NPC baddy
View Single Post
  #2  
Old 01-04-2007, 06:48 AM
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
I'm trying to do some movement...not working.
How do you use move(), and am I using the scripts right...and wil this make it easier to attack the baddy?
PHP Code:
  if(this.mode==1)
  {
    
setcharani("walk",NULL);
    if(!
onwall(x+1+vecx(dir)*this.speed,y+1.5+vecy(dir)*this.speed))
    {
      
x=x+1+vecx(dir)*this.speed;
      
y=y+1.5+vecy(dir)*this.speed;
    }
    if(
abs(player.x-x)>abs(player.y-y))
    {
      
//direction should be 1 or 3
      
if(player.x>x)
      {
        
dir 3;
      }
      else
      {
        
dir 1;
      }
    }
    else
    {
      
//direction is 0 or 2
      
if(player.y>y)
      {
        
dir 2;
      }
      else
      {
        
dir 0;
      }
    }
    if((
abs(player.x-x)^2+abs(player.y-y)^2)^.5<=3)
    {

      if(
this.hit==1)
      {
        
setcharani("sword",NULL);
        
this.hit 0;
        
setTimer(.45);
      }
      else
      {
        
this.hit 1;
        
setTimer(random(.05,.3));
      }
    }
    else
    {
      
setTimer(.05);
    }
  } 
Reply With Quote