MateDeVita Posted August 18, 2019 Share Posted August 18, 2019 (edited) 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 August 18, 2019 by MateDeVita Link to comment Share on other sites More sharing options...
IsharaMeradin Posted August 19, 2019 Share Posted August 19, 2019 No idea why Fireball is failing the check. Do unarmed attacks have projectiles? If no, then do If akAggressor == PlayerRef && akSource == Unarmed && !akProjectileThat should weed out any projectile spell (as well as ammo) that may fail the unarmed check alone. Link to comment Share on other sites More sharing options...
MateDeVita Posted August 19, 2019 Author Share Posted August 19, 2019 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): akSource = [sPELL < (0001C789)>], akProjectile = [PROJECTILE < (0010FBED)>] akSource = [Explosion < (000439C0)>], akProjectile = None akSource = [WEAPON < (000001F4)>], akProjectile = NoneI 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 More sharing options...
IsharaMeradin Posted August 19, 2019 Share Posted August 19, 2019 Well, bummer. I tried. Just as clueless as you then. Sorry. Link to comment Share on other sites More sharing options...
MateDeVita Posted August 20, 2019 Author Share Posted August 20, 2019 (edited) 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 August 20, 2019 by MateDeVita Link to comment Share on other sites More sharing options...
Recommended Posts