GetHitProjectile

From GECK
Jump to: navigation, search


A function added by the JIP NVSE Plugin.

Description

When called from a OnHit/OnHitWith script block (or the corresponding NVSE event handlers), or from a ScriptEffectStart block in an Ammo form Impact Script, will return the Projectile OR Explosion reference (if any) of the current hit.

Syntax

[help]
(projectile/Explosion:ref) reference.GetHitProjectile

Example

set rProjectileRef to targetRef.GetHitProjectile 

Notes

  • The OnHit event from SetOnHitEventHandler can run multiple times for what seems to be a singular hit. This function can return up to three different results for the different instances of the OnHit event. These return values categorize the type of OnHit event that has occurred:
1: No valid reference 
2: Projectile-type reference
3: Explosion-type reference

GetHitTypeUDF can be used to retrieve the type of OnHit event that is occurring.

Note that these types of OnHit events are not necessarily in order of possible frame-time execution; for example, when an explosion directly hits an actor, first the Projectile-type reference OnHit event runs, then No valid reference, and finally Explosion-type reference.

  • Case 1 (No valid reference):
    • If the attack is a regular melee hit, this will be the only time the OnHit event will fire. In this case, GetHitHealthDamage returns a reliable result.
    • This may also happen right before an Explosion-type reference OnHit event occurs. In this case, GetHitHealthDamage does NOT return a reliable result; damage should only be checked when the Explosion-type reference OnHit event occurs.
    • For flamethrower-type hits, the OnHit event will run a couple times with this case. For all these cases, GetHitHealthDamage does NOT seem to be reliable to check. Instead, it is more accurate to check for a Projectile-type reference hit, which will run once, and then check the health damage.
  • Case 2 (Projectile-type reference):
    • For throwing-type weapons like the Throwing Spear, this is the only OnHit event-type that will be executed (it is executed only once), and GetHitHealthDamage is safe to check here.
    • For shotgun-type weapons, this is also the only OnHit event-type that will be executed, except it is executed multiple times for SetOnHitEventHandler, equal to the amount of pellets the weapon has. GetHitHealthDamage will return the amount of damage each pellet is dealing.
  • Case 3 (Explosion-type reference):
    • To check damage from explosions, checking the damage from this type of event (+ possibly checking the Projectile-type reference type in order to account for direct projectile hit damage) is all that is needed.
      • Caveat: if the player fires a grenade launcher right next to a mine that they're next to, the collective detonation will fire this type of event twice, but the total damage retrieved by GetHitHealthDamage will be inaccurate.

See Also