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 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
  #2  
Old 09-01-2011, 10:03 PM
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
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).
__________________
Reply With Quote
  #3  
Old 09-02-2011, 07:35 AM
furry_mougle furry_mougle is offline
big heart
furry_mougle's Avatar
Join Date: Aug 2011
Posts: 42
furry_mougle is an unknown quantity at this point
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
__________________
Quote:
Originally Posted by ffcmike View Post
But make sure to change beer.png to Orange Juice.
pay bills to play graal

Last edited by furry_mougle; 09-02-2011 at 07:47 AM..
Reply With Quote
  #4  
Old 09-02-2011, 10:47 AM
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
Thanks for the help chris and furrt_mougle
__________________
Reply With Quote
  #5  
Old 09-02-2011, 04:52 PM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of light
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
Seeing Mog post this much is both shocking and exciting.
__________________
Reply With Quote
  #6  
Old 09-02-2011, 05:25 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
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!
__________________
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 04:12 AM.


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