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 10-28-2009, 12:28 AM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Spell system Problem

Hi everyone,

i got a little problem that i can't make it work, it should work due to other systems it's begin used in.
it doesn't hurt other players.

-System/Spells:
PHP Code:
function onActionServerside(cmd,p1,p2,p3) {
  if (
cmd == "TakeMana")
    
clientr.mana -= p1;
}
//#CLIENTSIDE
public function fireSpell(stats) {
//fired from the spell weapon
  
temp.spellName stats[0];
  
temp.action stats[1];
  
temp.cast stats[2];
  
temp.ani stats[3]; //projectile
  
temp.mana stats[4];
  
temp.freeze stats[5];
  
temp.power stats[6];
  
temp.cooldown stats[7];
  
  if (
mana clientr.mana) {
    
player.chat "You don't have enough mana to cast " @spellName".";
    
//if you have a message system you can use that instead
    
return;
  }
  if (
this.("cooldown_" @spellName) != null) {
    
player.chat spellName" is still cooling down for " @this.("cooldown_" @spellName)@ " seconds.";
    
//if you have a message system you can use that instead
    
return;
  }
  
  if (
action == "hurt") { //a spell that hurts a player
    
if (cast == "projectile") { //a hurt spell that is a projectile
      
freezePlayer(freeze);
      
setani("grab",null); //placeholder
      
sleep(freeze);
      
setShootParams("spell","heal",power,player.account,player.guild);
      
temp.angle getangle(vecx(player.dir),vecy(player.dir)); //shoots in a straight line
      
shoot(player.x+vecx(player.dir),player.y+vecy(player.dir),player.z,angle,0,0,ani,null);
    }
  }
  if (
action == "heal") { //a spell that heals a player
    
if (cast == "projectile") { //a heal spell that is a projectile
      
freezePlayer(freeze);
      
setani("grab",null); //placeholder
      
sleep(freeze);
      
setShootParams("spell","heal",power,player.account,player.guild);
      
temp.angle getAngle(vecx(player.dir),vecy(player.dir)); //shoots in a straight line
      
shoot(player.x+vecx(player.dir),player.y+vecy(player.dir),player.z,angle,1,0,ani,null);
    }
    if (
cast == "self") { //a heal spell that is cast on yourself
      
freezePlayer(freeze);
      
setani("grab",null);  //placeholder
      
sleep(freeze);
      
//go to health system and heal using the amount 'random(int(power[0],power[1]))'
    
}
  }    
  
triggerServer("gui","-System/Spells","TakeMana",mana);
  
makeVar("this.cooldown_" @spellname) = cooldown;
  
scheduleEvent(0.05,"Cooldown",spellName);
}

function 
onCooldown(spellName) {
  if (
this.("cooldown_" @spellName) > 0) {
    
makeVar("this.cooldown_" @spellName) -= 0.05;
    
scheduleEvent(0.05,"Cooldown",spellName);
  }
}

function 
onActionProjectile(spell,action,power,pl,pguild) {
  if (
spell == "spell") { //make sure it's a spell and not some other projectile
    
if (action == "hurt") {
     
temp.hurtable CheckHurtable(plpguild); //Here's the problem (i think.)
      
if (temp.hurtable && clientr.hp 0)
      {
        
player.chat temp.hurtable;
        
temp.powerdmg int(random(power[0],power[1]));
        
triggerserver("weapon""-System/Health""TakeDamage"temp.powerdmgpl);
        
client.immunity 1;
        
player.attr[20] = "noc_damage.gani,-" temp.powerdmg;
        
scheduleevent(0.5"UnSetAttr""");
        
client.LastAttacker pl;
        
setani("hurt","");
       
// player.chat = clientr.hp; <- debug
      
}
    }
    if (
action == "heal") {
      
//go to health system and heal using the amount 'random(int(power[0],power[1]))'
    
}
  }
}

function 
onUnSetAttr()
{
  
client.immunity 0;
  
player.attr[20] = "";
  
cancelEvents("UnSetAttr");
}

function 
CheckHurtableplgd)
{
  if(
gd == "Newbie Protection" || player.guild == "Newbie Protection")return;
  if(
pl == player.account)return false;
  if(
level.nopkzone)return false;
  if(
client.sparstatus == 1)return false;
  if(
client.dead)return false;
  if(
clientr.dead)return false;
  if(
clientr.stafftag == player.guild && clientr.stafftag != NULL)return false;
  if(
gd == "Working" || gd == "Events Team")return false;
  if(
player.guild == "Working" || player.guild == "Events Team")return false;
  if(
client.immunity 0)return false;
  if(
player.guild == gd)
    if(
player.guild != NULL)
      if(
gd != NULL)
        return 
false;
  return 
true;

Spells/Test:
PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
  
temp.stats = {
    
"Test"//name
    
"hurt"//action
    
"projectile"//cast
    
"tl_fire"//projectile animation
    
20//mana
    
0.5//freeze
    
{1,5}, //power
    
2//cooldown
  
};
  
findWeapon("-System/Spells").fireSpell(stats);
  
setani("idle",null);

Credits for this script goes to Switch.

a part of the -System/Health
PHP Code:
function onActionServerSide(id)
{
  switch(
id)
  {      
    case 
"TakeDamage":
      if(
clientr.hp <= || clientr.specialpkzone == true)
        return;
      
temp.dmg params[1];
      
temp.pl params[2];// no idea why this is here but ohwell.
      
player.attr[16] = dmg// no idea why this is here but ohwell.
      
player.attr[15] = "noc_damage.gani";// no idea why this is here but ohwell.
      
if(clientr.hp 0)
        
clientr.hp -= temp.dmg;
    break;
  }

please notice that the heath system is used by other systems, so it might not be the thing that breaks it but i included it in-case of.
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #2  
Old 10-28-2009, 03:51 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by Deas_Voice View Post
PHP Code:
...
temp.powerdmg int(random(power[0],power[1]));
...
//go to health system and heal using the amount 'random(int(power[0],power[1]))' 
Hehe

Did you make sure that the player you're testing this on has the spell system weapon?
And if you have your own firing system (if you use disableweapons() and/or set your D-weapon differently) make sure to call onWeaponFired() in "Spell/Test", and make sure the function in public (public function onWeaponFired() {)
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #3  
Old 10-28-2009, 08:59 AM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Quote:
Originally Posted by Switch View Post
Hehe

Did you make sure that the player you're testing this on has the spell system weapon?
And if you have your own firing system (if you use disableweapons() and/or set your D-weapon differently) make sure to call onWeaponFired() in "Spell/Test", and make sure the function in public (public function onWeaponFired() {)
yup, the spell sysytem weapon is added at login.
no as far as i know, we are still using the default movment system and onWeaponFired()
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #4  
Old 10-30-2009, 03:04 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Well what exactly doesn't work?
Put a different echo in each statement and see where the problem occurs.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #5  
Old 10-30-2009, 03:08 AM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Quote:
Originally Posted by Switch View Post
Well what exactly doesn't work?
the actual hurting doesn't work.
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #6  
Old 10-30-2009, 03:12 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
PHP Code:
  if (action == "hurt") { //a spell that hurts a player
    
if (cast == "projectile") { //a hurt spell that is a projectile
      
freezePlayer(freeze);
      
setani("grab",null); //placeholder
      
sleep(freeze);
      
setShootParams("spell","hurt",power,player.account,player.guild);
      
temp.angle getangle(vecx(player.dir),vecy(player.dir)); //shoots in a straight line
      
shoot(player.x+vecx(player.dir),player.y+vecy(player.dir),player.z,angle,0,0,ani,null);
    }
  } 
Had the second param in setShotParams as "heal" instead of "hurt".
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #7  
Old 10-30-2009, 03:24 AM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Quote:
Originally Posted by Switch View Post
PHP Code:
  if (action == "hurt") { //a spell that hurts a player
    
if (cast == "projectile") { //a hurt spell that is a projectile
      
freezePlayer(freeze);
      
setani("grab",null); //placeholder
      
sleep(freeze);
      
setShootParams("spell","hurt",power,player.account,player.guild);
      
temp.angle getangle(vecx(player.dir),vecy(player.dir)); //shoots in a straight line
      
shoot(player.x+vecx(player.dir),player.y+vecy(player.dir),player.z,angle,0,0,ani,null);
    }
  } 
Had the second param in setShotParams as "heal" instead of "hurt".
....lol

Edit:
in lack of players to test it on, i can't test it ATM.
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you

Last edited by Deas_Voice; 10-30-2009 at 03:38 AM..
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:11 AM.


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