Script to check player and mod players health

Post » Thu Jun 21, 2012 12:31 pm

I have made the player essential and now I want to make there be a penalty for going into bleedout of a reduction in max health.

I was originally trying to write a script checking if the player entered bleedout, but I was getting nowhere. So instead I've switched to checking if player health is 0 (On the assumption it is when the pc health goes to 0 that triggers bleedout) and then applying the penalty.

So I am trying to
- Detects if the players health is zero
- Reduces the max health if it is

Scriptname WZTestBleedout extends QuestEvent Oninit()		  if Game.GetPlayer().GetActorValue("health") == 0				  Game.GetPlayer().ModActorValue("health", -10)endIfendEvent

I've got the script to compile but it isn't doing anything. I'm guessing I need to change it to an onstory script event but I don't know how to do that. Any help would be greatly appreciated!
User avatar
Jonathan Braz
 
Posts: 3459
Joined: Wed Aug 22, 2007 10:29 pm

Post » Thu Jun 21, 2012 10:14 am

OnInit() only fires once, and only once. It's only firing the first time the Plug-ins loaded, at the very beginning. It will never fire again. Try using this:

 Scriptname WZTestBleedout extends QuestEvent Oninit()				  RegisterForSingleUpdate(10.0)EndEventEvent OnUpdate()	 If Game.GetPlayer().GetAV("Health") == 0		  Game.GetPlayer().ModAV("Health", -10)	 EndifRegisterForSingleUpdate(10.0)EndEvent
User avatar
Anna Watts
 
Posts: 3476
Joined: Sat Jun 17, 2006 8:31 pm

Post » Thu Jun 21, 2012 4:40 am

Thanks, yeah I know about Oninit, I was trying a whole bunch of different events.

RegisterForSingleUpdate didn't work, so I tried RegisterForUpdate instead.

EDIT: Ah, have it! Changed back to IsBleedingOut instead of GetAv and it worked!

Scriptname WZTestBleedout extends QuestEvent Oninit()                                  RegisterForUpdate(1)EndEventEvent OnUpdate()         If Game.GetPlayer(). IsBleedingOut()                  Game.GetPlayer().ModAV("Health", 10)         EndifRegisterForUpdate(1)EndEvent
User avatar
Marguerite Dabrin
 
Posts: 3546
Joined: Tue Mar 20, 2007 11:33 am


Return to V - Skyrim