Casting an epic spell properly

I'm trying to figure out how to make an AI to cast an epic spell in a way that actually burns the spell feat use and the spell is cast with proper caster level. I'm having trouble with this and here is what I tried so far:
Is there a way to make an actor use its epic spell (feat) normally?
ActionUseFeat(FEAT_EPIC_SPELL_EPIC_WARDING, OBJECT_SELF);The actor casts the spell but it ends instantly.
// 695 - epic warding spell id ActionCastSpellAtObject(695, OBJECT_SELF, METAMAGIC_NONE);The actor does nothing.
ActionCastSpellAtObject(695, OBJECT_SELF, METAMAGIC_NONE, TRUE); DecrementRemainingFeatUses(OBJECT_SELF, FEAT_EPIC_SPELL_EPIC_WARDING);The spell is cast but the caster level is wrong because it's cheat-casted.
Is there a way to make an actor use its epic spell (feat) normally?
0
Comments
ActionUseFeat should do it correctly. Maybe add a bunch of extra levels to the creature and see if that makes it last longer?
The only other thing I can think of is make sure the creature has either epic wizard feat or epic sorcerer feat. The Wiki also mentions 15 levels of Pale Master will enable Epic Warding.
Some more digging in the lexicon says that the caster has to be a creature or PC. Placeables will not do it correctly. That last option you tried should work for placeables. (Says the caster level is automatically calculated with the code though I have no idea how you define Innate Spell Level for the placeable.)
Eitherway you can just edit all epic spells scripts and do something like this
"if npc set caster level to be get hit dice of self"
Finally, I ended up modifying spell scripts with code like this and now it works fine: