GetHitTypeUDF
From GECK
An example UDF script.
Contents
Description
Returns the type of OnHit event that has currently been fired. More details are available here: GetHitProjectile. Meant to be called in an OnHit event.
Syntax
(hitType:int) targetRef.call GetHitTypeUDF
Example
let int iHitType := rTarget.call GetHitTypeUDF
Script
To use this function, copy the following code into a new object script:
scn GetHitTypeUDF begin function {} ;this = a calling actor, aka the target from the OnHit event. let ref rProjectile := GetHitProjectile let int iHitType := 0 if eval !(IsReference rProjectile) iHitType = 1 elseif eval ((int iType := GetType rProjectile) == 51) ;* 51 = projectile type iHitType = 2 elseif eval (iType == 81) ;* 81 = explosion type iHitType = 3 endif SetFunctionValue iHitType end
To interpret the result of this function for debugging, use the following in an OnHit event script:
let int iHitType := rTarget.call GetHitTypeUDF let array_var aHitTypeStrings := ar_list "?Unknown?", "Invalid ref", "Projectile hit", "Explosion Hit" print "OnHit - iHitType: " + $iHitType + " (" + $aHitTypeStrings[iHitType] + ")"