SetOnCriticalHitEventHandler

From GECK
Jump to: navigation, search


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 Critical Hit.

Any combination of the three optional arguments may be used for filtering events:

  • target - The target Actor (taking the hit).
  • source - The source Reference (striking the hit).
  • weapon - The Weapon dealing the hit.

Note: Due to GECK limitations, the function cannot accept 0-valued arguments. As a workaround, when required, pass XMarker to indicate a filter should be ignored (see examples, below).

When invoked, the script is passed with the struck Actor as the calling reference ("this"), and two arguments: the source Reference and the Weapon.

Syntax

[help]
SetOnCriticalHitEventHandler handlerScript:ref setORremove:1/0 target:ref source:ref weapon:ref

Example

SetOnCriticalHitEventHandler OnCriticalHitUDF 1

Sets the OnCriticalHitUDF script as a handler to be invoked whenever any actor takes a critical hit (unfiltered).

SetOnCriticalHitEventHandler OnCriticalHitUDF 1 FortCaesarRef

...whenever FortCaesarRef takes a critical hit.

SetOnCriticalHitEventHandler OnCriticalHitUDF 1 FortCaesarRef PlayerRef

...whenever FortCaesarRef takes a critical hit from the Player.

SetOnCriticalHitEventHandler OnCriticalHitUDF 1 XMarker PlayerRef

...whenever any actor takes a critical hit from the Player.

SetOnCriticalHitEventHandler OnCriticalHitUDF 1 XMarker XMarker Weap10mmPistol

...whenever any actor takes a critical hit from a Weap10mmPistol.

SetOnCriticalHitEventHandler OnCriticalHitUDF 1 XMarker PlayerRef Weap10mmPistol

...whenever any actor takes a critical hit from the Player, using a Weap10mmPistol.

Handler Script

A skeleton handler script for this event:

scn	OnCriticalHitUDF

ref	rTarget
ref	rSource
ref	rWeapon
int	iHitLocation

begin Function {rSource, rWeapon}

	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.

See Also