Make NPC cast one spell instead of another

Post » Tue Aug 06, 2013 2:06 am

I wonder is there a less sloppy way to do this? I was going to add a unique NPC class to my mod, a type of archer mage hybrid. This NPC opens up with a spell that causes vulnerability to fire damage that lasts for about a minute, then the NPC switches to a fire enchanted bow, and then this is where said NPC starts doing serious damage with the bow followed by the debuffing spell. Only problem is this: The NPC has another spell, it's an enhanced health drain spell. I only want the enhanced health drain spell to be casted when the NPC is already wounded, or at least to be casted less often. Unfortunately the NPC just appears to cast the health drain until out of magicka. I could as a last resort delete the absorb health spell, and give the NPC a lower magicka pool, so this spell is only casted once, and at least the NPC fights as the type of archer/mage hybrid I wanted. The NPC is not a main character of my mod anyways, just an additional feature intended to making the mod a more diverse experience.

So... What do you recommend I do? Should I go the slightly sloppy route and just take absorb health from this specific NPC? Or is there a relatively easy way to resolve this?

User avatar
Dominic Vaughan
 
Posts: 3531
Joined: Mon May 14, 2007 1:47 pm

Post » Mon Aug 05, 2013 7:19 pm

I use something like this. The spell must be added to the actor via SCRIPT. Giving him the life drain spell via the CK will make this not work.

SPELL Property LifeDrain AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)    Utility.Wait(1.0) ;give time for sfx to finish    akCaster.UnequipSpell(LifeDrain, 0)    akCaster.RemoveSpell(LifeDrain)    Utility.Wait(10.0) ;cool down time    akCaster.AddSpell(LifeDrain)endEvent
User avatar
Amie Mccubbing
 
Posts: 3497
Joined: Thu Aug 31, 2006 11:33 pm


Return to V - Skyrim