Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Hp System, damage var (https://forums.graalonline.com/forums/showthread.php?t=134264440)

imbavik 09-01-2011 08:04 PM

Hp System, damage var
 
i have a Health system im working on, and it seems to work, it's just that i dont know what variable i will use to my damage, like in a othere weapon as "Guns/AK47" etc.

My Gun Script look's like this.
PHP Code:

join("class_gun");
//#CLIENTSIDE
function onCreated() {

  
this.gun.spread .053;
  
this.gun.speed 5;
  
this.gun.reload50;
  
this.gun.load 50;
  
this.gun.firerate 1;
  
this.gun.firegani "testfire";
  
this.gun.bulletgani "imbavik_bullet";



and here is the gun_class that its joined to:
PHP Code:

//#CLIENTSIDE

function onWeaponFired() {
  while (
keydown(4)) {
    
FireGun();
    
sleep(this.gun.firerate);
  }
}

function 
FireGun() {

  
setani(this.gun.firegani"");
  
temp.angl getangle(vecx(player.dir), vecy(player.dir))+random(this.gun.spread*-1,this.gun.spread);
  
shoot(player.0.5 vecx(player.dir), player.vecy(player.dir), player.ztemp.angl00this.gun.bulletganiplayer.dir);



and here is the -System/Health:

PHP Code:

/*
Health System worked on by Imbavik!
*/

serverr.hp 100;
function 
onActionServerSidecmdaccdamageguild )
{
switch ( 
cmd )
{
case 
"createHP":
{
clientr.hp_max serverr.hp;
clientr.hp_cur serverr.hp;
break;
}
case 
"revivePlayer":
{
player.chat "DEAD!";
clientr.speed 0;
sleep(5);
player.chat "";
clientr.speed 0.6;
clientr.hp_cur clientr.hp_max;
client.mode = ("idle");
break;
}
 case 
"setHP":
    {
      
clientr.hp_cur acc;
      break;

      case 
"playerKilled":
    {
      
setani("dead"NULL);
      
client.mode="dead";

     
clientr.speed=0;
      
sleep(3);
      
client.mode="idle";
      
setani("idle""");
      
clientr.speed=0.6;

      break;

 case 
"doDamage":
    {
      if ( 
damage )
      {
        break;
      }
      if ( 
clientr.hp_cur <= )
      {
        break;

      }

      
damage intdamage );
      
clientr.hp_cur -= damage;




      if ( 
clientr.hp_cur <= )
      {
        
clientr.hp_cur 0;

        if ( 
acc == player.account )
        {
          if ( 
clientr.stats_points )
          {
            
clientr.stats_points --;
          }
          
clientr.stats_deaths ++;

        }
        else
        {
          
findPlayeracc ).clientr.stats_kills ++;
          
findPlayeracc ).clientr.stats_points += intrandom1) );


          
clientr.stats_deaths ++;

        }

        
serverr.kills ++;

      }
      break;

case 
"hitByBullet":
 {
      if ( 
acc == player.account )
      {
        break;


      }
      if ( 
clientr.hp_cur <= )
      {
        break;

      }

      
damage intdamage );
      
clientr.hp_cur -= damage;
      
setAni"hurt"null );



      if ( 
clientr.hp_cur <= )
      {
        
clientr.hp_cur 0;

        
findPlayeracc ).clientr.stats_kills ++;
        
findPlayeracc ).clientr.stats_points += intrandom1) );

        
clientr.stats_deaths ++;
        
serverr.kills ++;
      }
      break;
}
}
}
}
}


}

//#CLIENTSIDE

function onCreated(){
triggerserver"gui"this.name"createHP");

  if ( 
clientr.hp_max != serverr.hp )
  {
    
this.hasTriggered true;
    
triggerserver"gui"name"createHP" );
  }
  
setTimer0.05 );
}
function 
onTimeOut()
{
  if ( 
clientr.hp_max != serverr.hp )
  {
    if ( ! 
this.hasTriggered )
    {
      
this.hasTriggered true;
      
triggerserver"gui"name"createHP" );
    }
    
setTimer0.05 );
    return;
  }

  
player.attr[10] = clientr.hp_cur;
  
player.attr[11] = clientr.hp_max;

  if ( 
clientr.hp_cur <= )
  {

   
triggerserver"gui"name"playerKilled");
   
sleed(3);
   
triggerserver"gui"this.name"createHP");


    if ( 
clientr.hp_cur )
    {
      
triggerserver"gui"name"setHP");
    }
  }

  if ( 
clientr.hp_cur clientr.hp_max )
  {
    
triggerserver"gui"name"setHP");
  }

  
setTimer0.05 );
}

function 
onPlayerChats(){
if (
player.chat == "/heal"){
triggerserver"gui"this.name"createHP");
}
}

function 
onActionProjectileaccdamageguild )
{
triggerserver"gui"this.name"hitByBullet"acc10guild );
player.chat ""SPC clientr.hp_cur SPC "/" SPC clientr.hp_max SPC"";


but what variable do i use in the Gun wnpc ? :confused:
i was thinking something like thiso.damage = "12"; etc
but didint work.

btw, i am new to gs2. so please dont judge!

i only need help on how i can change the damage of my weapon whitout changing the damage of all the othere weapons! x_x

cbk1994 09-01-2011 10:03 PM

Looks like you'll need to use setShootParams before shooting. Second parameter appears to be damage based on your onActionProjectile function (although it looks like you are just sending "10" to serverside instead of the actual damage in your health script).

furry_mougle 09-02-2011 07:35 AM

CBK pretty much summed up the answer to your question quite nicely. However as a suggestion, Skyld wrote a pretty good HP class you might want to take a look at:

http://forums.graalonline.com/forums...p/t-68271.html (kind of dated but still applicable)

It isn't required, but it'd at least make a good reference to prevent that HP class from getting any more messier than it already is.

One major thing to note is the usage of sleep() in your class. (?) wat

imbavik 09-02-2011 10:47 AM

Thanks for the help chris and furrt_mougle :)

ff7chocoboknight 09-02-2011 04:52 PM

Seeing Mog post this much is both shocking and exciting.

Emera 09-02-2011 05:25 PM

I never knew that he had a forum account until now. I thought he was out asking everybody for their sisters Facebook account. Oh well, hello Mog!


All times are GMT +2. The time now is 04:01 AM.

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