Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-21-2006, 09:19 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
Custom baddies and custom hp

Basically, I have one, apparently very powerfull, baddy. I can't damage it.
Here's some parts of the scritps used for attacking it, it's mostly triggeractions, but AI can't find out what's failing, since it's all going through
First, the action triggered by punching:
PHP Code:
triggeraction(player.x+1+vecx(player.dir)*2.1,player.y+1.5+vecy(player.dir)*2.1,"hurt","hurt",clientr.attack); 
This is received by the baddy:

PHP Code:
function onActionhurt()
{
  if(
params[0]=="hurt")
  {
      
this.hp-=params[1];
      
chat=this.hp;
      
triggeraction(x,y,"hp","hp",this.hp);
      if(
this.hp<=0)
      {
        
this.hp=int(random(15,25));
        
triggeraction(0,0,"serverside","-System","exp",1,"secure");
        
hide();
        
settimer(random(10,20));
      } 
  }
}

function 
onCreated()
{
  
setshape(1,32,32);
  
this.hp=int(random(15,25));

Which triggers the client of the baddy, for the hp variable to exist on clientside as well:

PHP Code:
function onActionhp()
{
  
this.hp=params[1];
}
function 
onCreated()
{
  
this.direct=2;
  
setimg("dr_baddy_spider.png");
  
setshape(1,32,32);
  
onTimeout();

Now...what's not working???
The hp doesn't go down, yet the actions are received.
=(
Reply With Quote
  #2  
Old 08-22-2006, 12:22 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
o.o, I would simply use 'wash1t' or something
__________________
Deep into the Darkness peering...
Reply With Quote
  #3  
Old 08-22-2006, 03:15 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, playing around I found out that I could damage the baddy if it didn't move. I then tried a long timeout, 3 seconds. I couldn't make it work with a shorter timeout. My question is, How could I make it so I could have a .05 timeout (clientside of course) and still have the actions be received?
Right now I'm using that long timeout with a for loop to make it look like it's moving, then stoping for a while.
Reply With Quote
  #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
  #5  
Old 08-22-2006, 11:20 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
The serverside (x,y) of the baddy are different than the clientside (x,y). Make sure you're triggering at the serverside coordinates. If you're not modifying the (x,y) serverside, than you can store them in save[] variables (the npc will be stationary serverside), granted they still work...
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #6  
Old 08-22-2006, 11:40 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
It's all on clientside now
Reply With Quote
  #7  
Old 08-23-2006, 05:02 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
Sorry to bump :forwn:
It seems that I can only damage it once. I attack it, it's hearts seem to go down, but after that, I cannot hit it again. I've shortened the timeout as well, in fact, here is the current script:
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(.1);

Reply With Quote
  #8  
Old 08-26-2006, 10:39 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, I'm using hitobjects, and hearts for the baddy. Now, why would I only be able to hurt this baddy once. Even after it revives, I cannot hit it again unless I reconnect. Why?
There should be no reason for this now? At least not one I can see. Can someone please fill me in? What is wrong with this?!?
Reply With Quote
  #9  
Old 08-27-2006, 01:24 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
First of all, why the heck are you making a clientsided baddy?
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #10  
Old 08-27-2006, 02:11 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
Because the serversided one didn't work.
I want it serverside, but I'm afraid a large number could hurt the NPC server, or cause lag, etc. It doesn't work either way.
Reply With Quote
  #11  
Old 08-27-2006, 02:13 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Malorias baddys are serversided, and Im pretty sure that GKs and Zodiac's are aswell.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #12  
Old 08-27-2006, 04:20 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
Once again, doesn't work
Movement is messed up, he doesn't shoot, and you can still only hit him once. Any thoughts?
Here's what I have now:
PHP Code:
function onCreated()
{
  
showcharacter();
  
dir 2;
  
setcharani("dr_baddy_spider",NULL);
  
setshape(1,32,32);
  
hearts int(random(10,25));
  
onTimeout();
}
function 
onTimeout()
{
  if(
hearts>0)
  {
    if(
this.walk==0)
    {
      
setcharani("dr_baddy_spider_prep",NULL);
      
sleep(random(.5,1.5));
      
shootball();
      
setcharani("dr_baddy_spider_shoot",NULL);
      
this.walk=int(random(2,15));
    }
    else
    {
      
this.walk--;
      if(
abs(x-player.x)>=abs(y-player.y))
      {
        if(
player.x<x)
        {
          
dir 1;
        }
        if(
player.x>=x)
        {
          
dir 3;
        }
      }
      else if(
abs(x-player.x)<abs(y-player.y))
      {
        if(
player.y>y)
        {
          
dir 2;
        }
        if(
playery<=y)
        {
          
dir 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;
        }
      }
    }
  }
  else if(
hearts<=0)
  {
    
hearts 0;
    
triggeraction(0,0,"serverside","-System","exp","secure",player.account,1);
    
setani(NULL,NULL);
    
sleep(random(7,20));
    
onCreated();
  }
  
settimer(.1);
}
function 
onPlayertouchsme()
{
  
setani("hurt",NULL);
  
triggeraction(0,0,"serverside","-System","hurt","secure",1);      
}
function 
onWa****()
{
  
setcharani("dr_baddy_spider_shoot",NULL);


Last edited by excaliber7388; 08-27-2006 at 05:18 PM..
Reply With Quote
  #13  
Old 08-28-2006, 09:10 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
Only pay attention to the above post....bump
Reply With Quote
  #14  
Old 08-29-2006, 09:54 AM
contiga contiga is offline
Graal2001 Administration
contiga's Avatar
Join Date: Jul 2004
Location: Netherlands
Posts: 419
contiga is an unknown quantity at this point
Send a message via ICQ to contiga Send a message via AIM to contiga Send a message via MSN to contiga Send a message via Yahoo to contiga
Lol, that movement.. is so.. lmao xD
__________________
AIM: Contiga122
MSN: [email protected]
Status:
Quote:
Originally Posted by unixmad View Post
I am also awake 3AM to help correct problems.
Quote:
Originally Posted by Bomy Island RC people
Daniel: HoudiniMan is a bad guy =p
*Bell: rofl. I first read that as houdini is a bad man. like the little kid that wants his mommy to keep her away from that boogie man
Daniel: xD
*Rufus: I wouldn't want my kids around him.
Reply With Quote
  #15  
Old 08-29-2006, 06:27 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
Quote:
Originally Posted by contiga
Lol, that movement.. is so.. lmao xD
It worked in the past versions of this baddy, but for some reason it doesn't work right now. Also, the baddy can STILL only be damaged ONCE. After than, I have to reconnect to damage it again. I can't figure out what the problem is, and apparently, no one else can either
Reply With Quote
  #16  
Old 08-29-2006, 07:37 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Ugh.. use move(dx, dx, speed, options) for movement.

Editing the X and Y manually will not give you very fluid movement due to the 0.05 second limit.
Reply With Quote
  #17  
Old 08-29-2006, 07:43 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
Quote:
Originally Posted by Skyld
Ugh.. use move(dx, dx, speed, options) for movement.

Editing the X and Y manually will not give you very fluid movement due to the 0.05 second limit.
It doesn't look too bad, but I'll do that, just to see if it makes the NPC work at all
Reply With Quote
  #18  
Old 08-31-2006, 12:41 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
Oh come on, I've rescripted this three times, the last one should work.
Does anyone know why it wouldn't????

Last edited by excaliber7388; 08-31-2006 at 12:58 AM..
Reply With Quote
  #19  
Old 08-31-2006, 12:58 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
Okay, added the move thing, I'm nwe to using move, so tell me if I'm wrong:
(btw, it still doesn't work)
PHP Code:
//by Excalibur
function onCreated()
{
  
showcharacter();
  
dir 2;
  
setcharani("dr_baddy_spider",NULL);
  
setshape(1,32,32);
  
hearts int(random(10,25));
  
onTimeout();
}
function 
onTimeout()
{
  if(
hearts>0)
  {
    if(
this.walk==0)
    {
      
setcharani("dr_baddy_spider_prep",NULL);
      
sleep(random(.5,1.5));
      
shootball();
      
setcharani("dr_baddy_spider_shoot",NULL);
      
this.walk=int(random(2,15));
    }
    else if(
this.walk>0)
    {
      
this.walk--;
      if(
abs(x-player.x)>=abs(y-player.y))
      {
        if(
player.x<x)
        {
          
dir 1;
        }
        if(
player.x>=x)
        {
          
dir 3;
        }
      }
      else if(
abs(x-player.x)<abs(y-player.y))
      {
        if(
player.y>y)
        {
          
dir 2;
        }
        if(
playery<=y)
        {
          
dir 0;
        }
      }  
      if(
player.x+.5<x)
      {
        if(!
onwall(x-.2,y) && !onwall(x-.2,y+2))
        {
          
move(-.2,0,1,1);
        }
      }
      else if(
player.x+.5>=x)
      {
        if(!
onwall(x+2.2,y) && !onwall(x+2.2,y+2))
        {
          
move(.2,0,1,1);
        }
      }
      if(
player.y+1<y)
      {
        if(!
onwall(x,y-.2) && !onwall(x+2,y-.2))
        {
          
move(0,-.2,1,1);
        }
      }
      else if(
player.y+1>=y)
      {
        if(!
onwall(x,y+.2) && !onwall(x+2,y+.2))
        {
          
move(0,.2,1,1);
        }
      }
    }
  }
  else if(
hearts<=0)
  {
    
hearts 0;
    
triggeraction(0,0,"serverside","-System","exp","secure",player.account,1);
    
setani(NULL,NULL);
    
sleep(random(7,20));
    
onCreated();
  }
  
settimer(.1);
}
function 
onPlayertouchsme()
{
  
setani("hurt",NULL);
  
triggeraction(0,0,"serverside","-System","hurt","secure",1);      
}
function 
onWa****()
{
  
setcharani("dr_baddy_spider_shoot",NULL);

Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:38 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.