Jump to content

Spell triggered after shouting


Delta

Recommended Posts

Hey, I would use a spell ability rather than a perk. You can put this script on the abilities magic effect

 

Scriptname MyShoutEffectScript extends ActiveMagicEffect 

Spell Property MySpell Auto
Actor Target 

event oneffectstart(actor akTarget, actor akCaster)
    RegisterForAnimationEvent(akTarget, "BeginCastVoice")
    Target = akTarget
endevent
    
Event OnAnimationEvent(ObjectReference akSource, String asEventName)
    MySpell.Cast(Target) ;The actor that this ability is on casts the spell 
EndEvent

Name the script something more unique to your mod.

Edited by dylbill
Link to comment
Share on other sites

In that case, do MySpell.Cast(Target, Target) instead. The target will cast the spell on themselves when shouting. Also don't forgot to fill the spell property after compiling and adding the script. Your ability should be constant effect, self. One more thing, don't forget to add the ability to the player somehow. You can with a reference alias, or a script on a quest that's start game enabled.

Spell Property ShoutAbilitySpell Auto
Actor Property PlayerRef Auto

Event OnInit()
    PlayerRef.AddSpell(ShoutAbilitySpell) 
    Self.Stop() ;stops the quest this script is on 
EndEvent

You can also add a Debug.Notification("Shout") to the OnAnimationEvent to make sure the script is firing.

Link to comment
Share on other sites

Alternatively you can use https://www.creationkit.com/index.php?title=OnSpellCast_-_ObjectReference. Make a quest, have the player as an alias and attach a script to it.

 

Only downside is you need to run a check for all shouts in the game as the Event cares only about spells in general. Casting akSpell to Spell allows for listening to ALL spells(the shout is a form with spells attached to and will catch those but the means checking for ALL spells associated with shouts), but casting to Shout does nothing, requires assigning to akSpell instead. Basically, arrays or formlists of shouts and iterate through them.

Edited by Rasikko
Link to comment
Share on other sites

It works, but I've used AddSpell instead of Cast, that didn't want in any way.
This is the script, attached to an ability spell, attached to a perk. Thank you both guys!

Scriptname MyScript extends ActiveMagicEffect

Actor property PlayerRef Auto
string shoutCast = "BeginCastVoice"
Spell Property MySpell Auto

Event OnInit()
    RegisterForAnimationEvent(PlayerRef, shoutCast)
endEvent

Event OnPlayerLoadGame()
    RegisterForAnimationEvent(PlayerRef, shoutCast)
endEvent

Event OnAnimationEvent(ObjectReference akSource, string asEventName)
    if (asEventName == shoutCast)
    PlayerRef.AddSpell(MySpell, false)
    Utility.Wait(20.0)
    PlayerRef.RemoveSpell(MySpell)
    endIf
endEvent
Link to comment
Share on other sites

  • Recently Browsing   0 members

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