Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   stefans health sys guide help (https://forums.graalonline.com/forums/showthread.php?t=81791)

GULTHEX 09-12-2008 11:23 PM

stefans health sys guide help
 
i foloed this guide to the bottom
and when i use the sword one it hurts myself :(
ill show ya what i put

i put this in the hpsys
PHP Code:

if (actionserverattack) {
  
// A sword-type weapon
  // Check for players
  
this.attackx playerx 1.5 vecx(playerdir)*2;
  
this.attacky playery 2   vecy(playerdir)*2;
  
this.attackpower 1;
  
attackplayers();
  
attacknpcs();
}
function 
attackplayers() {
  
pid playerid;
  
pindexes getnearestplayers(this.attackx,this.attacky,playerid!=pid);
  
dist  0;
  for (
i=0i<arraylen(pindexes); i++) {
    
with (players[pindexes[i]]) {
      
dx playerx 1.5 this.attackx;
      
dy playery 2   this.attacky;
      
dist = (dx*dx dy*dy)^0.5;
      if (
dist<=2)
        
hurtplayer();
    }
    if (
dist>2)
      break;
  }
function 
hurtplayer() {
  
newhp strtofloat(#s(clientr.hp)) - this.attackpower;
  
if (newhp<=0) {
    
newhp 3;
    
setani dead,;
  } else {
    
setani hurt,;
  }
  
setstring clientr.hp,#v(newhp);
}



PHP Code:

put this in the sword
//#CLIENTSIDE
if (weaponfired) {
  
setani dg_katana_attack,;
  
freezeplayer 0.25;
  
triggeraction 0,0,serverattack,;


put this in npcserver
PHP Code:

if (actionserverattack) {
  
// A sword-type weapon
  // Check for players
  
this.attackx playerx 1.5 vecx(playerdir)*2;
  
this.attacky playery 2   vecy(playerdir)*2;
  
this.attackpower 1;
  
attackplayers();
  
attacknpcs();

join hpfunctions;} 

put this in the class called
hpfunctions
PHP Code:

function attackplayers() {
  
pid playerid;
  
pindexes getnearestplayers(this.attackx,this.attacky,playerid!=pid);
  
dist  0;
  for (
i=0i<arraylen(pindexes); i++) {
    
with (players[pindexes[i]]) {
      
dx playerx 1.5 this.attackx;
      
dy playery 2   this.attacky;
      
dist = (dx*dx dy*dy)^0.5;
      if (
dist<=2)
        
hurtplayer();
    }
    if (
dist>2)
      break;
  }
}
function 
hurtplayer() {
  
newhp strtofloat(#s(clientr.hp)) - this.attackpower;
  
if (newhp<=0) {
    
newhp 3;
    
setani dead,;
  } else {
    
setani hurt,;
  }
  
setstring clientr.hp,#v(newhp);


and note*i didint use the arrow 1 because the script had an error because when i hit apply it had an error so i only did sword*note

coreys 09-12-2008 11:32 PM

You've honestly been trying to do more complex things than you should. You obviously don't know the basics well yet, you need to start with that.

xAzerothx 09-12-2008 11:33 PM

Maybe someone could help him.

Codein 09-13-2008 12:15 AM

http://gs2.graalstudios.com/index.php

Clockwork 09-13-2008 12:59 AM

Im no Nat, just browsing, but

PHP Code:

 if (dist<=2)
        
hurtplayer(); 

looks like it hurts you to me o.o.....?

Codein 09-13-2008 01:08 AM

Quote:

Originally Posted by Clockwork (Post 1422906)
Im no Nat, just browsing, but

PHP Code:

 if (dist<=2)
        
hurtplayer(); 

looks like it hurts you to me o.o.....?

His code is riddled with errors.

He should really read Twinny's guide, and start out with easier, less complex projects, in my opinion.

GULTHEX 09-13-2008 02:21 AM

iv read the guide i just need some help with this lol

coreys 09-13-2008 06:38 AM

Also, you mix GS1 and GS2 so much...

xXziroXx 09-13-2008 11:27 AM

Quote:

Originally Posted by GULTHEX (Post 1422920)
iv read the guide i just need some help with this lol

I don't think any of us are willing to just give you help like that, when you clearly don't understand the script yourself. :\

Dude, just work your way up from the bottom to the top, it'll be so much more rewarding for you in the end.

BonzaiXxXSRStudios 09-21-2008 11:21 PM

Also, there are alot more threads already posted in the NPC Scripting section that could also lend you some useful information. Thats how i learn also because lets face it, the guide doesnt show you everything, it was more for me a tool to help me better understand GS2. Either way, its going to take alot of work to get it done..your best bet would be to not only browse the forums but also, go to servers with a health system already..and ask them if they could temporarily lend you a hand with yours. Im sure if you ask nicely they would atleast look at it.


All times are GMT +2. The time now is 09:17 AM.

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