Jump to content

How to: add "emergency spell" behavior to an NPC?


xkkmEl

Recommended Posts

I want to add to my custom NPCs the ability to cast emergency healing spells on the player, while in combat. I have been lugging around Cerwiden for that purpose for over a year... its time I move on to enjoy other NPCs,

 

I have found in another thread the following script, triggered by a Player.OnHit event:

float cost = HealOther.GetEffectiveMagickaCost( NPC)
NPC.EquipSpell( HealOther, 0)
NPC.DamageActorValue( "Magicka", cost)
NPC.DoCombatSpellApply( HealOther, Player)

Well... I added the DamageActorValue myself after seeing my NPC cast 5 of them in a row and realizing no magicka was being spent.

 

Still... I'm not sure this is the right approach. If the NPC is animating the spell casting, it happens so fast I can't actually see it.

 

Or perhaps it's the right approach, and I should just change the casting art to one that is more obvious/dramatic...

 

Any suggestions? pointers?

 

PS: I gave up on reverse engineering Cerwiden. I got confused and couldn't find the proper starting point. I could be coaxed into trying again with a little push in the right direction.

 

Link to comment
Share on other sites

Ok, so I tried and sort of failed.

 

I managed to get it "working" as an AI package attached directly to the NPC. It took me a while to figure out how to check conditions on the NPC (using "Subject" and "Swap subject and target"). However, it takes forever for the package to activate once the conditions turn true... looks like you have to wait for currently running package to "complete" before the conditions get reevaluated.

 

So I tried to attach my package as a "combat override", with two stacked procedures: UseMagic and HoldPosition. But that doesn't seem to work at all. Not sure why... the UseMagic just doesn't get invoked. Perhaps AFT is messing with my compbat override?? Or again, it's waiting for HoldPosition to complete before reevaluating the stack?

 

Perhaps I should be using a script to push an unconditional AI package when the time is right.... under the assumption that it will force an immediate reevaluation of the active package.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...