Author Topic: Problem With Spell Scripting  (Read 343 times)

Legacy_VonTherodere

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Problem With Spell Scripting
« on: October 18, 2011, 08:31:44 am »


                Hello all.  I've dabbled in scripting for a while now on my own and managed through online searches and my own customization to figure most everything out but I've finally gotten completely stumped on something that is bugging me.  I've made a host of races for players to choose in a module I am working on and one race are undead with various subraces that are modified on creation.  The spells cure (minor through critical) and inflict (minor through critical) work fine, inflict healing the undead and cure harmikng them.  But spells like negative energy ray, harm, negative energy burst, and healing circle for example don't work as well.  If a player fires a negative energy ray at an undead player it still harms them.... however if a monster has negative energy ray and fires it, it heals them as it should normally.  The same goes for negative pulse, healing sting, heal, m ass heal, healing circle, harm, horrid wilting, and others.  The only ones working exactly right are the normal cures and inflicts :S.

Below is the script I used for negative energy ray.  I have several varieties of undead, which is why I have so many exceptions other than RACIAL_TYPE_UNDEAD.

It is such a minor issue but it really bugs me.  I'm sure that if I can figure out why Negative Energy Ray isn't working correctly then I can fix the other scripts too.  I really hope someone can help me '<img'>.


//:://///////////////////////////////////////////////:: Negative Energy Ray//:: NW_S0_NegRay//:: Copyright (c) 2001 Bioware Corp.//::///////////////////////////////////////////////*    Fires a bolt of negative energy at the target    doing 1d6 damage.  Does an additional 1d6    damage for 2 levels after level 1 (3,5,7,9) to    a maximum of 5d6 at level 9.*///::////////////////////////////////////////////////:: Created By: Preston Watamaniuk//:: Created On: Sept 13, 2001//:: Modified by: VonTherodere//:://////////////////////////////////////////////
#include "NW_I0_SPELLS"#include "x2_inc_spellhook"
void main(){
/*  Spellcast Hook Code  Added 2003-06-23 by GeorgZ  If you want to make changes to all spells,  check x2_inc_spellhook.nss to find out more
*/
    if (!X2PreSpellCastCode())    {    // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell        return;    }
// End of Spell Cast Hook

    //Declare major variables    object oTarget = GetSpellTargetObject();    int nCasterLevel = GetCasterLevel(OBJECT_SELF);    int nMetaMagic = GetMetaMagicFeat();
    if(nCasterLevel > 9)    {        nCasterLevel = 9;    }    nCasterLevel = (nCasterLevel + 2) / 2;    int nDamage = d8(nCasterLevel);
    //Enter Metamagic conditions    if (nMetaMagic == METAMAGIC_MAXIMIZE)    {        nDamage = 8 * nCasterLevel;//Damage is at max    }    else if (nMetaMagic == METAMAGIC_EMPOWER)    {        nDamage = nDamage + (nDamage/2); //Damage/Healing is +50%    }    effect eVis = EffectVisualEffect(VFX_IMP_NEGATIVE_ENERGY);    effect eDam = EffectDamage(nDamage, DAMAGE_TYPE_NEGATIVE);    effect eHeal = EffectHeal(nDamage);    effect eVisHeal = EffectVisualEffect(VFX_IMP_HEALING_M);    effect eRay;
    if(GetRacialType(oTarget) != RACIAL_TYPE_UNDEAD                && GetSubRace(oTarget) != "Skeleton"                && GetSubRace(oTarget) != "Zombie"                && GetSubRace(oTarget) != "Small Skeleton"                && GetSubRace(oTarget) != "Large Skeleton"                && GetSubRace(oTarget) != "Ghoul"                && GetSubRace(oTarget) != "Wight"                && GetSubRace(oTarget) != "Morhg"                && GetSubRace(oTarget) != "Mummy"                && GetSubRace(oTarget) != "Vampire")    {        if(!GetIsReactionTypeFriendly(oTarget))        {            //Fire cast spell at event for the specified target            SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_NEGATIVE_ENERGY_RAY));            eRay = EffectBeam(VFX_BEAM_EVIL, OBJECT_SELF, BODY_NODE_HAND);            if (!MyResistSpell(OBJECT_SELF, oTarget))            {                //Make a saving throw check                if(/*Will Save*/ MySavingThrow(SAVING_THROW_WILL, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_NEGATIVE))                {                    nDamage /= 2;                }                //Apply the VFX impact and effects                //DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));                DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));                ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);            }        }    }    else    {        //Fire cast spell at event for the specified target        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_NEGATIVE_ENERGY_RAY, FALSE));        eRay = EffectBeam(VFX_BEAM_EVIL, OBJECT_SELF, BODY_NODE_HAND);        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisHeal, oTarget);        ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);    }    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eRay, oTarget, 1.7);}

               
               

               


                     Modifié par VonTherodere, 18 octobre 2011 - 07:48 .
                     
                  


            

Legacy_VonTherodere

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Problem With Spell Scripting
« Reply #1 on: October 18, 2011, 08:49:41 am »


                Sorry beforehand about the weird way the script copied into the post.  Tried to make it look normal but failed :S.
               
               

               
            

Legacy_Morbane

  • Jr. Member
  • **
  • Posts: 79
  • Karma: +0/-0
Problem With Spell Scripting
« Reply #2 on: October 18, 2011, 09:24:34 am »


               //Straightened out a bit

//::///////////////////////////////////////////////
//:: Negative Energy Ray//:: NW_S0_NegRay
//:: Copyright © 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*    Fires a bolt of negative energy at the target    
doing 1d6 damage.  Does an additional 1d6    damage for 2 levels after level 1 (3,5,7,9) to    
a maximum of 5d6 at level 9.*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk//:: Created On: Sept 13, 2001
//:: Modified by: VonTherodere//:://////////////////////////////////////////////
#include "NW_I0_SPELLS"#include "x2_inc_spellhook"
void main(){
/*  Spellcast Hook Code  Added 2003-06-23 by GeorgZ  If you want to make changes to all spells,  check x2_inc_spellhook.nss to find out more
*/
   if (!X2PreSpellCastCode())    
   {    
   // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell        
   return;    
   }
   // End of Spell Cast Hook

   //Declare major variables    
   object oTarget = GetSpellTargetObject();    
   int nCasterLevel = GetCasterLevel(OBJECT_SELF);    
   int nMetaMagic = GetMetaMagicFeat();
   if(nCasterLevel > 9)    
   {        
      nCasterLevel = 9;    
   }    
   nCasterLevel = (nCasterLevel + 2) / 2;    
   int nDamage = d8(nCasterLevel);
   
   //Enter Metamagic conditions    
   if (nMetaMagic == METAMAGIC_MAXIMIZE)    
   {        
      nDamage = 8 * nCasterLevel;//Damage is at max    
   }    
   else if (nMetaMagic == METAMAGIC_EMPOWER)    
   {        
      nDamage = nDamage + (nDamage/2); //Damage/Healing is +50%    
   }    
   effect eVis = EffectVisualEffect(VFX_IMP_NEGATIVE_ENERGY);    
   effect eDam = EffectDamage(nDamage, DAMAGE_TYPE_NEGATIVE);    
   effect eHeal = EffectHeal(nDamage);    
   effect eVisHeal = EffectVisualEffect(VFX_IMP_HEALING_M);    
   effect eRay;
   if(GetRacialType(oTarget) != RACIAL_TYPE_UNDEAD && GetSubRace(oTarget) != "Skeleton" &&
                                          GetSubRace(oTarget) != "Zombie" &&
                                          GetSubRace(oTarget) != "Small Skeleton" &&
                                          GetSubRace(oTarget) != "Large Skeleton" &&
                                          GetSubRace(oTarget) != "Ghoul" &&
                                          GetSubRace(oTarget) != "Wight" &&
                                          GetSubRace(oTarget) != "Morhg" &&
                                          GetSubRace(oTarget) != "Mummy" &&
                                          GetSubRace(oTarget) != "Vampire")
   {        
      if(!GetIsReactionTypeFriendly(oTarget))        
      {            
         //Fire cast spell at event for the specified target            
         SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_NEGATIVE_ENERGY_RAY));            
         eRay = EffectBeam(VFX_BEAM_EVIL, OBJECT_SELF, BODY_NODE_HAND);            
         if (!MyResistSpell(OBJECT_SELF, oTarget))            
         {                
            //Make a saving throw check                
            if(/*Will Save*/ MySavingThrow(SAVING_THROW_WILL, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_NEGATIVE))                
            {                    
               nDamage /= 2;                
            }                
            //Apply the VFX impact and effects                
            //DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));                
            DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));                
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);            
         }        
      }    
   }    
   else    
   {        
      //Fire cast spell at event for the specified target        
      SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_NEGATIVE_ENERGY_RAY, FALSE));        
      eRay = EffectBeam(VFX_BEAM_EVIL, OBJECT_SELF, BODY_NODE_HAND);        
      ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisHeal, oTarget);        
      ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);    
   }    
   ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eRay, oTarget, 1.7);
}
:innocent:
               
               

               


                     Modifié par Morbane, 18 octobre 2011 - 08:25 .
                     
                  


            

Legacy_VonTherodere

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Problem With Spell Scripting
« Reply #3 on: October 18, 2011, 09:39:54 am »


               Thanks '<img'>.  Looks a lot better now '<img'>