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-12-2008, 11:23 PM
GULTHEX GULTHEX is offline
Registered User
Join Date: Jul 2008
Posts: 148
GULTHEX can only hope to improve
Unhappy 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
Reply With Quote
  #2  
Old 09-12-2008, 11:32 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
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.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #3  
Old 09-12-2008, 11:33 PM
xAzerothx xAzerothx is offline
Banned
Join Date: Aug 2006
Location: Gurnee, Illinois
Posts: 2,615
xAzerothx has a little shameless behaviour in the past
Send a message via AIM to xAzerothx Send a message via MSN to xAzerothx Send a message via Yahoo to xAzerothx
Maybe someone could help him.
Reply With Quote
  #4  
Old 09-13-2008, 12:15 AM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
http://gs2.graalstudios.com/index.php
Reply With Quote
  #5  
Old 09-13-2008, 12:59 AM
Clockwork Clockwork is offline
ᶘ ᵒᴥᵒᶅ...ᶘ ಠᴥಠᶅ❤...ℳℴℯ
Clockwork's Avatar
Join Date: Feb 2007
Location: Pennsylvania
Posts: 2,071
Clockwork has a brilliant futureClockwork has a brilliant futureClockwork has a brilliant futureClockwork has a brilliant futureClockwork has a brilliant futureClockwork has a brilliant futureClockwork has a brilliant futureClockwork has a brilliant future
Im no Nat, just browsing, but

PHP Code:
 if (dist<=2)
        
hurtplayer(); 
looks like it hurts you to me o.o.....?
__________________
Reply With Quote
  #6  
Old 09-13-2008, 01:08 AM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Quote:
Originally Posted by Clockwork View Post
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.
Reply With Quote
  #7  
Old 09-13-2008, 02:21 AM
GULTHEX GULTHEX is offline
Registered User
Join Date: Jul 2008
Posts: 148
GULTHEX can only hope to improve
iv read the guide i just need some help with this lol
Reply With Quote
  #8  
Old 09-13-2008, 06:38 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Also, you mix GS1 and GS2 so much...
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #9  
Old 09-13-2008, 11:27 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 GULTHEX View Post
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.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #10  
Old 09-21-2008, 11:21 PM
BonzaiXxXSRStudios BonzaiXxXSRStudios is offline
Since 2001
BonzaiXxXSRStudios's Avatar
Join Date: Jul 2007
Location: Atlanta, Georgia USA
Posts: 108
BonzaiXxXSRStudios is on a distinguished road
Send a message via MSN to BonzaiXxXSRStudios
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.
__________________


Nutos (Jasler) and Yoke (lDarkDragonl) at Bonzai and Storm Reach Studios
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 01:24 AM.


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