SetOnHitEventHandler
From GECK
A function added by the JIP NVSE Plugin.
Description
Sets/removes the specified UDF Script as a handler that will be invoked in the event an Actor is struck by a Hit.
The optional argument may use an Actor or Form List for filtering events:
When invoked, the script is passed with the struck Actor as the calling reference ("this").
Syntax
SetOnHitEventHandler handlerScript:ref setORremove:1/0 target:ref
Example
SetOnHitEventHandler OnHitUDF 1
Sets the OnHitUDF script as a handler to be invoked whenever any actor takes a hit (unfiltered).
SetOnHitEventHandler OnHitUDF 1 FortCaesarRef
...whenever FortCaesarRef takes a hit.
SetOnHitEventHandler OnHitUDF 1 AndaleResidentList
...whenever any actor in AndaleResidentList takes a hit.
Handler Script
A skeleton handler script for this event:
scn OnHitUDF ref rTarget int iHitLocation begin Function { } set rTarget to this set iHitLocation to GetHitLocation ; (Optional) (code) end
Notes
- When explosions trigger this event it can fire up to three times. To detect which of the three possible times use GetHitProjectile and GetType on the returned projectile. The function will return 0 on the first firing. On the second firing it will either return the Projectile that hit the actor or the Explosion that hit the actor if it was not a direct hit. On the third firing it will return the Explosion that hit the actor if a Projectile hit the actor on the second firing.
- This event runs before the actor takes damage from the hit. It also runs before the on-hit console message from Verbose occurs.
- Unlike the OnHit blocktype, in the case of Shotgun hits, this event runs for each pellet.