What's wrong with this line of script? (For area-effect spells)

Hi, everyone. Been trying to get this to work (it’s part of a script meant to be called by an item I created when the player uses the item’s special power):

location lTarget = GetLocation(oPC); //Yes, I remembered to specify what oPC is. :wink:
ActionCastSpellAtLocation(SPELL_STORM_OF_VENGEANCE, lTarget, METAMAGIC_ANY, 1, 1);

Now Storm of Vengeance is a spell that works over an area rather than a targeted spell, so I left out the bit in the ActionCastSpellAtLocation where I had to specify the Projectile Path Type. It compiled nicely – but didn’t work.

I tried substituting other spells like SPELL_ENTANGLE and SPELL_GREASE (which as we know are also spells that work over an area rather than targeted spells). Still didn’t work. To find out if the problem might lie elsewhere in the script, I placed another line of script just before the ActionCastSpellAtLocation line of script above, which went:

AssignCommand(oPC, SpeakString(“Abracadabra!”));

This line worked, so the entire script had no problem – only the ActionCastSpellAtLocation line of script.

Tried changing the bInstantSpell specification right at the end of the line from 1 to 0. Still no good.

What gives here? How do I make the thing work? Is it that there’s something about the nature of the spells I listed above that makes ActionCastSpellAtLocation unsuitable for them? I thought of switching to ActionCastSpellAtObject, except I don’t want the player to be the target object for the spells! So what can I do? Any help will be appreciated, thanks!

The problem is likely being caused by who is casting the spell. I.e. it’s probably being cast by the owner of script, who is probably the item instead of the PC. Try:
AssignCommand(oPC, ClearAllActions());
AssignCommand(oPC, ActionCastSpellAtLocation(SPELL_STORM_OF_VENGEANCE, lTarget, METAMAGIC_NONE, 1));
That might get the script working correctly. Another possibility is that the error is being caused by the cheat flag being used to cast the spell. That means, the spell script might have 0 as the caster level of the spell, which could also cause the spell to malfunction.

2 Likes

Tried your suggestion, in addition to which I now decided to be very precise in specifying everything – the bCheat (set to 1), nProjectilePathType (set to 0) and bInstantSpell (set to 1) specifications.

AssignCommand(oPC, ClearAllActions());
AssignCommand(oPC, ActionCastSpellAtLocation(SPELL_STORM_OF_VENGEANCE, lTarget, METAMAGIC_NONE, 1, 0, 1));

This time it worked beautifully. Thanks, pal! :smiley:

1 Like

Glad to hear it worked. You might not need the ClearAllActions call, but I find that spell casting in particular does not play well with other actions.

1 Like