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-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
 


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 08:56 AM.


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