Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Spell system Problem (https://forums.graalonline.com/forums/showthread.php?t=134256695)

Deas_Voice 10-28-2009 12:28 AM

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.

Switch 10-28-2009 03:51 AM

Quote:

Originally Posted by Deas_Voice (Post 1534584)
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 :D

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() {)

Deas_Voice 10-28-2009 08:59 AM

Quote:

Originally Posted by Switch (Post 1534640)
Hehe :D

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

Switch 10-30-2009 03:04 AM

Well what exactly doesn't work?
Put a different echo in each statement and see where the problem occurs.

Deas_Voice 10-30-2009 03:08 AM

Quote:

Originally Posted by Switch (Post 1534983)
Well what exactly doesn't work?

the actual hurting doesn't work.

Switch 10-30-2009 03:12 AM

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

Deas_Voice 10-30-2009 03:24 AM

Quote:

Originally Posted by Switch (Post 1534988)
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.


All times are GMT +2. The time now is 01:27 AM.

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