Background for Starfield
Member of the ScriptObject script
eventOnHit(ObjectReferenceakTarget, ObjectReferenceakAggressor, FormakSource, ProjectileakProjectile, boolabPowerAttack, boolabSneakAttack, boolabBashAttack, boolabHitBlocked, stringasMaterialName)

[DEV SERVER] Loading description...


Caveats

CK Wiki - Notes

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


Parameters

ObjectReferenceakTarget

CK Wiki Description

ObjectReferenceakAggressor

CK Wiki Description

The ObjectReference that attacked this reference.

FormakSource

CK Wiki Description

The Weapon, Spell, Explosion, Ingredient, Potion, or Enchantment that hit this reference.

ProjectileakProjectile

CK Wiki Description

The Projectile that hit this reference.

boolabPowerAttack

CK Wiki Description

Was the hit caused by a power attack?

boolabSneakAttack

CK Wiki Description

Was the hit caused by a sneak attack?

boolabBashAttack

CK Wiki Description

Was the hit caused by a bash attack?

boolabHitBlocked

CK Wiki Description

Was the hit blocked?

stringasMaterialName


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

Auto-Generated Example

Scriptname MyCoolScript extends ScriptObject

event OnHit(ObjectReference akTarget, ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked, string asMaterialName)
    Debug.trace("Event received - OnHit: akTarget = " + akTarget + " akAggressor = " + akAggressor + " akSource = " + akSource + " akProjectile = " + akProjectile + " abPowerAttack = " + abPowerAttack + " abSneakAttack = " + abSneakAttack + " abBashAttack = " + abBashAttack + " abHitBlocked = " + abHitBlocked + " asMaterialName = " + asMaterialName)
endEvent

Related Pages


Additional References

View this event’s page on the Fallout 4 Creation Kit Wiki

Some data provided by the Fallout 4 Creation Kit Wiki. Licensed under the Creative Commons Attribution-Share Alike 4.0 license.