Jump to content

[LE] Fireball spell passes akSource=Unarmed to OnHit


Recommended Posts

I have the following Event in a script from my mod:

Scriptname BU_Monitor extends ActiveMagicEffect
{Monitors NPC for unarmed attacks from player}

Actor Property PlayerRef Auto
Weapon Property Unarmed Auto

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
  If akAggressor == PlayerRef && akSource == Unarmed
    Debug.Trace("BU - Unarmed attack detected")
    Debug.Trace("Source: " + akSource)
    Debug.Trace(Unarmed)
  EndIf
EndEvent

The script is placed on enemies and is supposed to detect unarmed attacks. As far as I can tell it works fine, except for one very peculiar case: hitting an enemy with a Fireball spell also results in akSource being equal to the Unarmed weapon (more precisely, form ID 1F4) and therefore passing the if-check. I wasn't able to find any other spell that this would happen with. Chain Lighting, Incinerate, Flames, and Ice Spear all correctly failed the if-check.

 

I am loading no other mods, not even SKSE. The only mod I'm running is my own, which doesn't touch Fireball in any way.

 

Why then is Fireball being recognized as an Unarmed attack?

Edited by MateDeVita
Link to comment
Share on other sites

No idea why Fireball is failing the check.

 

Do unarmed attacks have projectiles? If no, then do

If akAggressor == PlayerRef && akSource == Unarmed && !akProjectile

That should weed out any projectile spell (as well as ammo) that may fail the unarmed check alone.

Link to comment
Share on other sites

Unfortunately that workaround doesn't work either.

 

Upon further inspection, the problem is that a single Fireball spell triggers OnHit 3 times with the following values (remember that Unarmed is Form ID 1F4):

  1. akSource = [sPELL < (0001C789)>], akProjectile = [PROJECTILE < (0010FBED)>]
  2. akSource = [Explosion < (000439C0)>], akProjectile = None
  3. akSource = [WEAPON < (000001F4)>], akProjectile = None

I have been looking through the spell in the Creation Kit and comparing it to other spells but I haven't been able to determine what causes that 3rd (Unarmed) hit, nor have I been able to determine what other spells may be affected by this issue (since if it's just Fireball I could work around that by, say, ignoring the next Unarmed OnHIt when a Fireball OnHit happens).

Link to comment
Share on other sites

I managed to work around the issue by using SKSE's RegisterForActorAction to keep track of the player's last executed action and I always check it in OnHit to see if it was an unarmed swing. It's not a perfect workaround (a player could, for example, shoot a long range fireball, then swing an empty hand while the fireball was in flight), but it's good enough.

Edited by MateDeVita
Link to comment
Share on other sites

  • Recently Browsing   0 members

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