Difference between revisions of "OnHit - ObjectReference"
Jump to navigation
Jump to search
CreedAngelus (talk | contribs) (→Notes: I used the following SKSE script to confirm whether multiple hits with an enchanted weapon treat akSource as the sword for each time the event is called: https://docs.google.com/document/d/1B9FE8GgtiU0kLLagVchC0XbO2rehFWyxGgGFhAFfj8g/edit?usp=sharing) |
CreedAngelus (talk | contribs) |
||
Line 40: | Line 40: | ||
**akProjectile can be None if hit by a melee attack. | **akProjectile can be None if hit by a melee attack. | ||
Also, if this reference is an [[Actor Script|Actor]] and the projectile was caused by a weapon enchant, the enchanted weapon will be in akSource. | Also, if this reference is an [[Actor Script|Actor]] and the projectile was caused by a weapon enchant, the enchanted weapon will be in akSource. | ||
*This event is called multiple times when akSource has associated magic effects. If a sword has an enchantment with 2 effects, OnHit will be called 3 times - once for the physical damage of the sword and once for each magic effect. akSource is the sword for the first case | *This event is called multiple times when akSource has associated magic effects. If a sword has an enchantment with 2 effects, OnHit will be called 3 times - once for the physical damage of the sword and once for each magic effect. akSource is the sword for the first case. This also applies to spells (one hit for the spell projectile, and one for each associated magic effect). | ||
**Requires further testing. Previously, this entry claimed akSource will be the sword for all hits however, [https://drive.google.com/file/d/1e6A3IrZegopgxJ5m0iBNe38eBapj_rj7/view?usp=sharing this script] will only register the sword as akSource for the physical damage. | |||
== See Also == | == See Also == | ||
*[[ObjectReference Script]] | *[[ObjectReference Script]] |
Revision as of 05:43, 29 January 2023
Member of: ObjectReference Script
Event called when the object reference is hit by a weapon or projectile.
Syntax
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \
bool abBashAttack, bool abHitBlocked)
Parameters
- 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?
Examples
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \
bool abBashAttack, bool abHitBlocked)
Debug.Trace("We were hit by " + akAggressor)
EndEvent
Notes
akSource and akProjectile can be None under various circumstances:
- This reference is an Actor:
- akSource can be None if hit by a projectile attack where the projectile was not fired by a weapon or spell
- akSource can be None if hit by a bash attack from a carried light object (e.g., a torch)
- akProjectile can be None if hit by a melee attack.
- In fact, at least in SE, akProjectile appears to always be None if the reference is an Actor, although it does work as expected for some other types, such as Activators.
- This reference 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 this reference is an Actor and the projectile was caused by a weapon enchant, the enchanted weapon will be in akSource.
- This event is called multiple times when akSource has associated magic effects. If a sword has an enchantment with 2 effects, OnHit will be called 3 times - once for the physical damage of the sword and once for each magic effect. akSource is the sword for the first case. This also applies to spells (one hit for the spell projectile, and one for each associated magic effect).
- Requires further testing. Previously, this entry claimed akSource will be the sword for all hits however, this script will only register the sword as akSource for the physical damage.