Asking Companion for Healing

Post » Sat Dec 04, 2010 6:36 am

I've modded Morrowind for quite some time and done a fair amount of stuff with it, but since I got a new laptop I figured I'd have a go with Oblivion. I've gone through the scripted-spells-that-remove-everyone's-clothes stage and tried to do something a little more difficult, so I decided I wanted to try a companion.
After following a nice tutorial I got my NPC to be rather good at following and not following when he was meant to, but I thought a nice touch would be if I could ask him to heal me, seemed simple enough: ask for healing, checks to see if you are at full health already, if not, cast the spell at you.
Now, the only bit I'm having trouble with is checking if the player is at full health, because it seems in the dialogue conditions that I can check the player's current health, but I can't compare it to their base value.
Any ideas on how to make this work? I thought perhaps a script of some kind might work, but I wasn't really sure how to go about doing that. Thanks in advance :)
User avatar
~Amy~
 
Posts: 3478
Joined: Sat Aug 12, 2006 5:38 am

Post » Sat Dec 04, 2010 4:17 am

I tried doing something similar.
You'll need to create a new heal spell that your companion can cast on you and not just its self.
Try putting this in the script result space in the dialog option requesting the heal:

CompanionRef.castspell HealSpellRef Player

What I set up was a script that made my knight healing me if I dropped below 50%HP

BeginGame
if CompanionQuest.CompanionFollow == 1 && (Player.GetAV Health) / (Player.GetBaseAV Health) < 0.5 ;If the variable in your companion quest script is set to 1 (what I set for follow) and your hp drops below 50%
CompanionREF.Cast HealSpellRef Player ;Companion cast heal on you
endif
end

Run it through the compiler and it'll automatically tell you if its wrong.
I kinda just pulled this one out of my behind.

Bear in mind "CompanionREF" and "HealSpellRef" are generic referenced I picked out to write this, so you'll have to change them to work for your script.
Hopefully I wrote this correct
User avatar
Ridhwan Hemsome
 
Posts: 3501
Joined: Sun May 06, 2007 2:13 pm

Post » Sat Dec 04, 2010 11:59 am

As far as I know, if you make an NPC to cast an on-target spell on you with the cast function, he is probably going to run up to you and then cast it. If you want him to stay where he's at and cast the spell, you may have to do some kind of workaround like make him turn the correct way, play the casttarget animation, move an activator to where his hand should be, and then make that activator cast the spell at you.
User avatar
BRAD MONTGOMERY
 
Posts: 3354
Joined: Mon Nov 19, 2007 10:43 pm


Return to IV - Oblivion