Mod:Creation Kit/OnHit - ScriptObject

Member of: Mod:Creation Kit/ScriptObject Script

Event called when a target is hit by a weapon or projectile.

This event will only be sent to the specific script that registered for it. Other scripts attached to the same form/alias/active magic effect will not receive the event unless they also register.

Syntax
Event OnHit(ObjectReference akTarget, ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, \ bool abSneakAttack, bool abBashAttack, bool abHitBlocked, string apMaterial)

Parameters

 * akTarget: The ObjectReference
 * akAggressor: The ObjectReference that attacked this reference.
 * akSource: The Weapon, Spell, Explosion, Ingredient, Potion, or Enchantment that hit this reference.
 * akProjectile: The Projectile that hit this reference.
 * abPowerAttack: Was the hit caused by a power attack?
 * abSneakAttack: Was the hit caused by a sneak attack?
 * abBashAttack: Was the hit caused by a bash attack?
 * abHitBlocked: Was the hit blocked?
 * apMaterial: Material name where this object was hit. Used for specific script reactions to different hit locations.

Examples
Event OnHit(ObjectReference akTarget, ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, \ bool abSneakAttack, bool abBashAttack, bool abHitBlocked, string apMaterial) Debug.Trace(akTarget + " was hit by " + akAggressor) EndEvent