Jump to content

[LE] OnHit and filtering out enchantment hits


Recommended Posts

I've discovered a few more things. If you just run an OnHit event with nothing but a debug trace telling you what akSource is, it will report the following; WEAPON (if it has no enchantment on it), FORM (if a weapon has an enchantment on it, and spells), and EXPLOSIONS as Forms. I attempted to pass a potion hit via poison by applying one to an NPC and giving them the item but that hit was not passed at all.

Link to comment
Share on other sites

audiogarden21 wrote: "I've come to the conclusion that the wiki entry for the event is either out of date or just plain wrong in just about every way for Skyrim SE."
I have overseen that message from your first posting.

You wrote: "I'm just trying to ascertain whether this is a 'me' issue, or if OnHit() somehow got broken between Oldrim and Skyrim SE."
and times later: "One thing to note; it might still work for Oldrim so you might just want to notate that the information is false for Skyrim SE only if that turns out to be the case."

Why the hell are you posted to Skyrim forum and not to the Skyrim SE forum. You make someone crazy here!!

You researched some mistakes to Skyrim wiki by testing with installed Skyrim SE + SKSE 2.0.19 + mods like
(1) Address Library for SKSE Plugins
(2) Stay At The System Page
(3) Unofficial Skyrim SE Patch
(4) SkyUI SE

1. akSource inside OnHit() events cannot be casted like this

    IF (akSource as Enchantment)
        ; does not work for Skyrim SE
    ENDIF

only next is working for weapon and enchantment hits

    IF (akSource as Weapon)
          ; if weapon is enchanted it runs twice here
          Debug.Trace(" OnHit() - " + akSource)
    ENDIF


2. native function GetEquippedWeapon() https://www.creationkit.com/index.php?title=GetEquippedWeapon_-_Actor

I was wrong here! See posting of mine before in this thread.

 

3. You discovered this by writing next:
"WEAPON (if it has no enchantment on it), FORM (if a weapon has an enchantment on it, and spells), and Explosions."
What does it mean? I cannot do anything with your comment.

akSource is parameter like this "Form akSource"

    EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProj, Bool b1, Bool b2, Bool b3, Bool b4)
    ; b1 = abPowerAttack
    ; b2 = abSneakAttack
    ; b3 = abBashAttack
    ; b4 = abHitBlocked
    
    ENDEVENT
Edited by ReDragon2013
Link to comment
Share on other sites

@ReDragon2013

 

You're right. I hadn't realized there was a separate forum for SSE. That's my fault. I apologize. If a moderator could please move this to the SSE equivalent mod help thread that would be great.

 

1. akSource inside OnHit() events cannot be casted like this

 

Which is precisely why I'm here.

2. the native function GetEquippedWeapon() https://www.creation...dWeapon_-_Actor works different
Skyrim:
Weapon Function GetEquippedWeapon(bool abLeftHand = false) native

 

 

Are you sure about that? Because when I dig into the Actor script for SSE it says this, which coincidentally is the same thing the wiki says;

 

; Gets this actor's currently equipped weapon

; false - Default - Right Hand
; true - Left Hand
Weapon Function GetEquippedWeapon(bool abLeftHand = false) native

 

3. You discovered this by writing next:

"WEAPON (if it has no enchantment on it), FORM (if a weapon has an enchantment on it, and spells), and Explosions."
What does it mean? I cannot do anything with your comment.

 

What it means is that if a weapon has no enchant, debug.trace reads "akSource" as "[WEAPON < (00013983)>]". Obviously the ID changes based on the weapon. If you are hit with a weapon that has an enchantment on it or are hit by a spell, debug.trace reads "akSource" as "[Form < (00028DE8)>]", again, ID is just an example from one of my logs. WEAPON, and FORM, respectively. I just thought it was interesting.

Link to comment
Share on other sites

Can confirm the posted code on here, as well as on the wiki, is completely useless. Casting akSource to enchantment doesn't validate either.

The text at the bottom of the notes on the wiki page for OnHit states:

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 is absolutely true. However, before I remove the code examples from the wiki I'm willing to wait for someone else to verify as well.

Link to comment
Share on other sites

@RichWebster

 

Did you run it in SSE? It has been brought to my attention that I have posted this in the wrong forum segment. I hadn't realized there was a specific SSE forum. Whoops!

 

There's also another quirk I noticed regarding enchantments. Even when I filter to only show enchantments using SKSE's "GetEnchant()" function on akSource, it too runs the code twice per hit.

 

Here's the code snippet I used:

Enchantment SourceEnchantment = (akSource as Weapon).GetEnchantment()
If (SourceEnchantment != None)
	If (SourceEnchantment == EnchWeaponFireDamage04) ;I just chose this one because it's on the daedric mace I put on NPCs for testing
		Debug.Trace("Enchantment ID: "+SourceEnchantment)
	EndIf
EndIf 

You can also run "HasKeyword()" on the enchantment to test for MagicDamageFire and that will do the same thing. It's very peculiar.

Link to comment
Share on other sites

I ran it in normal Skyrim. And I played with SKSE functions as well to see if it can be isolated, and it can't. Each OnHit event is both a weapon hit and enchantment hit, there's no way in script to distinguish between the two.

 

If it was imperative in a wider sense then a different solution would have to be investigated, perhaps using perks or ability spells.

 

For your purpose the time constraint seems to be the best option.

Link to comment
Share on other sites

Yeah. That's what I've settled on and why I stopped asking for help on that front. =)

 

Well it's a shame that is the case then. I wonder if the SKSE team could fix that? I'm not sure how far they can go into fixing things but it would be interesting to see what's going on under the hood at the very least.

 

Thanks for lookin' into it for me though. It's much appreciated. I got a problem... When I come across anomalies like that I become obsessed. It gets pretty bad sometimes, heh.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...