Editing
OnHit - ObjectReference
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
[[Category:Scripting]] [[Category:Papyrus]] [[Category:Events]] '''Member of:''' [[ObjectReference Script]] Event called when the object reference is hit by a weapon or projectile. == Syntax == <syntaxhighlight lang="papyrus"> Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \ bool abBashAttack, bool abHitBlocked) </syntaxhighlight> == Parameters == *akAggressor: The [[ObjectReference Script (Papyrus)|ObjectReference]] that attacked this reference. *akSource: The [[Weapon Script|Weapon]], [[Spell Script|Spell]], [[Explosion Script|Explosion]], [[Ingredient Script|Ingredient]], [[Potion Script|Potion]], or [[Enchantment Script|Enchantment]] that hit this reference. *akProjectile: The [[Projectile Script (Papyrus)|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 == <syntaxhighlight lang="papyrus"> Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \ bool abBashAttack, bool abHitBlocked) Debug.Trace("We were hit by " + akAggressor) EndEvent </syntaxhighlight> == Notes == akSource and akProjectile can be None under various circumstances: *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 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 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). **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. *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). *Keep in mind, that akAggressor data is somewhat restricted in this event, and not all functions can be run on it. For instance, you cannot call [[GetAnimationVariableBool - ObjectReference|GetAnimationVariableBool]] and its variations on akAggressor. == See Also == *[[ObjectReference Script]]
Summary:
Please note that all contributions to the CreationKit Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see
CreationKit:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Search
Navigation
Landing page
Tutorials
Game Systems
Editor Reference
Scripting Reference
Recent changes
Help
Tools
What links here
Related changes
Special pages
Page information
Page values