Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-01-2011, 08:04 PM
imbavik imbavik is offline
Mercia
imbavik's Avatar
Join Date: Apr 2011
Location: Norway
Posts: 23
imbavik has a little shameless behaviour in the past
Send a message via MSN to imbavik
Exclamation 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 ?
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!
__________________
Reply With Quote
 


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 05:07 AM.


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