Difference between revisions of "OnHit - ObjectReference"

33 bytes removed ,  06:53, 29 January 2023
→‎Notes: Reverting changes while I test out to be sure.
imported>Terra Nova2
m (→‎Italic textNotes: fixed broken header)
(→‎Notes: Reverting changes while I test out to be sure.)
 
(10 intermediate revisions by 6 users not shown)
Line 31: Line 31:
== Notes ==
== Notes ==
akSource and akProjectile can be None under various circumstances:
akSource and akProjectile can be None under various circumstances:
*If specifying akSource, for example as a Weapon, akSource must be ''cast'' to the form that corresponds to the type. For instance, if(akSource ''as'' Weapon)...akSource = Weapon will yield a compiler error.
*This reference is an [[Actor Script|Actor]]:
*This reference is an [[Actor Script|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 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)
**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.
**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 Script|Actor]]:
*This reference is ''not'' an [[Actor Script|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).
**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.
**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. In all cases, akSource is the sword and not the enchantment. This also applies to spells (one hit for the spell projectile, and one for each associated magic effect).
*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. In all cases, akSource is the sword and not the enchantment. This also applies to spells (one hit for the spell projectile, and one for each associated magic effect).


== See Also ==
== See Also ==
*[[ObjectReference Script]]
*[[ObjectReference Script]]
22

edits