New Spell creation - Reduce Magic Resistance

Hi everyone,

I’m back trying to create a new spell. I am using “Natures Balance” (Druid lv 9 spell) as my base.

I want to make the spell do the following and I almost have it stripping out some stuff from this druid spell:

Reduce Spell Resistance of ONE target.
Reduce it 50% of its resistance (so if someone has spell resistance of 70% it reduces it to 35%)
No saving throw (because the enemy already has spell resistance - why this spell is to affect that).
Duration: 1 round per 3 caster levels.

Any further suggestions?

I used Nature’s Balance as my base because it sort of does that.

Here is what I have so far (I took out the Metamagic stuff because it was too difficult for me to do)

This does not compile but it is getting closer to what I want.

//:: Hagger's Magic Quencher
//::Lv 6 Wiz/Sor, Cleric
//::
//:: Hagger the mage created this spell to quench 
//:: enemy mage spell resistance. 
//::
//::
//:://////////////////////////////////////////////
/* 
    Reduces the SR of all enemies by 1d4 per 5 caster 
     levels for 1 round per 3 caster levels 
     (BUT I want to change this to just a 50% not 1d4).
*/
//:://////////////////////////////////////////////


#include "prc_alterations"

#include "X0_I0_SPELLS"
#include "x2_inc_spellhook"

void main()
{
DeleteLocalInt(OBJECT_SELF, "X2_L_LAST_SPELLSCHOOL_VAR");
SetLocalInt(OBJECT_SELF, "X2_L_LAST_SPELLSCHOOL_VAR", SPELL_SCHOOL_TRANSMUTATION);

/*
  Spellcast Hook Code
  Added 2003-06-20 by Georg
  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
    effect eVis = EffectVisualEffect(VFX_IMP_HEALING_L);
    effect eSR;
    effect eVis2 = EffectVisualEffect(VFX_IMP_BREACH);
    effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_NEGATIVE);

    int nRand;
    int nCasterLevel = (GetCasterLevel(OBJECT_SELF) + GetChangesToCasterLevel(OBJECT_SELF));
    //Determine spell duration as an integer for later conversion to Rounds, Turns or Hours.
    int nDuration = nCasterLevel/3;
    float fDelay;
    //Set off fire and forget visual
    ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eNature, GetLocation(OBJECT_SELF));
    //Declare the spell shape, size and the location.  Capture the first target object in the shape.

    object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_LARGE, GetLocation(OBJECT_SELF), FALSE);
    //Cycle through the targets within the spell shape until an invalid object is captured.
    while(GetIsObjectValid(oTarget))
    {

        }

        if (spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, OBJECT_SELF))
        {
             }              //Check for saving throw
                if (!MySavingThrow(SAVING_THROW_WILL, oTarget, (GetSpellSaveDC()+ GetChangesToSaveDC(OBJECT_SELF))))
                {
                    }
                      nCasterLevel /= 5;
                      if(nCasterLevel == 0)
                      {
                        nCasterLevel = 1;
                      }
                      nRand = d4(nCasterLevel);
                      eSR = EffectSpellResistanceDecrease(nRand);
                      effect eLink = EffectLinkEffects(eSR, eDur);
                      //Apply reduce SR effects
                      DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, RoundsToSeconds(nDuration)));
                      DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget));
                }

        //Select the next target within the spell shape.
        oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_LARGE, GetLocation(OBJECT_SELF), FALSE);
    }

DeleteLocalInt(OBJECT_SELF, "X2_L_LAST_SPELLSCHOOL_VAR");
// Getting rid of the integer used to hold the spells spell school
}

I will use different visual effects too and then release this and three other spells I’m working on to the vault. Just need some help.

In this function you are using “eNature”. However, as far as I can see you have not defined before in the script what “eNature” is. So my guess is that’s why it doesn’t compile.

EDIT: Oh, and then your curly brackets in the while statement is all over the place.

1 Like

If you write like this, you need some code between the two curly brackets, otherwise they are totally redundant.

1 Like

You probably want something like this:

 	while(GetIsObjectValid(oTarget))
    {

        if (spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, OBJECT_SELF))
        {
                  //Check for saving throw
                if (!MySavingThrow(SAVING_THROW_WILL, oTarget, (GetSpellSaveDC()+ GetChangesToSaveDC(OBJECT_SELF))))
                {
                    
                      nCasterLevel /= 5;
                      if(nCasterLevel == 0)
                      {
                        nCasterLevel = 1;
                      }
                      nRand = d4(nCasterLevel);
                      eSR = EffectSpellResistanceDecrease(nRand);
                      effect eLink = EffectLinkEffects(eSR, eDur);
                      //Apply reduce SR effects
                      DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, RoundsToSeconds(nDuration)));
                      DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget));
      


				}
		}

	}
1 Like

Worse, it’s an infinite loop (rather TMI because the engine will stop it).

You’ve got 3 places where you just close your opening brackets. And then 3 extra closing brackets because of it.

Randomly (or semi-randomly) changing lines and chars in a script is unlikely to make one that works.

Plus you said you wanted to not have a saving throw but you left the saving throw in.

2 Likes

hi guys,

Thanks for the replies and help. Yeah those brackets are there probably because I pulled out stuff between them from the original script. And andgalf that eNature is from the original spell…I see I forgot to pull that out.

I will try this again…with some more changes and repost.

Not really sure how to do that reduce the opponents spell resistance by half (50%) in there.

No saving throw (because the enemy already has spell resistance - why this spell is to affect that).

A saving throw and spell resistance is something quite different.

Any further suggestions?
I used Nature’s Balance as my base because it sort of does that.

A much easier appoach would be using the spell breach family, which has no saving thow.

1 Like

How do you do the spell breach Mmat?

Try this one. I guess it’s somewhat near the desired result.

#include "NW_I0_SPELLS"
#include "x2_inc_spellhook"

void main()
{
  if (!X2PreSpellCastCode()) return;

  object oTarget = GetSpellTargetObject();
  if(GetIsReactionTypeFriendly(oTarget)) return;

  int nSR = GetSpellResistance (oTarget)/2;
  effect eSR = EffectSpellResistanceDecrease(nSR);
  effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_NEGATIVE);
  effect eVis = EffectVisualEffect(VFX_IMP_BREACH);
  int dur = GetCasterLevel(OBJECT_SELF)/3;

  SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_GREATER_SPELL_BREACH));
  effect eLink = EffectLinkEffects(eDur, eSR);
  eLink = ExtraordinaryEffect(eLink);
  ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, RoundsToSeconds(dur));
  ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
}
1 Like

Is this the whole spell then…or part of it?

Your bit there compiled :slight_smile:

Going to try and figure out what it is doing line by line so I understand.

that’s the whole spell

edit: the impact script only of course.

1 Like

Wow…lol…short…was expecting it to be long…lol

Cool thanks…will test it out. Still trying to go line by line to understand what it is doing :slight_smile:

Not sure what you mean? Is there more that should be added?

No

1 Like

Ok…thanks :slight_smile:

Hi Mmat

The spell doesn’t target the creature. Caster just goes through the casting motions. :frowning:

Also, I think I would like the caster to point at the target and cast the spell animation. I have everything made…just need the spell to work now. Don’t understand why I can’t target the creature. Is it because f the new 2da for NWN that uses the area of effect (i.e. sphere)?

If someone wants me to send my test module with the spell to test to look at it let me know.

Which 2da-line do you use? Just copy the line of “Greater Spell breach”, change the impact script and you should be fine.

Thanks Mmat…I will try that. I will let you know if it works. :slight_smile:

Works!!..thanks Mmat!!

Now I have to figure out why the hades my scroll version of this spell is having the description read below the stuff that is written normally below the spell description (i.e. what classes can cast the spells…now at the top above the description)…good grief…done this so many times never had this issue in creating scrolls for the spell. Wonder what could be causing that.