Jump to content

How to create a spell that dispells when a player attacks or activates an object? (Like Invisibility)


Recommended Posts

Hello. I'm looking to make a simple spell that will automatically dispel if the player attacks or activates an object, the same as Invisibility or Become Ethereal. I looked at how they work in the creation kit, but they use the "Invisibility" and "Etherealize" Effect Archetypes, so I can't copy just the dispel conditions.

I looked through the creation kit wiki and can't find any events to detect attacking or activating. Best I could find was the OnPlayerBowShot event, which obviously isn't enough on its own.

Is there a way to cancel a spell under those conditions? Even better if I can specify which (such as canceling on bow or magic attacks but not melee)

Link to comment
Share on other sites

Hey, if you're using SKSE you can use my mod Dylbill's Papyrus Functions which includes DbSkseEvents, which are global events. https://www.nexusmods.com/skyrimspecialedition/mods/65410?tab=files

Example script: 

Event OnEffectStart(Actor akTarget, Actor akCaster)
    DbSkseEvents.RegisterActiveMagicEffectForGlobalEvent("OnHitGlobal", Self, akCaster, 0)      ;compare akCaster with 'Attacker'. Registers for when the akCaster hits anything
    DbSkseEvents.RegisterActiveMagicEffectForGlobalEvent("OnActivateGlobal", Self, akCaster, 0)      ;compare akCaster with 'ActivatorRef'. Registers for when the akCaster activates anything
EndEvent

Event OnHitGlobal(ObjectReference Attacker, ObjectReference Target, Form Source, Ammo akAmmo, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
    Debug.MessageBox("on hit: Attacker = " + Attacker.getDisplayName() + "\nTarget = " + Target.GetDisplayName() + "\nSource = " + Source.GetName() + "\nAmmo = " + akAmmo.getName() + "\nProjectile = " + akProjectile.getName())
EndEvent

Event OnActivateGlobal(ObjectReference ActivatorRef, ObjectReference ActivatedRef)
    Debug.MessageBox(ActivatorRef.GetDisplayName() + " Activated " + ActivatedRef.GetDisplayName())
EndEvent 

 

You'll have to put some checks in for the OnHit event, like if an actor was hit ect.

If you don't want to use SKSE, there are workarounds. I would suggest animation events for attacking and you can use a perk to detect when an actor activates something. I don't remember the exact method off the top of my head but I use it in my mod Portable Standing Stones https://www.nexusmods.com/skyrimspecialedition/mods/33425 to detect when the player activates a standing stone.

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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