xkkmEl Posted August 30, 2021 Share Posted August 30, 2021 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 More sharing options...
dylbill Posted August 31, 2021 Share Posted August 31, 2021 If you want the NPC to use the animation, you have to use a UseMagic AI Package instead of a script. In the conditions for the package, you can put IsInCombat == 1 AND GetActorValuePercentage < 20% or something and have both run on the player. https://www.creationkit.com/index.php?title=Procedure_UseMagic Link to comment Share on other sites More sharing options...
xkkmEl Posted August 31, 2021 Author Share Posted August 31, 2021 Thanks. I was afraid of going into neurosurgery. Time to man up and face my phobias. Link to comment Share on other sites More sharing options...
xkkmEl Posted September 5, 2021 Author Share Posted September 5, 2021 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 More sharing options...
dylbill Posted September 5, 2021 Share Posted September 5, 2021 Hmm, yeah that might work. You can also look at another healer follower mod such as Toccata: https://www.nexusmods.com/skyrimspecialedition/mods/12713 to see how they did it. Link to comment Share on other sites More sharing options...
Recommended Posts