Author Topic: Wand, Potion, Scroll Crafting Feats Broken  (Read 3080 times)

Legacy_TripleXM

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Wand, Potion, Scroll Crafting Feats Broken
« on: July 30, 2016, 04:28:09 am »


               

Apparently, I did something years ago to break the aforementioned crafting feats in my module and I can't figure out what. I do know that if I bypass this spellhook script, item crafting works again:



#include "x2_inc_switches"
#include "NW_I0_SPELLS"
#include "x2_i0_spells"
#include "x2_inc_toollib"
#include "x2_inc_craft"
#include "wdm_inc"
#include "oai_inc_weapstat"
#include "sha_subr_methds"
#include "69_hench_lib"

//:****************************************************************************/
//: FUNCTIONS

int DetermineDuration()
{
    int nDuration = 1 + d4(1);
    int nSeconds = nDuration;
    int nDOverride = GetLocalInt(GetModule(),"TIMESTOP_DUR");
    if(nDOverride != 0) nSeconds = nDOverride;
    return nSeconds;
}

void TimeStopDelay(object oCaster)
{
    int nDelay = GetLocalInt(GetModule(),"TIMESTOP_DEL");
    float fDelay = IntToFloat(nDelay);
    float Delay1 = fDelay * 0.25;
    string Message1 = IntToString(FloatToInt(Delay1));
    float Delay2 = fDelay * 0.50;
    string Message2 = IntToString(FloatToInt(Delay2));
    float Delay3 = fDelay * 0.75;
    string Message3 = IntToString(FloatToInt(Delay3));
    SetLocalInt(oCaster, "TIMESTOP_DELAY", 1);
    FloatingTextStringOnCreature("Time Stop Recastable In " + IntToString(nDelay) + " seconds", oCaster, FALSE);
    DelayCommand(Delay1, FloatingTextStringOnCreature("Time Stop Recastable In " + Message3 + " seconds", oCaster, FALSE));
    DelayCommand(Delay2, FloatingTextStringOnCreature("Time Stop Recastable In " + Message2 + " seconds", oCaster, FALSE));
    DelayCommand(Delay3, FloatingTextStringOnCreature("Time Stop Recastable In " + Message1 + " seconds", oCaster, FALSE));
    DelayCommand(fDelay, FloatingTextStringOnCreature("Time Stop Ready", oCaster, FALSE));
    DelayCommand(fDelay, DeleteLocalInt(oCaster, "TIMESTOP_DELAY"));
}

void Timestop(object oCaster)
{
    object oArea = GetArea(oCaster);
    int nDuration = DetermineDuration();
    float fDuration = IntToFloat(nDuration);

    //Time Stop is AOE or Area Wide
    int nTSAOE = GetLocalInt(GetModule(),"TSAOE");

    if(nTSAOE == 0)
    {
      object oTarget = GetFirstObjectInArea(oArea);
      while (GetIsObjectValid(oTarget))
      {
        if(GetIsPC(oTarget) == TRUE || GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
        {
          if(GetHasEffect(EFFECT_TYPE_CUTSCENE_PARALYZE,oTarget) == FALSE && oTarget != OBJECT_SELF)
          {
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectVisualEffect(VFX_DUR_FREEZE_ANIMATION),oTarget,fDuration);
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectCutsceneParalyze(),oTarget,fDuration);
          }
        }
        oTarget = GetNextObjectInArea(oArea);
      }
    }
    else
    {
      //Radius of the Time Stop Spell
      int nRadius = GetLocalInt(GetModule(),"TSRAD");
      float fRadius = IntToFloat(nRadius);

      location lSpell = GetSpellTargetLocation();
      ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_TIME_STOP),OBJECT_SELF);

      //Freeze All Creatures
      object oTarget = GetFirstObjectInShape(SHAPE_SPHERE,fRadius,lSpell,TRUE,OBJECT_TYPE_CREATURE);
      while(oTarget != OBJECT_INVALID)
      {
        if(GetHasEffect(EFFECT_TYPE_CUTSCENE_PARALYZE,oTarget) == FALSE && oTarget != OBJECT_SELF)
        {
          ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectVisualEffect(VFX_DUR_FREEZE_ANIMATION),oTarget,fDuration);
          ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectCutsceneParalyze(),oTarget,fDuration);
        }
        oTarget = GetNextObjectInShape(SHAPE_SPHERE,fRadius,lSpell,TRUE,OBJECT_TYPE_CREATURE);
      }
    }
}

void TimestopCheck(object oCaster, int nDuration)
{
    if (nDuration == 0) return;

    nDuration = nDuration - 1;
    float fDuration = IntToFloat(nDuration);
    object oArea = GetArea(oCaster);
    location lCaster = GetLocation(oCaster);

    effect eParalyze = EffectCutsceneParalyze();
    object oTarget = GetFirstObjectInArea(oArea);

    while (GetIsObjectValid(oTarget))
    {
      if(GetIsPC(oTarget) == TRUE || GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
      {
        if(GetIsDM(oTarget) == FALSE)
        {
          if(oTarget != oCaster)
          {
            effect eEffect = GetFirstEffect(oTarget);
            while (GetIsEffectValid(eEffect))
            {
              if(GetEffectType(eEffect) == EFFECT_TYPE_CUTSCENE_PARALYZE)
              {
                SetLocalInt(oTarget, "TIME_STOPPED", 1);
              }
              eEffect = GetNextEffect(oTarget);
            }

            if(GetLocalInt(oTarget, "TIME_STOPPED") == 0)
            {
              FloatingTextStringOnCreature("Time Stopped", oTarget, FALSE);
              AssignCommand(oTarget, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eParalyze, oTarget, fDuration));
            }

            DeleteLocalInt(oTarget, "TIME_STOPPED");
          }
        }
      }

     oTarget = GetNextObjectInArea(oArea);
   }

   DelayCommand(1.0, TimestopCheck(oCaster, nDuration));
}

void GSStopDelay(object oCaster)
{
    int nDelay = GetLocalInt(GetModule(),"GSANCTUARY_DEL");//In Rounds
    float fDelay = IntToFloat(nDelay);
    float Delay1 = fDelay * 0.25;
    string Message1 = IntToString(FloatToInt(Delay1));
    float Delay2 = fDelay * 0.50;
    string Message2 = IntToString(FloatToInt(Delay2));
    float Delay3 = fDelay * 0.75;
    string Message3 = IntToString(FloatToInt(Delay3));
    SetLocalInt(oCaster, "GSANCTUARY_DELAY", 1);
    SendMessageToPC(oCaster,"Greater Sanctuary Recastable In " + IntToString(nDelay) + " seconds");
    DelayCommand(Delay1, SendMessageToPC(oCaster,"Greater Sanctuary Recastable In " + Message3 + " seconds"));
    DelayCommand(Delay2, SendMessageToPC(oCaster,"Greater Sanctuary Recastable In " + Message2 + " seconds"));
    DelayCommand(Delay3, SendMessageToPC(oCaster,"Greater Sanctuary Recastable In " + Message1 + " seconds"));
    DelayCommand(fDelay, SendMessageToPC(oCaster,"Greater Sanctuary Ready"));
    DelayCommand(fDelay, DeleteLocalInt(oCaster, "GSANCTUARY_DELAY"));
}

//:****************************************************************************/
//: SSE - Shayan's Subrace System (Implemented by Olander...Original NOT Vaild!!!)

void ORS_SpellsCure(int nDamage, int nMaxExtraDamage, int nMaximized, int vfx_impactHurt, int vfx_impactHeal, int nSpellID)
{
    //Declare major variables
    object oTarget = GetSpellTargetObject();
    int nHeal;
    int nMetaMagic = GetMetaMagicFeat();
    effect eHeal, eDam;

    int nExtraDamage = GetCasterLevel(OBJECT_SELF); // * figure out the bonus damage
    if (nExtraDamage > nMaxExtraDamage)
    {
        nExtraDamage = nMaxExtraDamage;
    }
    // * if low or normal difficulty is treated as MAXIMIZED
    if(GetIsPC(oTarget) && GetGameDifficulty() < GAME_DIFFICULTY_CORE_RULES)
    {
        nDamage = nMaximized + nExtraDamage;
    }
    else
    {
        nDamage = nDamage + nExtraDamage;
    }


    //Make metamagic checks
    if (nMetaMagic == METAMAGIC_MAXIMIZE)
    {
        nDamage = nMaximized + nExtraDamage;
        // * if low or normal difficulty then MAXMIZED is doubled.
        if(GetIsPC(OBJECT_SELF) && GetGameDifficulty() < GAME_DIFFICULTY_CORE_RULES)
        {
            nDamage = nDamage + nExtraDamage;
        }
    }
    if (nMetaMagic == METAMAGIC_EMPOWER || GetHasFeat(FEAT_HEALING_DOMAIN_POWER))
    {
        nDamage = nDamage + (nDamage/2);
    }

    int nTouch = TouchAttackMelee(oTarget);
    if (nTouch > 0)
    {
        if(Subrace_GetIsUndead(oTarget))
        {
            //Fire cast spell at event for the specified target
            SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, nSpellID));
            if (!MyResistSpell(OBJECT_SELF, oTarget))
            {
                eDam = EffectDamage(nDamage,DAMAGE_TYPE_POSITIVE);
                //Apply the VFX impact and effects
                DelayCommand(1.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
                effect eVis = EffectVisualEffect(vfx_impactHurt);
                ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
            }
        }
     }
}

void ORS_SpellsInflictTouchAttack(int nDamage, int nMaxExtraDamage, int nMaximized, int vfx_impactHurt, int vfx_impactHeal, int nSpellID)
{
    //Declare major variables
    object oTarget = GetSpellTargetObject();
    int nMetaMagic = GetMetaMagicFeat();
    int nTouch = TouchAttackMelee(oTarget);

    int nExtraDamage = GetCasterLevel(OBJECT_SELF); // * figure out the bonus damage
    if (nExtraDamage > nMaxExtraDamage)
    {
        nExtraDamage = nMaxExtraDamage;
    }

        //Check for metamagic
    if (nMetaMagic == METAMAGIC_MAXIMIZE)
    {
        nDamage = nMaximized;
    }
    else
    if (nMetaMagic == METAMAGIC_EMPOWER)
    {
        nDamage = nDamage + (nDamage / 2);
    }


    //Check that the target is undead.
    //Edited For Shayan's Subrace Engine.
    if (Subrace_GetIsUndead(oTarget))
    {
        effect eVis2 = EffectVisualEffect(vfx_impactHeal);
        //Figure out the amount of damage to heal
        //nHeal = nDamage;
        //Set the heal effect
        effect eHeal = EffectHeal(nDamage + nExtraDamage);
        //Apply heal effect and VFX impact
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget);
        //Fire cast spell at event for the specified target
        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, nSpellID, FALSE));
    }
}

//: SSE - Shayan's Subrace System (Implemented by Olander...Original NOT Vaild!!!)
//:****************************************************************************/

//: FUNCTIONS
//:****************************************************************************/

void main()
{
  object oMod = GetModule();

  int nSpell = GetSpellId(); // returns the SPELL_* constant of the spell cast
  object oTarget = GetSpellTargetObject();
  location lTarget = GetSpellTargetLocation();
  int nCasterLevel = GetCasterLevel(OBJECT_SELF);
  location lLoc = GetLocation(OBJECT_SELF);
  int nCasterAlignment = GetAlignmentGoodEvil(OBJECT_SELF);
  int nTargetLevel = GetHitDice(oTarget);
  float fDuration=0.0f;
  effect eEffect1,eEffect2,eEffect3;
  int nUndeadSSE = Subrace_GetIsUndead(oTarget);
  int nUndeadR = GetRacialType(oTarget);

  //Undeads
  int IsUndead = FALSE;
  if(GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD) IsUndead = TRUE;
  if(nUndeadSSE == TRUE) IsUndead = TRUE;


  int nCLEAR = FALSE;
  int nType = GetObjectType(oTarget);
  if(nType == OBJECT_TYPE_ITEM)
  {
    if(CIGetIsCraftFeatBaseItem(oTarget))
    {
      if(GetLocalInt(oMod,"BIOCRAFT") <= 0)
      {
        SetModuleOverrideSpellScriptFinished();
        return;
      }
      else nCLEAR = TRUE;
    }
  }

//:****************************************************************************/
//: DEAD AND WILD MAGIC

  if(WDM_HandleMagicZone() == TRUE && nCLEAR == TRUE)
  {
    SetModuleOverrideSpellScriptFinished();
    return;
  }

//: DEAD AND WILD MAGIC
//:****************************************************************************/

  if(nCLEAR == TRUE) return;

  switch(nSpell)
  {

//:****************************************************************************/
//: AREA SPECIFIC TIME STOP

    case SPELL_TIME_STOP:
    {
      if(GetLocalInt(oMod,"TIMESTOP") == 1)
      {
        if(GetLocalInt(OBJECT_SELF, "TIMESTOP_DELAY") == 1)
        {
          FloatingTextStringOnCreature("Timestop is not castable yet", OBJECT_SELF, FALSE);
          SetModuleOverrideSpellScriptFinished();
          break;
        }

        int nDelay = GetLocalInt(GetModule(),"TIMESTOP_DEL");
        float fDelay = IntToFloat(nDelay);
        if(nDelay > 0){ DelayCommand(1.0, TimeStopDelay(OBJECT_SELF)); }

        location lTarget = GetSpellTargetLocation();
        effect eVis = EffectVisualEffect(VFX_FNF_TIME_STOP);
        int nDuration = DetermineDuration();

        //Fire cast spell at event for the specified target
        SignalEvent(OBJECT_SELF, EventSpellCastAt(OBJECT_SELF, SPELL_TIME_STOP, FALSE));

        ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, lTarget);
        Timestop(OBJECT_SELF);
        DelayCommand(1.0, TimestopCheck(OBJECT_SELF, nDuration));

        SetModuleOverrideSpellScriptFinished();
      }
      break;
    }

//: AREA SPECIFIC TIME STOP
//:****************************************************************************/

//:****************************************************************************/
//: GREATER SANCTUARY FIX

    case SPELL_ETHEREALNESS:
    {
      if(GetLocalInt(oMod,"GSANCTUARY") == 1)
      {
        if(GetLocalInt(OBJECT_SELF, "GSANCTUARY_DELAY") == 1)
        {
          FloatingTextStringOnCreature("Greater Sanctuary is not castable yet.", OBJECT_SELF, FALSE);
          SetModuleOverrideSpellScriptFinished();
          break;
        }

        //Spell Duration (in rounds)
        int nRoll = d8();
        if(nRoll < 4) nRoll = 4;
        int nDuration = nRoll;
        int nDurCheck = GetLocalInt(oMod,"GSANCTUARY_DUR");
        if(nDurCheck > 0) nDuration = nDurCheck;

        //Casting Delay
        int nDelay = 0;
        int nDelCheck = GetLocalInt(GetModule(),"GSANCTUARY_DEL");
        if(nDelCheck > 0)
        {
          nDuration = nDelCheck;
        }

        if(nDuration > 0)
        {
          if(GetIsPC(oTarget)) GSStopDelay(oTarget);
        }

        effect eVis = EffectVisualEffect(VFX_DUR_SANCTUARY);
        effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE);
        effect eSanc = EffectEthereal();

        effect eLink = EffectLinkEffects(eVis, eSanc);
        eLink = EffectLinkEffects(eLink, eDur);

        //Enter Metamagic conditions
        int nMetaMagic = GetMetaMagicFeat();
        if(nMetaMagic == METAMAGIC_EXTEND)
        {
          nDuration = nDuration *2; //Duration is +100%
        }

        //Fire cast spell at event for the specified target
        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_ETHEREALNESS, FALSE));

        //Apply the VFX impact and effects
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, RoundsToSeconds(nDuration));
        AssignCommand(oTarget, ClearAllActions());

        SetModuleOverrideSpellScriptFinished();
      }
      break;
    }

//: GREATER SANCTUARY FIX
//:****************************************************************************/

//:****************************************************************************/
//: PHB HARM

    case SPELL_HARM:
    {
      if(GetLocalInt(oMod,"PHBHARM") == 1)
      {
        object oCaster = OBJECT_SELF;
        int nCaster = GetHitDice(oCaster);
        object oTarget = GetSpellTargetObject();
        int nDamage, nHarm;
        int nMetaMagic = GetMetaMagicFeat();
        int nTouch = TouchAttackMelee(oTarget);
        effect eVis = EffectVisualEffect(246);
        effect eVis2 = EffectVisualEffect(VFX_IMP_HEALING_G);
        effect eHeal, eDam;

        //PHB Max Value
        int nMV = 150;

        int nCHP = GetCurrentHitPoints(oTarget);
        int nMHP = GetMaxHitPoints(oTarget);

        //Determine Amount Cap At Max
        nHarm = 10 * nCaster;
        if(nHarm > nMV) nHarm = nMV;

        //Check for Metamagic Maximized
        if(nMetaMagic == METAMAGIC_MAXIMIZE) nHarm = nMV;

        //Check that the target is undead
        if(IsUndead)
        {
          //Heal Amount
          int nDiff = nMHP - nCHP;
          if(nDiff > nHarm) nHarm = nDiff;

          eHeal = EffectHeal(nHarm);
          ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
          ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget);

          //Fire cast spell at event for the specified target
          SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_HARM, FALSE));
        }

        else if (nTouch != FALSE)
        {
          if(!GetIsReactionTypeFriendly(oTarget))
          {
            //Fire cast spell at event for the specified target
            SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_HARM, TRUE));

            if(!MyResistSpell(OBJECT_SELF, oTarget))
            {
              //Harm Amount
              if(nCHP < nHarm) nHarm = nCHP - d4(1);

              eDam = EffectDamage(nHarm,DAMAGE_TYPE_NEGATIVE);
              DelayCommand(1.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
              ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
            }
          }
        }

        SetModuleOverrideSpellScriptFinished();
      }
      break;
    }

//: PHB HARM
//:****************************************************************************/

//:****************************************************************************/
//: PHB HEAL AND MASS HEAL

    case SPELL_HEAL:
    {
      if(GetLocalInt(oMod,"PHBHEAL") == 1)
      {
        object oCaster = OBJECT_SELF;
        int nCaster = GetHitDice(oCaster);
        object oTarget = GetSpellTargetObject();
        int nDamage, nHeal;
        int nMetaMagic = GetMetaMagicFeat();
        int nTouch = TouchAttackMelee(oTarget);
        effect eVis = EffectVisualEffect(VFX_IMP_SUNSTRIKE);
        effect eVis2 = EffectVisualEffect(VFX_IMP_HEALING_X);
        effect eHeal, eDam;

        //PHB Max Value
        int nMV = 150;

        int nCHP = GetCurrentHitPoints(oTarget);
        int nMHP = GetMaxHitPoints(oTarget);

        //Determine Amount
        nHeal = 10 * nCaster;
        if(nHeal > nMV) nHeal = nMV;

        //Check for Metamagic Maximized
        if(nMetaMagic == METAMAGIC_MAXIMIZE) nHeal = nMV;

        //Check that the target is undead
        if(IsUndead)
        {
          if(!GetIsReactionTypeFriendly(oTarget))
          {
            //Fire cast spell at event for the specified target
            SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_HEAL, TRUE));

            //Make SR check
            if(!MyResistSpell(OBJECT_SELF, oTarget))
            {
              //Harm Amount
              if(nCHP <= nHeal) nHeal = nCHP - d4(1);

              eDam = EffectDamage(nHeal, DAMAGE_TYPE_POSITIVE);
              ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);
              ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
            }
          }
        }
        else
        {
          //Fire cast spell at event for the specified target
          SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_HEAL, FALSE));

          //Heal Amount
          int nDiff = nMHP - nCHP;
          if(nDiff < nHeal) nHeal = nDiff;

          eHeal = EffectHeal(nHeal);
          ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
          ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget);

          object oArea = GetArea(oTarget);
          string sTag = GetTag(oTarget);

          if(GetIsHenchmanDying(oTarget))
          {
          SetLocalInt(oArea, "nCHP" +sTag, 21);
          }
        }

        SetModuleOverrideSpellScriptFinished();
      }
      break;
    }

    case SPELL_MASS_HEAL:
    {
      if(GetLocalInt(oMod,"PHBHEAL") == 1)
      {
        object oCaster = OBJECT_SELF;
        int nCaster = GetHitDice(oCaster);
        int nDamage, nHeal, nTouch;
        int nMetaMagic = GetMetaMagicFeat();
        effect eVis = EffectVisualEffect(VFX_IMP_SUNSTRIKE);
        effect eVis2 = EffectVisualEffect(VFX_IMP_HEALING_G);
        effect eStrike = EffectVisualEffect(VFX_FNF_LOS_HOLY_10);
        effect eHeal, eDam;
        float fDelay;

        //PHB Max Value
        int nMV = 250;

        int nCHP = GetCurrentHitPoints(oTarget);
        int nMHP = GetMaxHitPoints(oTarget);

        //Determine Amount
        nHeal = 10 * nCaster;
        if(nHeal > nMV) nHeal = nMV;

        //Check for Metamagic Maximized
        if(nMetaMagic == METAMAGIC_MAXIMIZE) nHeal = nMV;

        //Apply VFX at Location
        location lLoc =  GetSpellTargetLocation();
        ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eStrike, lLoc);

        //Get first target in spell area
        object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_MEDIUM, lLoc);
        while(GetIsObjectValid(oTarget))
        {
          fDelay = GetRandomDelay();

          //Check that the target is undead and unfriendly
          if(GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD && !GetIsReactionTypeFriendly(oTarget))
          {
            //Fire cast spell at event for the specified target
            SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_MASS_HEAL, TRUE));

            //Make a touch attack
            nTouch = TouchAttackRanged(oTarget);
            if(nTouch > 0)
            {
              //Make SR check
              if(!MyResistSpell(OBJECT_SELF, oTarget))
              {
                //Harm Amount
                if(nCHP <= nHeal) nHeal = nCHP - d4(1);

                eDam = EffectDamage(nHeal, DAMAGE_TYPE_POSITIVE);
                DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
                DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
              }
            }
          }

          else
          {
            if(GetIsFriend(oTarget) && GetRacialType(oTarget) != RACIAL_TYPE_UNDEAD)
            {
              //Fire cast spell at event for the specified target
              SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_HEAL, FALSE));

              //Heal Amount
              int nDiff = nMHP - nCHP;
              if(nDiff < nHeal) nHeal = nDiff;

              eHeal = EffectHeal(nHeal);
              ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
              ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget);
              object oArea = GetArea(oTarget);
              string sTag = GetTag(oTarget);

              if(GetIsHenchmanDying(oTarget))
              {
              SetLocalInt(oArea, "nCHP" +sTag, nCHP + nHeal);
              }
            }
          }

          oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_MEDIUM, lLoc);
        }

        SetModuleOverrideSpellScriptFinished();
      }
      break;
    }

//: PHB HEAL AND MASS HEAL
//:****************************************************************************/

//:****************************************************************************/
//: CONTINUAL FLAME EXPLOIT FIX (Thanks to CFX for this)

    case SPELL_CONTINUAL_FLAME:
    {
     if(GetLocalInt(oMod,"CFLAME") == 1)
     {
      int nDuration;
      int nMetaMagic;
      object oTarget = GetSpellTargetObject();

      // Handle spell cast on item....
      if((GetObjectType(oTarget) == OBJECT_TYPE_ITEM) && !CIGetIsCraftFeatBaseItem(oTarget))
      {
        // Do not allow casting on not equippable items
        if(!IPGetIsItemEquipable(oTarget))
        {
          // Item must be equipable...
          FloatingTextStrRefOnCreature(83326,OBJECT_SELF);
          SetModuleOverrideSpellScriptFinished();
          return;
        }
        itemproperty ip = ItemPropertyLight (IP_CONST_LIGHTBRIGHTNESS_BRIGHT, IP_CONST_LIGHTCOLOR_WHITE);
        DelayCommand(0.01, IPSafeAddItemProperty(oTarget, ip, HoursToSeconds(1000), X2_IP_ADDPROP_POLICY_KEEP_EXISTING, TRUE, TRUE));
      }
      else
      {
        //Declare major variables
        effect eVis = (EffectVisualEffect(VFX_DUR_LIGHT_WHITE_20));
        effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE);
        effect eLink = SupernaturalEffect(EffectLinkEffects(eVis, eDur));

        //Fire cast spell at event for the specified target
        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, 419, FALSE));

        //Apply the VFX impact and effects
        ApplyEffectToObject(DURATION_TYPE_PERMANENT, eLink, oTarget);
      }
      SetModuleOverrideSpellScriptFinished();
     }
     break;
    }

//: CONTINUAL FLAME EXPLOIT FIX
//:****************************************************************************/

//:****************************************************************************/
//: OLANDER'S EPIC SUMMONING

    case SPELL_GATE:
    {
      //Module Config
      if(GetLocalInt(oMod,"GATE") != 1) break;

      // Creature duration
      fDuration = RoundsToSeconds(20);

      effect eSummon;
      effect eVis = EffectVisualEffect(VFX_FNF_SUMMON_GATE);

      //Summon the Balrog and apply the VFX impact
      location lSpellTargetLOC = GetSpellTargetLocation();

      if(GetHasSpellEffect(SPELL_PROTECTION_FROM_EVIL) ||
        GetHasSpellEffect(SPELL_MAGIC_CIRCLE_AGAINST_EVIL) ||
        GetHasSpellEffect(SPELL_HOLY_AURA))
      {
        eSummon = EffectSummonCreature("sum_lbalrog",VFX_FNF_SUMMON_GATE,3.0);
        DelayCommand(3.0, ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, lSpellTargetLOC, fDuration));
      }
      else
      {
        ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, lSpellTargetLOC);
        object oLBalrog = CreateObject(OBJECT_TYPE_CREATURE, "hos_lbalrog", GetSpellTargetLocation());
        DestroyObject(oLBalrog,fDuration);
      }

      SetModuleOverrideSpellScriptFinished();
      break;
    }

    case SPELL_EPIC_DRAGON_KNIGHT:
    {
      //Module Config
      if(GetLocalInt(oMod,"EDK") != 1) break;

      // Creature duration
      fDuration=RoundsToSeconds(20);

      effect effect1; effect effect2;

      if(nCasterAlignment==ALIGNMENT_EVIL)
      {
        eEffect2=EffectVisualEffect(VFX_FNF_SUMMON_GATE);
        eEffect1=EffectSummonCreature("sum_dragknight",481,0.0f,TRUE);
      }
      if(nCasterAlignment==ALIGNMENT_GOOD)
      {
        eEffect2=EffectVisualEffect(VFX_FNF_SUMMON_CELESTIAL);
        eEffect1=EffectSummonCreature("sum_cendrial",481,0.0f,TRUE);
      }
      if(nCasterAlignment==ALIGNMENT_NEUTRAL)
      {
        eEffect2=EffectVisualEffect(VFX_FNF_NATURES_BALANCE);
        eEffect1=EffectSummonCreature("sum_treant",481,0.0f,TRUE);
      }

      // Make Dragon Aura Undispellable
      eEffect1=ExtraordinaryEffect(eEffect1);

      ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY,eEffect1,lTarget,fDuration);
      DelayCommand(1.0f,ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY,eEffect2,lTarget));

      SetModuleOverrideSpellScriptFinished();
      break;
    }

    case SPELL_EPIC_MUMMY_DUST:
    {
      //Module Config
      if(GetLocalInt(oMod,"EMD") != 1) break;

      // Creature duration
      fDuration = RoundsToSeconds(20);
      effect eSummon;
      eSummon = EffectSummonCreature("sum_gmummy",496,1.0f);
      eSummon = ExtraordinaryEffect(eSummon);
      effect eVis = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
      //Apply the summon visual and summon the undead.
      ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetSpellTargetLocation());
      ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, GetSpellTargetLocation(), fDuration);

      SetModuleOverrideSpellScriptFinished();
      break;
    }

//: OLANDER'S EPIC SUMMONING
//:****************************************************************************/

//:****************************************************************************/
//: IMPROVED SUMMONING (By Olander, Daschel, and Chara Swift)

    case SPELL_SUMMON_CREATURE_I:
    case SPELL_SUMMON_CREATURE_II:
    case SPELL_SUMMON_CREATURE_III:
    case SPELL_SUMMON_CREATURE_IV:
    case SPELL_SUMMON_CREATURE_V:
    case SPELL_SUMMON_CREATURE_VI:
    case SPELL_SUMMON_CREATURE_VII:
    case SPELL_SUMMON_CREATURE_VIII:
    case SPELL_SUMMON_CREATURE_IX:
    {
       //Module Config
       if(GetLocalInt(oMod,"ISUM") != 1) break;

       // Creature constants
       string sSummon = "summon_";

       // Summon Alignment Level Spell Number Constant Creator
       // szFinalSummon2 = "summon_" + <caster_alignment> + "_" + <spell> + "_"
       // example for spell_summon_creature_I casted by good aligned spellcaster:
       // szFinalSummon2 = "summon_good_i_"

       if(nCasterAlignment==ALIGNMENT_EVIL)
       {
         eEffect2=EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3);
         sSummon = "summon_evil";
       }
       else
       {
         eEffect2=EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_2);
         sSummon = "summon_good";
       }

       // Which Summon Creature Spell ?
       if(GetHasFeat(FEAT_ANIMAL_DOMAIN_POWER))
       {
         if(nSpell==SPELL_SUMMON_CREATURE_I){sSummon = sSummon + "_i";}
         else if(nSpell==SPELL_SUMMON_CREATURE_II){sSummon = sSummon + "_ii";}
         else if(nSpell==SPELL_SUMMON_CREATURE_III){sSummon = sSummon + "_iii";}
         else if(nSpell==SPELL_SUMMON_CREATURE_IV){sSummon = sSummon + "_iv";}
         else if(nSpell==SPELL_SUMMON_CREATURE_V){sSummon = sSummon + "_vi";}
         else if(nSpell==SPELL_SUMMON_CREATURE_VI){sSummon = sSummon + "_vi";}
         else if(nSpell==SPELL_SUMMON_CREATURE_VII){sSummon = sSummon + "_vii";}
         else if(nSpell==SPELL_SUMMON_CREATURE_VIII){sSummon = sSummon + "_viii";}
         else {sSummon = sSummon + "_ix";}
       }
       else
       {
         if(nSpell==SPELL_SUMMON_CREATURE_I){sSummon = sSummon + "_i";}
         else if(nSpell==SPELL_SUMMON_CREATURE_II){sSummon = sSummon + "_ii";}
         else if(nSpell==SPELL_SUMMON_CREATURE_III){sSummon = sSummon + "_iii";}
         else if(nSpell==SPELL_SUMMON_CREATURE_IV){sSummon = sSummon + "_iv";}
         else if(nSpell==SPELL_SUMMON_CREATURE_V){sSummon = sSummon + "_v";}
         else if(nSpell==SPELL_SUMMON_CREATURE_VI){sSummon = sSummon + "_vi";}
         else if(nSpell==SPELL_SUMMON_CREATURE_VII){sSummon = sSummon + "_vii";}
         else if(nSpell==SPELL_SUMMON_CREATURE_VIII){sSummon = sSummon + "_viii";}
         else {sSummon = sSummon + "_ix";}
       }

       // Creature duration (Rounds/Level, 3 Min, 10 Max)
       //if(nCasterLevel < 3) nCasterLevel = 3;
       //if(nCasterLevel > 10) nCasterLevel = 10;
       fDuration = TurnsToSeconds(nCasterLevel);
       int nMetaMagic = GetMetaMagicFeat();

       if(nMetaMagic == METAMAGIC_EXTEND)
       {
         fDuration*=2;
       }

       // Create Summon and Visual Effect
       eEffect1=EffectSummonCreature(sSummon);
       ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY,eEffect2,lTarget);
       ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY,eEffect1,lTarget,fDuration);

       SetModuleOverrideSpellScriptFinished();
       break;
    }

//: IMPROVED SUMMONING
//:****************************************************************************/

//:****************************************************************************/
//: OLANDER'S PLANAR SUMMONING

    case SPELL_GREATER_PLANAR_BINDING:
    case SPELL_LESSER_PLANAR_BINDING:
    case SPELL_PLANAR_ALLY:
    case SPELL_PLANAR_BINDING:
    {
       //Module Config
       if(GetLocalInt(oMod,"IPSUM") != 1) break;

       // Creature constants
       string sSummon = "summon_";

       // Summon Alignment Level Spell Number Constant Creator
       // szFinalSummon2 = "summon_" + <caster_alignment> + "_" + <spell> + "_"
       // example for spell_summon_creature_I casted by good aligned spellcaster:
       // szFinalSummon2 = "summon_good_i_"

       if(nCasterAlignment==ALIGNMENT_EVIL)
       {
         eEffect2=EffectVisualEffect(VFX_FNF_SUMMON_GATE);
         sSummon = "summon_evil";
       }
       else
       {
         eEffect2=EffectVisualEffect(VFX_FNF_SUMMON_CELESTIAL);
         sSummon = "summon_good";
       }

       if(nSpell==SPELL_PLANAR_BINDING){sSummon = sSummon + "_pb";}
       else if(nSpell==SPELL_PLANAR_ALLY){sSummon = sSummon + "_lpb";}
       else if(nSpell==SPELL_LESSER_PLANAR_BINDING){sSummon = sSummon + "_lpb";}
       else if(nSpell==SPELL_GREATER_PLANAR_BINDING){sSummon = sSummon + "_gpb";}
       else {sSummon = sSummon + "_vi";}

       // Creature duration (Rounds/Level, 3 Min, 10 Max)
       //if(nCasterLevel < 3) nCasterLevel = 3;
       //if(nCasterLevel > 10) nCasterLevel = 10;
       fDuration = TurnsToSeconds(nCasterLevel);
       int nMetaMagic = GetMetaMagicFeat();

       if(nMetaMagic == METAMAGIC_EXTEND)
       {
         fDuration*=2;
       }

       // Create Summon and Visual Effect
       eEffect1=EffectSummonCreature(sSummon);
       ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY,eEffect2,lTarget);
       ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY,eEffect1,lTarget,fDuration);

       SetModuleOverrideSpellScriptFinished();
       break;
    }

//: OLANDER'S PLANAR SUMMONING
//:****************************************************************************/

//:****************************************************************************/
//: PHB RAISE DEAD (THROUGH LOOTABLE CORPSES)

    case SPELL_RAISE_DEAD:
    {
      //Declare major variables
      object oTarget = GetSpellTargetObject();
      effect eRaise = EffectResurrection();
      effect eVis = EffectVisualEffect(VFX_IMP_RAISE_DEAD);
      if(GetIsDead(oTarget))
      {
        //Fire cast spell at event for the specified target
        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_RAISE_DEAD, FALSE));
        //Apply raise dead effect and VFX impact
        ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(oTarget));
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eRaise, oTarget);
      }

      // The following lines have been added to support Scrotok's Lootable Corpses script
      // Fire SpellCastAt event for lootable corpse placeables or bones
      // (Raise Dead won't work for bones, but _kb_raise_res" takes care of that)
      if ((GetTag(oTarget) == "invis_corpse_obj") || (GetTag(oTarget) == "loot_bones_obj"))
      {
        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_RAISE_DEAD, FALSE));
      }

      //For OUW - Underwater System
      object oUWWP = GetNearestObjectByTag("Underwater",oTarget);
      if(GetIsObjectValid(oUWWP) && GetIsPC(oTarget))
      {
        //Destroy Old Underwater Item
        object oUW = GetItemPossessedBy(oTarget,"UnderWater");
        if(GetIsObjectValid(oUW)) DestroyObject(oUW);

        //Now Make a New Underwater Item
        oUW = CreateItemOnObject("underwater",oTarget);

        //Now Figure out How Many Rounds a Player Can Breath
        int nRounds = 20;
        int nCON = GetAbilityModifier(ABILITY_CONSTITUTION, oTarget);
        if(nCON > 4) nCON = 4;//Remove supernatural abilities
        int nTotal = nRounds - nCON;

        //Set Rounds to Underwater Item
        SetLocalInt(oUW,"UNDERWATER_TOT_ROUNDS",nTotal);
        SetLocalInt(oUW,"UNDERWATER_CUR_ROUNDS",nTotal/2);

        ExecuteScript("ouw_main",oTarget);
      }

      //Reset Forced Respawn
      SetLocalInt(oTarget,"OBD_FORCE_RESPAWN",0);

      //Subraces
      DelayCommand(2.0, ReapplySubraceAbilities(oTarget));

      SetModuleOverrideSpellScriptFinished();
      break;
    }

//: PHB RAISE DEAD (THROUGH LOOTABLE CORPSES)
//:****************************************************************************/

//:****************************************************************************/
//: PHB RESURRECTION(THROUGH LOOTABLE CORPSES)

    case SPELL_RESURRECTION:
    {
      //Get the spell target
      object oTarget = GetSpellTargetObject();
      //Check to make sure the target is dead first
      if (GetIsDead(oTarget))
      {
        //Fire cast spell at event for the specified target
        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_RESURRECTION, FALSE));
        //Declare major variables
        int nHealed = GetMaxHitPoints(oTarget);
        effect eRaise = EffectResurrection();
        effect eHeal = EffectHeal(nHealed + 10);
        effect eVis = EffectVisualEffect(VFX_IMP_RAISE_DEAD);
        //Apply the heal, raise dead and VFX impact effect
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eRaise, oTarget);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
        ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(oTarget));
        //SetLocalInt(oTarget, "JUST_RESED", 1);
        //DelayCommand(60.0, DeleteLocalInt(oTarget, "JUST_RESED"));
        /*
        if (GetLocalInt(oTarget, "I_AM_HENCH") == 1)
            {
            object oMaster = GetLastMaster(oTarget);
            HireHenchman69(oMaster, oTarget);
            }
        */
      }

      // The following lines have been added to support Scrotok's Lootable Corpses script
      // Fire SpellCastAt event for lootable corpse placeables or bones
      if ((GetTag(oTarget) == "invis_corpse_obj") || (GetTag(oTarget) == "loot_bones_obj"))
      {
        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_RESURRECTION, FALSE));
      }

      //For OUW - Underwater System
      object oUWWP = GetNearestObjectByTag("Underwater",oTarget);
      if(GetIsObjectValid(oUWWP) && GetIsPC(oTarget))
      {
        //Destroy Old Underwater Item
        object oUW = GetItemPossessedBy(oTarget,"UnderWater");
        if(GetIsObjectValid(oUW)) DestroyObject(oUW);

        //Now Make a New Underwater Item
        oUW = CreateItemOnObject("underwater",oTarget);

        //Now Figure out How Many Rounds a Player Can Breath
        int nRounds = 20;
        int nCON = GetAbilityModifier(ABILITY_CONSTITUTION, oTarget);
        if(nCON > 4) nCON = 4;//Remove supernatural abilities
        int nTotal = nRounds - nCON;

        //Set Rounds to Underwater Item
        SetLocalInt(oUW,"UNDERWATER_TOT_ROUNDS",nTotal);
        SetLocalInt(oUW,"UNDERWATER_CUR_ROUNDS",nTotal/2);

        ExecuteScript("ouw_main",oTarget);
      }

      //Reset Forced Respawn
      SetLocalInt(oTarget,"OBD_FORCE_RESPAWN",0);

      //Subraces
      DelayCommand(2.0, ReapplySubraceAbilities(oTarget));

      SetModuleOverrideSpellScriptFinished();
      break;
    }

//: PHB RESURRECTION
//:****************************************************************************/

//:****************************************************************************/
//: POLYMORPH SELF FOR NPC'S ALSO

    case SPELL_POLYMORPH_SELF:
    {
      //Declare major variables
      //Special - if NPC, randomise the nSpell, so it works properly
      int nSpell;
      if(!GetIsPC(OBJECT_SELF) && !GetIsDM(OBJECT_SELF) && !GetIsDMPossessed(OBJECT_SELF))
      {
        nSpell = (Random(5) + 387);
      }
      else
      {
        nSpell = GetSpellId();
      }
      object oTarget = GetSpellTargetObject();
      effect eVis = EffectVisualEffect(VFX_IMP_POLYMORPH);
      effect ePoly;
      int nPoly;
      int nMetaMagic = GetMetaMagicFeat();
      int nDuration = GetCasterLevel(OBJECT_SELF);

      //Enter Metamagic conditions
      if (nMetaMagic == METAMAGIC_EXTEND)
      {
        nDuration = nDuration *2; //Duration is +100%
      }

      //Determine Polymorph subradial type
      if(nSpell == 387)
      {
        nPoly = POLYMORPH_TYPE_GIANT_SPIDER;
      }
      else if (nSpell == 388)
      {
        nPoly = POLYMORPH_TYPE_TROLL;
      }
      else if (nSpell == 389)
      {
        nPoly = POLYMORPH_TYPE_UMBER_HULK;
      }
      else if (nSpell == 390)
      {
        nPoly = POLYMORPH_TYPE_PIXIE;
      }
      else if (nSpell == 391)
      {
        nPoly = POLYMORPH_TYPE_ZOMBIE;
      }
      ePoly = EffectPolymorph(nPoly);
      //Fire cast spell at event for the specified target
      SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_POLYMORPH_SELF, FALSE));

      //Apply the VFX impact and effects
      ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
      ApplyEffectToObject(DURATION_TYPE_TEMPORARY, ePoly, oTarget, TurnsToSeconds(nDuration));

      SetModuleOverrideSpellScriptFinished();
      break;
    }

//: POLYMORPH SELF FOR NPC'S ALSO
//:****************************************************************************/

//:****************************************************************************/
//: SHAPECHANGE FOR NPC'S ALSO

    case SPELL_SHAPECHANGE:
    {
      //Declare major variables
      //Special - if NPC, randomise the nSpell, so it works properly
      int nSpell;
      if(!GetIsPC(OBJECT_SELF) && !GetIsDM(OBJECT_SELF) && !GetIsDMPossessed(OBJECT_SELF))
      {
        nSpell = (Random(5) + 392);
      }
      else
      {
        nSpell = GetSpellId();
      }
      object oTarget = GetSpellTargetObject();
      effect eVis = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3);
      effect ePoly;
      int nPoly;
      int nMetaMagic = GetMetaMagicFeat();
      int nDuration = GetCasterLevel(OBJECT_SELF);

      //Enter Metamagic conditions
      if (nMetaMagic == METAMAGIC_EXTEND)
      {
        nDuration = nDuration *2; //Duration is +100%
      }

      //Determine Polymorph subradial type
      if(nSpell == 392)
      {
        nPoly = POLYMORPH_TYPE_RED_DRAGON;
      }
      else if (nSpell == 393)
      {
        nPoly = POLYMORPH_TYPE_FIRE_GIANT;
      }
      else if (nSpell == 394)
      {
        nPoly = POLYMORPH_TYPE_BALOR;
      }
      else if (nSpell == 395)
      {
        nPoly = POLYMORPH_TYPE_DEATH_SLAAD;
      }
      else if (nSpell == 396)
      {
        nPoly = POLYMORPH_TYPE_IRON_GOLEM;
      }
      ePoly = EffectPolymorph(nPoly);
      //Fire cast spell at event for the specified target
      SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_SHAPECHANGE, FALSE));

      //Apply the VFX impact and effects
      ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(oTarget));
      DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, ePoly, oTarget, TurnsToSeconds(nDuration)));
      SetModuleOverrideSpellScriptFinished();
      break;
    }

//: POLYMORPH SELF FOR NPC'S ALSO
//:****************************************************************************/

//:****************************************************************************/
//: PHB LESSER RESTORATION
// (WILL NOT REMOVE EXTRAORDINARY EFFECTS)

    case SPELL_LESSER_RESTORATION:
    {
      //Declare major variables
      object oTarget = GetSpellTargetObject();
      effect eVisual = EffectVisualEffect(VFX_IMP_RESTORATION_LESSER);
      effect eBad = GetFirstEffect(oTarget);
      //Search for negative effects
      while(GetIsEffectValid(eBad))
      {
        if(GetEffectSubType(eBad) != SUBTYPE_EXTRAORDINARY)
        {
          if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE ||
              GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE ||
              GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE ||
              GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE ||
              GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE ||
              GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE ||
              GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE ||
              GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE)
          {
              //Remove effect if it is not subracial effect
              if(GetEffectSubType(eBad) == SUBTYPE_SUPERNATURAL)
              {
                if(GetEffectCreator(eBad) != oTarget)
                {
                  RemoveEffect(oTarget, eBad);
                }
              }
              //else
              if(GetEffectSubType(eBad) != SUBTYPE_SUPERNATURAL)
              {
                RemoveEffect(oTarget, eBad);
              }
          }
        }
        eBad = GetNextEffect(oTarget);
      }
      //Fire cast spell at event for the specified target
      SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_LESSER_RESTORATION, FALSE));
      ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oTarget);

        object oItem = GetItemInSlot(INVENTORY_SLOT_CARMOUR, oTarget);

        object oTieflingSkin    = GetObjectByTag("TSM_PC_TIEFLING");
        object oAirGenSkin      = GetObjectByTag("SHA_PC_AIR_GENASI");
        object oAvarielSkin     = GetObjectByTag("SHA_PC_ELF_AVARIEL");
        object oSvirfSkin       = GetObjectByTag("SHA_PC_SVIRFNEBLIN");
        object oArcDwfSkin      = GetObjectByTag("SHA_PC_DWARF_ARTIC");
        object oIlliSkin        = GetObjectByTag("SHA_PC_ILLITHID");
        object oPixieSkin       = GetObjectByTag("SHA_PC_PIXIE");
        object oOgreSkin        = GetObjectByTag("SHA_PC_OGRE");
        object oGoblinSkin      = GetObjectByTag("SHA_PC_GOBLIN");
        object oImaskarSkin     = GetObjectByTag("SHA_PC_IMASKAR");

        if (!GetIsPC(oTarget)) return;
        if ((oItem == oTieflingSkin) || (oItem == oAirGenSkin) || (oItem == oAvarielSkin) || (oItem == oSvirfSkin))
            {
            effect eEffect;
            eEffect = EffectAbilityIncrease(ABILITY_DEXTERITY, 2);
            eEffect = SupernaturalEffect(eEffect);
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);
            return;
            }

        if (oItem == oIlliSkin || oItem == oGoblinSkin)
            {
            effect eEffect;
            eEffect = EffectAbilityIncrease(ABILITY_DEXTERITY, 4);
            eEffect = SupernaturalEffect(eEffect);
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);
            return;
            }

        if (oItem == oPixieSkin)
            {
            effect eEffect;
            eEffect = EffectAbilityIncrease(ABILITY_DEXTERITY, 8);
            eEffect = SupernaturalEffect(eEffect);
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);
            return;
            }

        if (oItem == oArcDwfSkin || oItem == oOgreSkin || oItem == oImaskarSkin)
            {
            effect eEffect;
            eEffect = EffectAbilityDecrease(ABILITY_DEXTERITY, 2);
            eEffect = SupernaturalEffect(eEffect);
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);
            return;
            }
      SetModuleOverrideSpellScriptFinished();
      break;
    }

//: PHB LESSER RESTORATION
//:****************************************************************************/

//:****************************************************************************/
//: PHB RESTORATION
// (WILL NOT REMOVE EXTRAORDINARY EFFECTS)

    case SPELL_RESTORATION:
    {
      //Declare major variables
      object oTarget = GetSpellTargetObject();
      effect eVisual = EffectVisualEffect(VFX_IMP_RESTORATION);
      int bValid;

      effect eBad = GetFirstEffect(oTarget);
      //Search for negative effects
      while(GetIsEffectValid(eBad))
      {
        if(GetEffectSubType(eBad) != SUBTYPE_EXTRAORDINARY)
        {
            if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_BLINDNESS ||
                GetEffectType(eBad) == EFFECT_TYPE_DEAF ||
                GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
                GetEffectType(eBad) == EFFECT_TYPE_NEGATIVELEVEL)
            {
                //Remove effect if it is not subracial effect
                if(GetEffectSubType(eBad) == SUBTYPE_SUPERNATURAL)
                {
                  if(GetEffectCreator(eBad) != oTarget)
                  {
                    RemoveEffect(oTarget, eBad);
                  }
                }
                //else
                if(GetEffectSubType(eBad) != SUBTYPE_SUPERNATURAL)
                {
                  RemoveEffect(oTarget, eBad);
                }
            }
        }
        eBad = GetNextEffect(oTarget);
      }
      //Fire cast spell at event for the specified target
      SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_RESTORATION, FALSE));
      ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oTarget);

        object oItem = GetItemInSlot(INVENTORY_SLOT_CARMOUR, oTarget);

        object oTieflingSkin    = GetObjectByTag("TSM_PC_TIEFLING");
        object oAirGenSkin      = GetObjectByTag("SHA_PC_AIR_GENASI");
        object oAvarielSkin     = GetObjectByTag("SHA_PC_ELF_AVARIEL");
        object oSvirfSkin       = GetObjectByTag("SHA_PC_SVIRFNEBLIN");
        object oArcDwfSkin      = GetObjectByTag("SHA_PC_DWARF_ARTIC");
        object oIlliSkin        = GetObjectByTag("SHA_PC_ILLITHID");
        object oPixieSkin       = GetObjectByTag("SHA_PC_PIXIE");
        object oOgreSkin        = GetObjectByTag("SHA_PC_OGRE");
        object oGoblinSkin      = GetObjectByTag("SHA_PC_GOBLIN");
        object oImaskarSkin     = GetObjectByTag("SHA_PC_IMASKAR");

        if (!GetIsPC(oTarget)) return;
        if ((oItem == oTieflingSkin) || (oItem == oAirGenSkin) || (oItem == oAvarielSkin) || (oItem == oSvirfSkin))
            {
            //object oTarget = oPC;
            effect eEffect;

            eEffect = EffectAbilityIncrease(ABILITY_DEXTERITY, 2);
            eEffect = SupernaturalEffect(eEffect);
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);
            return;
            }

        if (oItem == oIlliSkin || oItem == oGoblinSkin)
            {
            effect eEffect;
            eEffect = EffectAbilityIncrease(ABILITY_DEXTERITY, 4);
            eEffect = SupernaturalEffect(eEffect);
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);
            return;
            }


        if (oItem == oPixieSkin)
            {
            effect eEffect;
            eEffect = EffectAbilityIncrease(ABILITY_DEXTERITY, 8);
            eEffect = SupernaturalEffect(eEffect);
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);
            return;
            }

        if (oItem == oArcDwfSkin || oItem == oOgreSkin || oItem == oImaskarSkin)
            {
            effect eEffect;
            eEffect = EffectAbilityDecrease(ABILITY_DEXTERITY, 2);
            eEffect = SupernaturalEffect(eEffect);
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);
            return;
            }
      SetModuleOverrideSpellScriptFinished();
      break;
    }

//: PHB RESTORATION
//:****************************************************************************/

//:****************************************************************************/
//: PHB GREATER RESTORATION
// (WILL NOT REMOVE EXTRAORDINARY EFFECTS)
// (WILL NOT HEAL CONSTRUCTS)

    case SPELL_GREATER_RESTORATION:
    {
      //Declare major variables
      object oTarget = GetSpellTargetObject();
      effect eVisual = EffectVisualEffect(VFX_IMP_RESTORATION_GREATER);

      effect eBad = GetFirstEffect(oTarget);
      //Search for negative effects
      while(GetIsEffectValid(eBad))
      {
        if(GetEffectSubType(eBad) != SUBTYPE_EXTRAORDINARY)
        {
            if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_BLINDNESS ||
                GetEffectType(eBad) == EFFECT_TYPE_DEAF ||
                GetEffectType(eBad) == EFFECT_TYPE_CURSE ||
                GetEffectType(eBad) == EFFECT_TYPE_DISEASE ||
                GetEffectType(eBad) == EFFECT_TYPE_POISON ||
                GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
                GetEffectType(eBad) == EFFECT_TYPE_CHARMED ||
                GetEffectType(eBad) == EFFECT_TYPE_DOMINATED ||
                GetEffectType(eBad) == EFFECT_TYPE_DAZED ||
                GetEffectType(eBad) == EFFECT_TYPE_CONFUSED ||
                GetEffectType(eBad) == EFFECT_TYPE_FRIGHTENED ||
                GetEffectType(eBad) == EFFECT_TYPE_NEGATIVELEVEL ||
                GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
                GetEffectType(eBad) == EFFECT_TYPE_SLOW ||
                GetEffectType(eBad) == EFFECT_TYPE_STUNNED)
            {
                //Remove effect if it is not subracial effect
                if(GetEffectSubType(eBad) == SUBTYPE_SUPERNATURAL)
                {
                  if(GetEffectCreator(eBad) != oTarget)
                  {
                    RemoveEffect(oTarget, eBad);
                  }
                }
                //else
                if(GetEffectSubType(eBad) != SUBTYPE_SUPERNATURAL)
                {
                  RemoveEffect(oTarget, eBad);
                }
            }
        }
        eBad = GetNextEffect(oTarget);
      }

      //Fire cast spell at event for the specified target
      SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_GREATER_RESTORATION, FALSE));
      ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oTarget);

        object oItem = GetItemInSlot(INVENTORY_SLOT_CARMOUR, oTarget);

        object oTieflingSkin    = GetObjectByTag("TSM_PC_TIEFLING");
        object oAirGenSkin      = GetObjectByTag("SHA_PC_AIR_GENASI");
        object oAvarielSkin     = GetObjectByTag("SHA_PC_ELF_AVARIEL");
        object oSvirfSkin       = GetObjectByTag("SHA_PC_SVIRFNEBLIN");
        object oArcDwfSkin      = GetObjectByTag("SHA_PC_DWARF_ARTIC");
        object oIlliSkin        = GetObjectByTag("SHA_PC_ILLITHID");
        object oPixieSkin       = GetObjectByTag("SHA_PC_PIXIE");
        object oOgreSkin        = GetObjectByTag("SHA_PC_OGRE");
        object oGoblinSkin      = GetObjectByTag("SHA_PC_GOBLIN");
        object oImaskarSkin     = GetObjectByTag("SHA_PC_IMASKAR");

        if (!GetIsPC(oTarget)) return;
        if ((oItem == oTieflingSkin) || (oItem == oAirGenSkin) || (oItem == oAvarielSkin) || (oItem == oSvirfSkin))
            {
            effect eEffect;
            eEffect = EffectAbilityIncrease(ABILITY_DEXTERITY, 2);
            eEffect = SupernaturalEffect(eEffect);
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);
            return;
            }

        if (oItem == oIlliSkin || oItem == oGoblinSkin)
            {
            effect eEffect;
            eEffect = EffectAbilityIncrease(ABILITY_DEXTERITY, 4);
            eEffect = SupernaturalEffect(eEffect);
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);
            return;
            }


        if (oItem == oPixieSkin)
            {
            effect eEffect;
            eEffect = EffectAbilityIncrease(ABILITY_DEXTERITY, 8);
            eEffect = SupernaturalEffect(eEffect);
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);
            return;
            }

        if (oItem == oArcDwfSkin || oItem == oOgreSkin || oItem == oImaskarSkin)
            {
            effect eEffect;
            eEffect = EffectAbilityDecrease(ABILITY_DEXTERITY, 2);
            eEffect = SupernaturalEffect(eEffect);
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);
            return;
            }
      SetModuleOverrideSpellScriptFinished();
      break;
    }

//: PHB GREATER RESTORATION
//:****************************************************************************/

//:****************************************************************************/
//: KNOCK (EP Olson Fixes)

    case SPELL_KNOCK:
    {
      object oTarget;
      effect eVis = EffectVisualEffect(VFX_IMP_KNOCK);
      oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 50.0, GetLocation(OBJECT_SELF), FALSE, OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);
      float fDelay;
      int nResist;

      while(GetIsObjectValid(oTarget))
      {
        SignalEvent(oTarget,EventSpellCastAt(OBJECT_SELF,GetSpellId()));
        fDelay = GetRandomDelay(0.5, 2.5);
        //if(!GetPlotFlag(oTarget) && GetLocked(oTarget))  // EPOlson - plot doors are knockable

        if(GetLocked(oTarget))
        {
          // EPOlson: set local int "X2_FLAG_DOOR_RESIST_KNOCK" for DoorFlag
          nResist =  GetDoorFlag(oTarget,DOOR_FLAG_RESIST_KNOCK);

          // plot is OK, but "requires key" will stop knock (unless key end in = knock)
          if(GetLockKeyRequired(oTarget))
          {
            if(!FindSubString(GetLockKeyTag(oTarget),"knock")) nResist = 1;
          }
          if (nResist == 0)
          {
            DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
            AssignCommand(oTarget, ActionUnlockObject(oTarget));
          }
          else if  (nResist == 1)
          {
            FloatingTextStrRefOnCreature(83887,OBJECT_SELF);
          }
        }
        oTarget = GetNextObjectInShape(SHAPE_SPHERE, 50.0, GetLocation(OBJECT_SELF), FALSE, OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);
      }
      SetModuleOverrideSpellScriptFinished();
      break;
    }

//: KNOCK
//:****************************************************************************/

//:****************************************************************************/
//: FIND TRAP - Only FINDS the Traps now and Not DESTROY them too (EP Olson Fix)

    case SPELL_FIND_TRAPS:
    {
      effect eVis = EffectVisualEffect(VFX_IMP_KNOCK);
      int nCnt = 1;
      object oTrap = GetNearestObject(OBJECT_TYPE_TRIGGER |
             OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE, OBJECT_SELF, nCnt);
      while(GetIsObjectValid(oTrap) && GetDistanceToObject(oTrap) <= 30.0)
      {
        if(GetIsTrapped(oTrap))
        {
          SetTrapDetectedBy(oTrap, OBJECT_SELF);
          ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(oTrap));
          //DelayCommand(2.0, SetTrapDisabled(oTrap));  // EPOlson: NOT disabled/destroyed
        }
        nCnt++;
        oTrap = GetNearestObject(OBJECT_TYPE_TRIGGER | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE, OBJECT_SELF, nCnt);
      }

      SetModuleOverrideSpellScriptFinished();
      break;
    }

//: FIND TRAP
//:****************************************************************************/

//:****************************************************************************/
//: SSE - Shayan's Subrace Engine (Updated by Olander)

    case SPELL_CURE_CRITICAL_WOUNDS:
    {
      object oTarget = GetSpellTargetObject();
      object oArea = GetArea(oTarget);
      string sTag = GetTag(oTarget);
      //int nHealing = GetLocalInt(oTarget, "IS_HEALING");
      int nCHP = GetLocalInt(oArea, "nCHP" +sTag);
      int nCure = d8(4);
      spellsCure(nCure, 20, 32, VFX_IMP_SUNSTRIKE, VFX_IMP_HEALING_G, GetSpellId());

      if(GetIsHenchmanDying(oTarget) || GetLocalInt(oTarget, "IS_HEALING") == 1)
      {
        SetLocalInt(oArea, "nCHP" +sTag, nCHP + nCure);
      }
      if(IsUndead)
      {
        ORS_SpellsCure(d8(4), 20, 32, VFX_IMP_SUNSTRIKE, VFX_IMP_HEALING_G, GetSpellId());

        SetModuleOverrideSpellScriptFinished();
        break;
      }
    }

    case SPELL_CURE_LIGHT_WOUNDS:
    {
      object oTarget = GetSpellTargetObject();
      object oArea = GetArea(oTarget);
      string sTag = GetTag(oTarget);
      //int nHealing = GetLocalInt(oTarget, "IS_HEALING");
      int nCHP = GetLocalInt(oArea, "nCHP" +sTag);
      int nCure = d8(1);
      spellsCure(nCure, 5, 8, VFX_IMP_SUNSTRIKE, VFX_IMP_HEALING_S, GetSpellId());

      if(GetIsHenchmanDying(oTarget) || GetLocalInt(oTarget, "IS_HEALING") == 1)
      {
        SetLocalInt(oArea, "nCHP" +sTag, nCHP + nCure);
      }
      if(IsUndead)
      {
        ORS_SpellsCure(d8(), 5, 8, VFX_IMP_SUNSTRIKE, VFX_IMP_HEALING_S, GetSpellId());

        SetModuleOverrideSpellScriptFinished();
        break;
      }
    }

    case SPELL_CURE_MINOR_WOUNDS:
    {
      object oTarget = GetSpellTargetObject();
      object oArea = GetArea(oTarget);
      string sTag = GetTag(oTarget);
      //int nHealing = GetLocalInt(oTarget, "IS_HEALING");
      int nCHP = GetLocalInt(oArea, "nCHP" +sTag);
      int nCure = 1;
      spellsCure(4, 0, 4, VFX_IMP_SUNSTRIKE, VFX_IMP_HEAD_HEAL, GetSpellId());

      if(GetIsHenchmanDying(oTarget) || GetLocalInt(oTarget, "IS_HEALING") == 1)
      {
        SetLocalInt(oArea, "nCHP" +sTag, nCHP + nCure);
      }
      if(IsUndead)
      {
        ORS_SpellsCure(4, 0, 4, VFX_IMP_SUNSTRIKE, VFX_IMP_HEAD_HEAL, GetSpellId());

        SetModuleOverrideSpellScriptFinished();
        break;
      }
    }

    case SPELL_CURE_MODERATE_WOUNDS:
    {
      object oTarget = GetSpellTargetObject();
      object oArea = GetArea(oTarget);
      string sTag = GetTag(oTarget);
      //int nHealing = GetLocalInt(oTarget, "IS_HEALING");
      int nCHP = GetLocalInt(oArea, "nCHP" +sTag);
      int nCure = d8(2);
      spellsCure(nCure, 10, 16, VFX_IMP_SUNSTRIKE, VFX_IMP_HEALING_M, GetSpellId());

      if(GetIsHenchmanDying(oTarget) || GetLocalInt(oTarget, "IS_HEALING") == 1)
      {
        SetLocalInt(oArea, "nCHP" +sTag, nCHP + nCure);
      }
      if(IsUndead)
      {
        ORS_SpellsCure(d8(2), 10, 16, VFX_IMP_SUNSTRIKE, VFX_IMP_HEALING_M, GetSpellId());

        SetModuleOverrideSpellScriptFinished();
        break;
      }
    }

    case SPELL_CURE_SERIOUS_WOUNDS:
    {
      object oTarget = GetSpellTargetObject();
      object oArea = GetArea(oTarget);
      string sTag = GetTag(oTarget);
      //int nHealing = GetLocalInt(oTarget, "IS_HEALING");
      int nCHP = GetLocalInt(oArea, "nCHP" +sTag);
      int nCure = d8(3);
      spellsCure(nCure, 15, 24, VFX_IMP_SUNSTRIKE, VFX_IMP_HEALING_S, GetSpellId());

      if(GetIsHenchmanDying(oTarget) || GetLocalInt(oTarget, "IS_HEALING") == 1)
      {
        SetLocalInt(oArea, "nCHP" +sTag, nCHP + nCure);
      }
      if(IsUndead)
      {
        ORS_SpellsCure(d8(3), 15, 24, VFX_IMP_SUNSTRIKE, VFX_IMP_HEALING_L, GetSpellId());

        SetModuleOverrideSpellScriptFinished();
        break;
      }
    }

    case SPELL_NEGATIVE_ENERGY_RAY:
    {
      if(IsUndead)
      {
        int nMetaMagic = GetMetaMagicFeat();
        if(nCasterLevel > 9)
        {
          nCasterLevel = 9;
        }

        nCasterLevel = (nCasterLevel + 1) / 2;
        int nDamage = d6(nCasterLevel);

        //Enter Metamagic conditions
        if (nMetaMagic == METAMAGIC_MAXIMIZE)
        {
          nDamage = 6 * 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);

        //Fire cast spell at event for the specified target
        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_NEGATIVE_ENERGY_RAY, FALSE));

        effect 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);

        SetModuleOverrideSpellScriptFinished();
        break;
      }
    }

    case SPELLABILITY_BG_INFLICT_SERIOUS_WOUNDS:
    {
      if(IsUndead)
      {
        ORS_SpellsInflictTouchAttack(d8(3), 15, 24, 246, VFX_IMP_HEALING_G, nSpell);

        SetModuleOverrideSpellScriptFinished();
        break;
      }
    }

    case SPELLABILITY_BG_INFLICT_CRITICAL_WOUNDS:
    {
      if(IsUndead)
      {
        ORS_SpellsInflictTouchAttack(d8(4), 20, 32, 246, VFX_IMP_HEALING_G, nSpell);

        SetModuleOverrideSpellScriptFinished();
        break;
      }
    }

//: SSE - Shayan's Subrace Engine (Updated by Olander)
//:****************************************************************************/

//:****************************************************************************/
//: TEMPPLATE
    /*
    case SPELL_*****:
    {

      SetModuleOverrideSpellScriptFinished();
      break;
    }
    */
//: TEMPPLATE
//:****************************************************************************/

  }
}

Can someone put me on the scent here? Thanks!



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Wand, Potion, Scroll Crafting Feats Broken
« Reply #1 on: July 30, 2016, 09:23:52 am »


               

I guess the problem is here:


 


int nType = GetObjectType(oTarget);
  if(nType == OBJECT_TYPE_ITEM)
  {
    if(CIGetIsCraftFeatBaseItem(oTarget))
    {
      if(GetLocalInt(oMod,"BIOCRAFT") <= 0)
      {
        SetModuleOverrideSpellScriptFinished();
        return;
      }
      else nCLEAR = TRUE;
    }
  }

 


Have you set the local integer BIOCRAFT on your module? If not, I imagine crafting will fail.


 


I'm no expert, but the standard way of disabling crafting in the module load script is


 


   SetLocalInt(GetModule(), "X2_L_DO_NOT_ALLOW_CRAFTSKILLS", TRUE);

 


so I wonder whether BIOCRAFT is a variable set in some private system of your own?


               
               

               
            

Legacy_TripleXM

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Wand, Potion, Scroll Crafting Feats Broken
« Reply #2 on: July 30, 2016, 04:30:59 pm »


               

Thank you! The problem was, indeed, in that bit of code. Fixed!