OnHit - ScriptObject

Revision as of 15:01, 6 June 2016 by imported>Dog (akWeapon isn't referenced in the in game OnHit event. Most likely a typo for akSource.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Member of: 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.

SyntaxEdit

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

ParametersEdit

  • 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.

ExamplesEdit

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

NotesEdit

  • akSource and akProjectile can be None under various circumstances:
    • The target is an Actor:
      • akSource can be None if hit by a projectile attack where the projectile was not fired by a weapon or spell
      • akProjectile can be None if hit by a melee attack.
    • The target is not an Actor:
      • akSource can be None if hit by a projectile attack where the projectile was not fired by a weapon (for example, a magic spell with a projectile component).
      • akProjectile can be None if hit by a melee attack.
  • Also, if the target is an Actor and the projectile was caused by a weapon enchant, the enchanted weapon will be in akSource.
  • Aliases and quests will automatically unregister for this event when the quest stops. Active magic effects will automatically unregister when they are removed.
  • This event only fires once, in order to have it fire again, you must re-register.

See AlsoEdit