NPCs and subradial spells

This will make them use a random subspell, but it also means they spend every other round casting an invisible spell with no animation.

//
void main()
{
// Determine caster & target
object oTarget = GetSpellTargetObject();
object oCaster = OBJECT_SELF;
int nSpellId = GetSpellId();
int nSubspell = nSpellId + d4(1);

// Keep track of spell/feat uses by variable
DecrementFeatUses(oCaster, FEAT_BLACK_MAGICK_I);

// Signal Spellcast event
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, nSpellId, TRUE) );

// Check for spellcasting success
if (!SpellCastSuccess(oCaster, oTarget, nSpellId))
    return;

// Cast random subspell spell
AssignCommand( oCaster, ClearAllActions() );
AssignCommand( oCaster, ActionCastSpellAtObject(nSubspell, oTarget, 0, 1, 0, 0, 0) );

}
// FIN

They also seem to get stuck occasionally with bad timing I guess where they’re interrupting their own spell-casting action so they don’t do anything.

as I said in very first post, modifying AI scripting will be the best option

still is weird that your custom feat is not used but wild shape is, but I can’t investigate right now

ROFL. NPCs do not like subspells. With this ai script they will say that theyre casting a subspell but they aren’t. They cast the master spell with no script anyway.

int nSpell;
int nSubSpell;

// Black Magick
if (GetHasFeat(FEAT_BLACK_MAGICK_I, OBJECT_SELF))
{
    SpeakString("Has black magick I");
    nSubSpell = 910 + d3(1);
    SpeakString("Casting "+IntToString(nSubSpell));
    ActionCastSpellAtObject(nSubSpell, oIntruder, 0, 1);
    return;
}

This works. :slight_smile: Now I can go ahead and have them check for weakness etc and then not use a random spell if it would be better. :slight_smile:

int nSpell;
int nSubSpell;

// Black Magick
if (GetHasFeat(FEAT_BLACK_MAGICK_I, OBJECT_SELF))
{
    SpeakString("Has black magick I");
    nSubSpell = 910 + d3(1);
    SpeakString("Casting "+IntToString(nSubSpell));
    ActionCastSpellAtObject(nSubSpell, oIntruder, 0, 1);
    DecrementRemainingFeatUses(OBJECT_SELF, FEAT_BLACK_MAGICK_I);
    SetLocalInt(OBJECT_SELF, "nShouldRest", 1);
}