Jump to content

Detecting amount of damage taken by a player


Recommended Posts

I need some help with making a script that detects when and how much damage is done to a player.

 

The OBSE event handler OnHealthChanged is close to what I want, but it detects how much damage is done to a player before the players armor and resistances/weaknesses are applied. What I really want is a hook that detects when the value of a players health changes and by how much.

 

Is there a way to do this?

Link to comment
Share on other sites

Some clarifications:

- The event is called OnHealthDamage

- Despite the OBSE docs says the event is called before the damage, the event is actually called after the damage (you can check: while running the function, the health has already been altered by the damage), but, in case the damage was fatal and the health is below 1**, no dead event has been called yet, so you can restore the health and save the actor before the game checks for his death.

- The damage of the event is already the final damage, comprehensive of any alteration made by any armor/weakness/resistance. Just think about it: a damage event can't be fired before the damage has been applied, and the damage can't be applied before all alterations have been applied, which means the damage event can't be fired before that as well! (As I said, when the event is called the damage has already been applied, so the final damage is already known).

 

To answer your question: yes OnHealthDamage is the one you need.

 

** Yes, in Oblivion an actor dies if health drop below 1 (and not when it drop to 0, like you would guess)

Edited by forli
Link to comment
Share on other sites

  • Recently Browsing   0 members

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