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


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:21 AM.


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