MSFD Keeping track of kills and knockouts
OnDeath (returns Boolean/short)
If ( Actor->OnDeath == 1 )
Returns 1 for 1 frame when the Actor is killed. OnDeath seems to reset itself once it is used. This also means that only one script can reliably detect death this way: if you have both a global and a local script using this function, only the global script will detect OnDeath. An alternative would be to use the GetHealth function. In the following script only the first message box will be displayed (forum info / Argent, ThePal):
begin personScript
if ( OnDeath )
messagebox "1"
endif
if ( OnDeath )
messagebox "2"
endif
end
OnMurder (returns Boolean/short)
If ( Actor->OnMurder == 1 )
Returns 1 for 1 frame when the Actor is murdered. The conditions for OnMurder are not entirely clear to me – from the context of its use in the game however, it seems that OnMurder gets set when you are reported as a murderer to the law ("your crime has been reported"). So a murder only happens when you kill someone illegally AND are seen.
Sample Script: this sets a variable that is used in the "Redoran Hortator" dialogue topic to determine if the player has killed a councilor:
begin RedoranCouncilor
;no lore...
short noLore
;for HT_Monopoly
short mageMonopolyVote
;for Hortator dialogue...
if ( OnDeath == 1 )
if ( OnMurder == 1 )
Set RedoranMurdered to 2
else
Set RedoranMurdered to 1
endif
endif
End
OnKnockout (returns Boolean/short)
If ( Actor->OnKnockout == 1 )
Returns true for one frame when the Actor is knocked unconscious (e.g. in hand-to-hand combat)
[no fix] GetDeadCount, "Actor ID" (returns short)
If ( GetDeadCount "divayth fyr" > 0)
The function returns the number of references (individuals) of type "Actor ID" that have been killed. A useful function for quest scripting to keep track of which NPCs are still alive. Note that there is an equivalent function for dialogue as well. Other uses are imaginable, e.g. building a reputation with certain monsters that might flee you instead of fighting after you killed more than 100 of them, etc.
Sample Script:
GetDeadCount is often used to check if a certain NPC is dead. It is advisable to use "> 0" in such cases, as you never know if another mod might add another instance of that ID, so it's better to play it safe.
Begin araraUvulasScript
short noLore
if ( CellChanged == 0 )
return
endif
if ( GetDeadCount "Neloth" > 0 )
Disable
endif
End