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 05-05-2007, 12:10 AM
theHAWKER theHAWKER is offline
**FLIP OUT**
theHAWKER's Avatar
Join Date: Mar 2006
Location: canada, vancouver
Posts: 768
theHAWKER is an unknown quantity at this point
Question spawn baddy probs...

i have a spar where u can spawn baddys but its not working x.x can u guys help me out?

oh and im just using the g-baddy script found in the script gallery
so here it is:
PHP Code:
// NPC made by theHAWKER
//#CLIENTSIDE
if (playerchats&&strequals(#c,/baddy)){
    
putnpc2 playerx,playery,{ //GBaddy
//Version 1.0

//Features:
// Constantly moving about, not idle like most
// boring baddies you see on Graal.
// When you step into the baddies vision radius,
// he will begin to chase after you, in attack mode.
// While in attack mode, the baddy has a total of
// 3 possible things that he can do, all of which
// are chosen randomly.
// The baddy can choose to swing his sword at
// you, heal himself, and/or cause an explosion
// under him.
// NOTE: I didn't add any damage checks besides
//       Was.Hit, so if Was.Hit only checks for
//       whether or not the baddy was hit by
//       a sword, then that's all that will
//       hurt it for now.
// NOTE #2: I know that it's NOT PERFECT,
//          but it's the first time I've actually,
//          worked with Artificial Intelligence,
//          excluding the current bot that I'm
//          making on Graal X, which is much
//          different. I figured it was a
//          nice learning experience, and I
//          figured some people could find it
//          useful since it's MUCH MORE challenging
//          than the default baddy NPCs.
// NOTE #3: I used some of the mathematical
//          calculations previously created by
//          Stefan in his baddy NPC (the default
//          Graal baddy NPC).

//By: Gambet

enum
{
 
WALK,
 
ATTACK,
 
DEAD
}

function 
onCreated()
{
  
showcharacter();
  
this.bodyimg "body2.png";
  
this.shieldimg "no-shield.png";
  
this.nick "GBaddy";
  
this.ap 0;
  for (
a=0a<5a++)
   {
    
this.colors[a] = "black";
   }
  if (
this.ani != "idle")
   {
     
setcharani("idle","");
   }
  
this.health = {10,10};
  
this.mov_speed 0.5;
  
this.count int(random(10,40));
  
this.mode WALK;
  
setTimer(0.1);
}

function 
onPlayerEnters()
{
  
onTimeOut(); //To Wake Up The NPC
  
this.headimg "head" int(random(0,1000)) @ ".png"//To Have A Different Head Each Time You Enter The Level
}

function 
onWa****() //REMOVE THE . - GRAAL FORUMS FILTER IS ANNOYING >O
{
 if (
this.health[0]-(player.swordpower/2) > 0)
  {
    if (
this.ani != "hurt")
     {
       
setcharani("hurt","");
       
scheduleevent(1,"Counter","");
     }
    switch(
this.plyr.dir//Knockback
     
{
      case 
"2":
       if (!
onwall(this.x,this.y+3))
        {
         
this.y+=3;
        }
       break;
      case 
"0":
       if (!
onwall(this.x,this.y-3))
        {
         
this.y-=3;
        }
       break;
      case 
"1":
       if (!
onwall(this.x-3,this.y))
        {
         
this.x-=3;
        }
       break;
      case 
"3":
       if (!
onwall(this.x+3,this.y))
        {
         
this.x+=3;
        }
       break;
     }
     
this.health[0]-=player.swordpower/2;
     
chat this.health[0] @ "/" this.health[1];
     
scheduleevent(2,"HideChat","");
  } else
   {
    if (
this.mode != DEAD)
     {
       
this.mode DEAD;
       
this.health[0] = 0;
       
putexplosion2(3,3,this.x,this.y);
       
putexplosion2(3,3,this.x,this.y+0.5);
       
setcharani("dead","");
       
chat this.health[0] @ "/" this.health[1];
       
scheduleevent(8,"Respawn","");
     }
   }
}

function 
onHideChat()
{
 if (
params[0] == "idle")
  {
    
chat "";
    
setcharani("idle","");
  } else
   {
     
chat "";
   }
}

function 
onCounter()
{
 if (
this.health[0] > 0)
  {
    
setcharani("sword","");
  }
}

function 
onRespawn()
{
 if (
this.mode == DEAD)
  {
    
setcharani("idle","");
    
chat "";
    
this.health[0] = this.health[1];
    
this.mode WALK;
  }
}

function 
onTimeOut()
{
 if (
players.size() > 0)
  {
   
setTimer(0.1);
  } else
   {
    
setTimer(0); //To Sleep In Case No Players Are In The Room - Saves CPU Time
   
}
 if (
this.mode != DEAD)
  {
   if (
this.to_check.x in |this.x-10,this.x+10| && this.to_check.y in |this.y-10,this.y+10|)
    {
     if (
this.mode != ATTACK)
      {
        
this.mode ATTACK;
      }
    } else
     {
       
this.mode WALK;
     }
  }
 if (
this.mode == WALK)
  {
    
this.to_check findnearestplayer(this.x,this.y);
    
this.new_x this.vecx(this.dir) * this.mov_speed;
    
this.new_y this.vecy(this.dir) * this.mov_speed;
    
this.count--;
   if (
this.count 0)
    {
      
this.to_add_x this.new_x 1.5 vecx(this.dir);
      
this.to_add_y this.new_y vecy(this.dir);
     if (
onwall(this.to_add_x,this.to_add_y))
      {
        
this.dir = (this.dir+2)%4;
      } else
       {
         
setcharani("walk","");
         
this.new_x;
         
this.new_y;
       }
    } else
     {
       
this.count int(random(10,40));
       
this.dir = (this.dir+1+int(random(0,2))*2)%4;
     }
  }
  if (
this.mode == ATTACK)
   {
     
this.plyr this.to_check;
     
this.dist_x this.plyr.this.x;
     
this.dist_y this.plyr.this.y;
     
this.len = (this.dist_x*this.dist_x+this.dist_y*this.dist_y)^0.5;
     
this.add_x = (this.dist_x this.len);
     
this.add_y = (this.dist_y this.len);
     
this.check_x this.1.5;
     
this.check_y this.2;
     if (!
onwall(this.check_x this.add_x,this.check_y this.add_y))
      {
        
DamagePlayer();
        
Move();
      } else if (!
onwall(this.check_x this.add_x,this.check_y))
       {
         
this.+= this.add_x;
         
DamagePlayer();
       } else if (!
onwall(this.check_x,this.check_y this.add_y))
        {
          
this.+= this.add_y;
          
DamagePlayer();
        }
   }
 
setTimer(0.1);
}

function 
DamagePlayer()
{
 
this.randomize int(random(0,101));
  if (
this.randomize in |0,82|) //Attack With Sword
   
{
     
setcharani("sword","");
   } else if (
this.randomize in |83,95|) //Cause Explosion
    
{
      
putexplosion2(3,3,this.x,this.y);
    } else if (
this.randomize in |95,101|) //Heal
     
{
      if (
this.health[0] < this.health[1])
       {
        if (
this.health[0]+this.health[1])
         {
           
this.temp_add int(random(0,6));
           
this.health[0]+=this.temp_add;
           
chat "*Healed for " this.temp_add "*";
         } else if (
this.health[0]+>= this.health[1])
          {
            
this.health[0] = this.health[1];
            
chat "*Fully Healed*";
          }
           
setcharani("lift","");
           
this.health[0] = this.health[1];
           
scheduleevent(1,"HideChat","idle");
       }
     }
}

function 
Move()
{
  
setcharani("walk","");
  
this.x+=this.add_x * (this.mov_speed 0.6);
  
this.y+=this.add_y * (this.mov_speed 0.6);
  if (
abs(this.dist_x) > abs(this.dist_y))
   {
    if (
this.dist_x 0)
     {
       
this.dir 3;
     } else
      {
        
this.dir 1;
      }
   } else
    {
     if (
this.dist_y 0)
      {
        
this.dir 2;
      } else
       {
         
this.dir 0;
       }
    }
}   };
  } 
__________________
**FLIP OUT**
Reply With Quote
  #2  
Old 05-05-2007, 12:22 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
*Sigh*.

1.) THIS IS THE MOST IMPORTANT PART. I WANT YOU TO READ, UNDERSTAND AND REMEMBER THIS WHILE YOU ARE ATTEMPTING TO CRITICIZE OTHER'S EFFORTS.

GS1 != GS2, IT'S NOT GOOD FOR COMPATIBILITY.

Now on, to the second part.

I would suggest actually putting the baddy in a damn class and then adding that weapon to the player and putnpc2 the class.
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #3  
Old 05-05-2007, 12:24 AM
godofwarares godofwarares is offline
Webmaster
godofwarares's Avatar
Join Date: Dec 2006
Location: Florida
Posts: 552
godofwarares is on a distinguished road
Send a message via ICQ to godofwarares Send a message via AIM to godofwarares Send a message via MSN to godofwarares Send a message via Yahoo to godofwarares
Quote:
Originally Posted by theHAWKER View Post
*Code*
Rofl!

How embarrassing for you! Hybridized scripts = Bad.

More to the point,
Try putting it in a class on RC and use the code putnpc2 x, y, "join baddyclass;"; to put it on the field.
__________________
What signature? I see no signature?
Reply With Quote
  #4  
Old 05-05-2007, 12:31 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
O_O


Wow.....


That's not how you do it at all x-x


You need to set up the baddy script as a class and then putnpc2 with the npc joining the classname that contains my baddy script.
Reply With Quote
  #5  
Old 05-05-2007, 12:33 AM
theHAWKER theHAWKER is offline
**FLIP OUT**
theHAWKER's Avatar
Join Date: Mar 2006
Location: canada, vancouver
Posts: 768
theHAWKER is an unknown quantity at this point
so like make an npc in the level saying join baddyclass;
then i make a class, and in the class i put the putnpc2 playerx,playery(*script*)

is that right?
__________________
**FLIP OUT**
Reply With Quote
  #6  
Old 05-05-2007, 12:34 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
Use GS2!!

putnpc2(player.x, player.y, "join(\"classname\");");
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #7  
Old 05-05-2007, 12:43 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
No, you make the class through RC. And then use putnpc2 through something like player chats then triggeraction. Or even a public function.

By the way, PUTNPC2 IS SERVERSIDE.

Edit: YOU HAVE THE MEANS TO LEARN A MUCH SIMPLER LANGUAGE CALLED Gscript2, WHY DO YOU NOT UTILIZE THEM TO NOT BURN OUR EYES OUT EVERY TIME YOU POST.
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #8  
Old 05-05-2007, 12:46 AM
theHAWKER theHAWKER is offline
**FLIP OUT**
theHAWKER's Avatar
Join Date: Mar 2006
Location: canada, vancouver
Posts: 768
theHAWKER is an unknown quantity at this point
nah it wont work eaven with just if (created)
__________________
**FLIP OUT**
Reply With Quote
  #9  
Old 05-05-2007, 12:47 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
Quote:
Originally Posted by theHAWKER View Post
nah it wont work eaven with just if (created)
Have to be serverside.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #10  
Old 05-05-2007, 12:49 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
Quote:
Originally Posted by theHAWKER View Post
nah it wont work eaven with just if (created)
MAYBE YOU OUGHT TO ACTUALLY READ AND TRY TO UNDERSTAND WHAT PEOPLE TELL YOU.

IF WE ARE SAYING IT IS SERVERSIDE ONLY, WHY WOULD ONCREATED MAKE A DIFFERENCE?
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #11  
Old 05-05-2007, 12:50 AM
theHAWKER theHAWKER is offline
**FLIP OUT**
theHAWKER's Avatar
Join Date: Mar 2006
Location: canada, vancouver
Posts: 768
theHAWKER is an unknown quantity at this point
stop spazzing out....
i just took out the celent side and that makes it server side, right?
__________________
**FLIP OUT**
Reply With Quote
  #12  
Old 05-05-2007, 12:59 AM
Bl0nkt Bl0nkt is offline
Era Developer
Bl0nkt's Avatar
Join Date: Mar 2005
Location: Pennsylvania
Posts: 1,589
Bl0nkt will become famous soon enough
Send a message via AIM to Bl0nkt
Quote:
// NPC made by theHAWKER
LOL
Reply With Quote
  #13  
Old 05-05-2007, 01:00 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by theHAWKER View Post
stop spazzing out....
i just took out the celent side and that makes it server side, right?
Look, your code is ****. You took great code from Gambet, erased his name and put your own on it, and then cry to us when it doesn't work.

Firstly, IT IS SERVERSIDE!

Secondly, MAKE A CLASS!

Thirdly, DO NOT MIX GS1 AND GS2!

Go to RC, go to classes, than create a new class. Name it "baddy". In that class, put Gambet's GBaddy. Then put this in a level.

PHP Code:
function onPlayerChats()
{
  if ( 
player.chat == "/baddy" )
  {
    
putnpc2player.xplayer.y"join( \"baddy\" ); ");
  }

Please take the time to look at the wiki and learn GS2, then maybe we won't all have to cry whenever you post.

EDIT:

Quote:
Originally Posted by Bl0nkt View Post
LOL
I second that.
__________________
Reply With Quote
  #14  
Old 05-05-2007, 01:04 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
Quote:
Originally Posted by theHAWKER View Post
stop spazzing out....
i just took out the celent side and that makes it server side, right?
It's not the fact I'm spazzing out, it's the fact that if you're asking people questions like the latter, then I suggest you take some time out to actually study before you dive right in.

Now where's Inverness to tell me I need to learn to script first?
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #15  
Old 05-05-2007, 01:09 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by killerogue View Post
It's not the fact I'm spazzing out, it's the fact that if you're asking people questions like the latter, then I suggest you take some time out to actually study before you dive right in.

Now where's Inverness to tell me I need to learn to script first?
Don't worry, he's coming. I called him on my gPhone.
__________________
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 11:25 AM.


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