Jump to content

Script to remove spell when sheathing weapon


Recommended Posts

Posted (edited)

Title

 

Say I want to make the fire cloak spell disappear after i sheathe my sword, how would I go about doing it?

I tried this, but it didn't work.

 

 

Event OnActorAction(int actionType, Actor akActor)
   If Game.GetPlayer().HasMagicEffect(FireCloak) && actionType == 9
 Dispel()
    EndIf
EndEvent

magicEffect Property FireCloak  Auto  

Edited by wcrfe
Posted

Two main observations; You need to register for the event and that can only be done on a form (from the code you give, guessing this is part of an activemagiceffect (note that that is not a form).

 

When you want to start listening, you need to have some form, let's say in variable F, that will do the listening and then you call:
F.RegisterForActorAction( 9 )    ; or 10
to start receiving the event on F.  Somewhere it the code that triggers the effect to begin with seems logical.
 

On the form F you will then need to have a script containing e.g. :
Event OnActorAction(int actionType, Actor akActor)
    Game.GetPlayer().DispellSpell( FireCloakSpell )    ; Checks not really needed if you only register for one event type.
    ; UnregisterforActorAction(9)    ; Optionally: Stop listening for now...
EndEvent

spell property FireCloakSpell auto

 

If you want it to work for all actors I would try (not sure it will work) putting it in an activemagiceffect script on (an effect of) the spell itself and using the animation event that comes with sheathe-weapon to detect sheathe events. I don't know what the exact name is but let's assume:  "BeginSheatheWeapon"  then have:
RegisterForAnimationEvent( GetCasterActor() , "BeginSheatheWeapon" )
in the oneffectstart
and the above code in the
OnAnimationEvent.

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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