Help with simple healing script

Post » Mon Nov 19, 2012 1:59 am

Hi, so I am quite familiar with the creation kit, but relatively new to papyrus and scripting, the papyrus creation kit wiki is very vague and hard to find specific details. Trying to follower other people's healer follower led to no avail because I can't actually view the scripts they used.

Pretty much I just want to make a companion healer who heals the player whenever their health drops below a certain amount.

So here is the script

scriptname healer extends actor
Actor Property Lean Auto
spell property Healother auto

Function Healplayer()
registerforUpdate(5)
endfunction

Event Onupdate()
int playersHealth = Game.GetPlayer().GetActorValue("health") as int
if playersHealth >75
Lean.EquipSpell(Healother, 1)
Healother.cast(self, Game.GetPlayer())

endif
endevent

I have not been able to get anything out of this script besides for it saving successfully...any help would be appreciated, in the mean time I am going to continue reading up on papyrus tutorials
User avatar
Oyuki Manson Lavey
 
Posts: 3438
Joined: Mon Aug 28, 2006 2:47 am

Post » Mon Nov 19, 2012 2:09 pm

Spoiler
ScriptName Healer Extends ActorActor Property PlayerREF Auto ; Much 'cheaper' than GetPlayerSpell Property HealOther AutoEvent OnInit()	RegisterForSingleUpdate(5.0) ; Single update is safer. Use a float value as arg is a FloatEndEventEvent OnUpdate()	If PlayerREF.GetActorValue("Health") < 75.0		EquipSpell(HealOther, 1) ; Called implicitly		HealOther.Cast(Self, PlayerREF)	EndIf	RegisterForSingleUpdate(5.0)EndEvent

Also, [spoiler][code][/code][/spoiler]. Makes posted code a lot easier to digest...
User avatar
Alexis Estrada
 
Posts: 3507
Joined: Tue Aug 29, 2006 6:22 pm

Post » Mon Nov 19, 2012 3:40 am

Thank you very much for the help! The script works, the only other details I would like to sort out is for the actor to actually have the spell equipped and play the animation....
User avatar
JAY
 
Posts: 3433
Joined: Fri Sep 14, 2007 6:17 am


Return to V - Skyrim