Adding a Spell When You Shout

Post » Tue Sep 23, 2014 10:20 pm

Having some trouble with a part of a script. I'm trying to add an ability to the player when you use a specific shout.

Here's what I've got:

stuff...Spell Property YourAbilityTwo AutoSpell Property YourShoutOne AutoSpell Property YourShoutTwo AutoSpell Property YourShoutThree Auto...stuff...Event OnSpellCast(Form akSpell)	If(akSpell == YourShoutOne || akSpell == YourShoutTwo || akSpell == YourShoutThree)		Game.GetPlayer().AddSpell(YourAbilityTwo)		Utility.Wait(10)		Game.GetPlayer().RemoveSpell(YourAbilityTwo)		debug.notification("Removed")	EndIfEndEvent

The shout is not adding the ability to the player or displaying the "Removed" text.

http://www.creationkit.com/OnSpellCast_-_ObjectReference is the creation kit wiki page on the event. I'm not sure I understand exactly how to use this event. What I find confusing in the example is the line:

Spell spellCast = akSpell as Spell 

Can anyone help me out here?

User avatar
City Swagga
 
Posts: 3498
Joined: Sat May 12, 2007 1:04 am

Post » Tue Sep 23, 2014 10:07 pm

Try:

stuff...Spell Property YourAbilityTwo AutoSpell Property YourShoutOne AutoSpell Property YourShoutTwo AutoSpell Property YourShoutThree Auto...stuff...Event OnSpellCast(Form akSpell)        Spell spellCast = akSpell	If(spellCast == YourShoutOne || spellCast == YourShoutTwo || spellCast == YourShoutThree)		Game.GetPlayer().AddSpell(YourAbilityTwo)		Utility.Wait(10)		Game.GetPlayer().RemoveSpell(YourAbilityTwo)		debug.notification("Removed")	EndIfEndEvent

Might make a difference.

Are all your properties filled?

User avatar
sophie
 
Posts: 3482
Joined: Fri Apr 20, 2007 7:31 pm

Post » Tue Sep 23, 2014 6:44 pm

Nope, It actually didn't compile, but I added this:

Spell spellCast = akSpell as Spell

It compiles but still doesn't work. I checked all the properties again and they're all right.

User avatar
Adam
 
Posts: 3446
Joined: Sat Jun 02, 2007 2:56 pm

Post » Tue Sep 23, 2014 2:08 pm

Look at the SKSE event: OnActorAction
User avatar
Horror- Puppe
 
Posts: 3376
Joined: Fri Apr 13, 2007 11:09 am

Post » Tue Sep 23, 2014 11:10 pm

Correct me if I'm wrong: but http://www.creationkit.com/Spell_Script is not the same as http://www.creationkit.com/Shout_Script. OnSpellCast() is only fired on Spell, Enchantment, Potion, or Ingredient.

Did your OnSpellCast() gets fired at all?

User avatar
Tyrone Haywood
 
Posts: 3472
Joined: Sun Apr 29, 2007 7:10 am

Post » Tue Sep 23, 2014 11:15 pm

I'd rather not use an SKSE event. My mod doesn't require it yet and I want to keep it that way.

Yeah it doesn't fire at all. Which is strange because Shouts are classified as spells in the CK. I guess it isn't possible without SKSE.

User avatar
Katy Hogben
 
Posts: 3457
Joined: Mon Oct 30, 2006 12:20 am

Post » Tue Sep 23, 2014 10:40 pm

Shouts are a bit strange. They use spells to do their damage and cause their effects, but they aren't technically spells when they're cast I guess.

It's still possible to do what you want without using SKSE though. Here's one possibility (there may be others) -

Use kuertee's method of http://www.creationkit.com/Passing_Conditions_to_Papyrus, combined with http://www.creationkit.com/IsPlayerActionActive to generate an event every time the player shouts.

User avatar
Natasha Callaghan
 
Posts: 3523
Joined: Sat Dec 09, 2006 7:44 pm

Post » Wed Sep 24, 2014 1:47 am

How about OnMagicEffectApply()? You could catch the 'underlying' Spell's MagicEffect?

User avatar
Tom Flanagan
 
Posts: 3522
Joined: Sat Jul 21, 2007 1:51 am

Post » Tue Sep 23, 2014 3:24 pm

That would work too, especially if you're trying to detect shouts that affect the player.

Though if you want to detect when the player is using shouts with a magic effect that is supposed to hit other things (like Unrelenting Force), it would be a bit trickier, since OnMagicEffectApply would need to be in a script attached to whatever is hit by the shout's magic effect.

User avatar
Phillip Hamilton
 
Posts: 3457
Joined: Wed Oct 10, 2007 3:07 pm

Post » Tue Sep 23, 2014 6:37 pm

Yeah I've made an OnEffectStart() version that works. It adds the ability but only when you hit something. I want it to add regardless of hitting anything.

User avatar
Damian Parsons
 
Posts: 3375
Joined: Wed Nov 07, 2007 6:48 am

Post » Tue Sep 23, 2014 1:49 pm

Thanks, I'll give this a try and report back with the results.

User avatar
Eoh
 
Posts: 3378
Joined: Sun Mar 18, 2007 6:03 pm

Post » Tue Sep 23, 2014 11:50 pm

Ah ok, then egocarib's suggestion should be the best solution.

User avatar
koumba
 
Posts: 3394
Joined: Thu Mar 22, 2007 8:39 pm

Post » Tue Sep 23, 2014 6:15 pm

Small note: I just edited the Passing Conditions To Papyrus page to clarify a detail in step 4 of kuertee's instructions - you need to make sure you add the condition to the Effect Item in your ability (not to the Magic Effect itself, as the original instructions could have been interpreted to mean).

This is because conditions on the Effect Item in the ability will update every second, but conditions on the Magic Effect will only be checked when the ability first is added to the player.

User avatar
Cheville Thompson
 
Posts: 3404
Joined: Sun Mar 25, 2007 2:33 pm

Post » Wed Sep 24, 2014 4:05 am

I made the ability with a magic effect that runs a script, just like in the tutorial. I added it to the player using a quest, and it was invisible in the UI even though I have "Hide in UI" unchecked. The script on the magic effect NEVER ran, even with no conditions on the magic effect. I'm wasn't sure that you can add an ability with a magic effect archetype "script". So I changed the effect architype to cloak and the ability still didn't show up in the UI.

I'm really confused now because I'm adding another ability with the same quest in exactly the same way and it works fine, but this new ability never shows up at all in the active effects menu.

User avatar
Victoria Bartel
 
Posts: 3325
Joined: Tue Apr 10, 2007 10:20 am

Post » Tue Sep 23, 2014 9:35 pm

Not really sure what I did but it's adding now.

User avatar
tiffany Royal
 
Posts: 3340
Joined: Mon Dec 25, 2006 1:48 pm

Post » Wed Sep 24, 2014 2:56 am

So everything is working now except the condition function GetSpellHasKeyword (ShoutFireBreath) == 1. If I remove that, the shout adds the ability to the player fine.

How else could I check to make sure the player is only using the flame breath shout?

User avatar
Sian Ennis
 
Posts: 3362
Joined: Wed Nov 08, 2006 11:46 am

Post » Tue Sep 23, 2014 4:46 pm

Got it! It's GetEquippedShout (FireBreathShout) == 1

User avatar
stacy hamilton
 
Posts: 3354
Joined: Fri Aug 25, 2006 10:03 am

Post » Wed Sep 24, 2014 5:19 am

For some reason the shout doesn't trigger the script when I'm in combat. Anyone know whats going on with that?

After some testing, i found that the ability will trigger with wolves nearby, as long as they aren't in combat with you. As soon as they enter combat with you, you cant trigger the ability. I still have no idea why this is happening though.

User avatar
Lou
 
Posts: 3518
Joined: Wed Aug 23, 2006 6:56 pm


Return to V - Skyrim