Attaching a sound to power attacks

Post » Wed Nov 06, 2013 12:54 pm

Been working more on my weaponry sound mod this week and I grew curious on how much more ambitious I can get with it... the idea I had was to play a unique sound when the player performs power attack swings. As expected I found no relevant settings for power attack sounds in the weapon parameters, so I assume this has to be done through scripting somehow. I watched a rudimentary video tutorial on scripting, though it only covered creating an activatable message box placed in a cell.

My gut feeling was that this could somehow be done through the Conditions tab in a Sound Descriptor, but everything is greyed out in that tab if I go to it. Next I searched the object window for anything related to power attacks, and found some AACT form types called ActionDual/Left/RightPowerAttack. Trying to edit them yielded no meaningful parameters. If I look at the Use Info window for them I see a reference to an "IDLE" type called PowerAttackRoot, which doesn't appear anywhere in the object window.

Any pointers on where to go and what to do, or if it's even possible? What I'm assuming is that I need a sound or sound descriptor played from a script and is attached to the power attack AACT entries, though I could very well be wrong.

User avatar
patricia kris
 
Posts: 3348
Joined: Tue Feb 13, 2007 5:49 am

Post » Wed Nov 06, 2013 12:52 pm

My character's make a grunting sound whenever I power attack, so that could be a clue on how to get your unique sound attached to this. So, look at the attack scripts.

User avatar
Donatus Uwasomba
 
Posts: 3361
Joined: Sun May 27, 2007 7:22 pm

Post » Wed Nov 06, 2013 9:04 am

There might be an easier way to do this, but one idea via scripting would be to use RegisterForActorAction to register for a weapon swing, and (assuming that that event will fire before the attack is over - which seems pretty likely) then you can use a spell effect on the player that would play the sound if they are swinging their weapon and the condition IsPowerAttacking is true. (you'd have to use a spell, or something equivalent, because you can't check condition functions directly via script)

I'd probably attach a script like this to a start-game enabled quest:

Spoiler
Scriptname PowerAttackSoundScript extends QuestActor property playerRef autoSpell property swingSpell autoEvent OnInit()  registerForSingleUpdate(1.0)EndEventEvent OnUpdate()  registerForActorAction(0)  ;0 == weapon swingEndEventEvent OnActorAction(int actionType, Actor akActor, Form source, int slot)  swingSpell.cast(playerRef, playerRef)EndEvent

And then make the spell a fire-and-forget type spell with a 1 second duration -- with spell archetype "Script". Give it the condition IsPowerAttacking == 1, so it only affects the player when they are power attacking, and then attach something like this to Magic Effect that the spell uses:

Spoiler
Scriptname PowerAttackEffectScript extends ActiveMagicEffectSound property PowerAttackSFX autoEvent OnEffectStart(Actor akTarget, Actor akCaster)  PowerAttackSFX.play(akTarget)EndEvent
User avatar
Laura Richards
 
Posts: 3468
Joined: Mon Aug 28, 2006 4:42 am

Post » Wed Nov 06, 2013 6:56 am

I'm still quite a beginner at scripting so it's pretty confusing and intimidating. Where would I look for this script? Gameplay > Papyrus Script Manager? I'm in there right now searching for anything related to power attacks, but nothing relevant seems to show up.

That Magig Effect solution might work, but as you said it appears quite convoluted. I think I've seen other mods like combat mods accomplish things that way... and the side effect is that I can also see the effects briefly appearing in the active effects list, in addition to an icon in the corner with SkyUI on. I found that a bit annoying and distracting so it's really something I'd rather avoid.

I was being stupid about the Conditions tab in Sound Descriptors and saw that you just need to enable conditions in the sound tab to get it working... I'm looking through the Condition Functions right now which is a drop down menu without a search function, so it's kind of hard to see if there is anything related to power attacks that way...

User avatar
Alycia Leann grace
 
Posts: 3539
Joined: Tue Jun 26, 2007 10:07 pm

Post » Wed Nov 06, 2013 10:03 am

Some more detailed directions if you want them. Simply checking "Hide in UI" on the magic effect will prevent the spell from ever appearing in the UI or showing up with a SkyUI icon. Good luck, whichever method you find to accomplish this :smile:

Spoiler

Make a new Magic Effect, give it an ID & Name
Effect Archetype: Script
Casting type: Fire and Forget
Flags: Recover, No Hit Event, Painless, Hide in UI
Add condition: IsPowerAttacking == 1
Hit Okay, then open it back up a second time, and attach script #2 that I posted above, then fill all the properties for the script and hit Okay to save.

Make a New spell, give it an ID/Name
Casting: Fire & Forget
Right-click, Add, and look up the ID of your Magic Effect, add it, set duration to 1 second

Make a New Quest, give it an ID/Name
Hit okay, then open it back up a second time, navigate to the "Scripts" tab on the far right, and attach script #1 that I posted above. Fill all the properties and hit okay to save your quest & script.

Save your new plugin and it should be good to go.

User avatar
Bloomer
 
Posts: 3435
Joined: Sun May 27, 2007 9:23 pm

Post » Wed Nov 06, 2013 3:03 am

I'll hang on to the magic effect trick as a last resort in case I can't find any other way. I tried a shot in the dark and just added IsPowerAttacking (Run On Subject) as a condition to a random sound for testing purposes, but that didn't seem to do anything.

The player grunt sounds associated with power attacks is probably the key here. I don't know how to find the relevant entries in the CK though. Since voices are handled differently from sounds there's nothing to go by in Sound Descriptors.

User avatar
CHARLODDE
 
Posts: 3408
Joined: Mon Apr 23, 2007 5:33 pm

Post » Wed Nov 06, 2013 6:39 pm

I think the way the sound descriptor conditions work is that they will be evaluated anytime the sound descriptor is attempted to be played. But if there isn't an effect or a script or an animation event or something trying to play it in the first place, the condition on it won't do anything.

User avatar
darnell waddington
 
Posts: 3448
Joined: Wed Oct 17, 2007 10:43 pm

Post » Wed Nov 06, 2013 5:18 pm

I've made the quest, the magic effect and the spell, and attached the respective scripts to them. But how are they all supposed to come together? I'm not sure how the quest is supposed to trigger the other stuff. I'm also confused as to how the actual sound is meant to be picked. While editing the properties for the PowerAttackEffectScript I found PowerAttackSFX which let me choose a sound from a drop down menu, so I did that. Nothing's happening ingame however.

User avatar
Georgia Fullalove
 
Posts: 3390
Joined: Mon Nov 06, 2006 11:48 pm

Post » Wed Nov 06, 2013 5:20 pm

It should play the sound you chose from the dropdown menu, assuming it works. You could change the quest script slightly to look like this, which should send you a debug message if it is recognizing your weapon swings:

Event OnActorAction(int actionType, Actor akActor, Form source, int slot)  debug.notification("Weapon swung!")  swingSpell.cast(playerRef, playerRef)EndEvent

If you see the debug message but don't hear any sound, then it is possible that for some reason the IsPowerAttacking condition isn't working for some reason (maybe because the OnActorAction event fires too soon or too late -- which you might be able to roughly judge by when the debug message appears). One other way to test, would be to remove the condition from the magic effect, in which case the sound should play no matter what whenever you swing the weapon.

As for how they all come together - the quest is running constantly from the time the game boots up, and the OnActorAction event will fire whenever the player swings a weapon. This then casts the spell, at which point the script on the spell's magic effect is triggered, and plays the sound. (at least in theory :tongue:)

User avatar
glot
 
Posts: 3297
Joined: Mon Jul 17, 2006 1:41 pm

Post » Wed Nov 06, 2013 6:00 pm

The debug message appears as it should. Still no sound. I tried changing the sound itself but that wasn't it either, nor did removing the condition change anything. Then I disabled "Hide from UI" for the magic effect and looked for the active effect to show, which it doesn't. So I guess the problem is that the magic effect isn't being triggered.

User avatar
m Gardner
 
Posts: 3510
Joined: Sun Jun 03, 2007 8:08 pm

Post » Wed Nov 06, 2013 4:29 am

Playing sounds with a script in a magic effect has a lot of pitfalls:

Conditions on the spell.

Conditions on the sound effect it self.

Priority (if the sound is less on the list it may not get played thru the speakers)

Volume levels

Just to name a few and if they are custom sounds there is a lot more pitfalls.

I have been doing this (tricks with sounds) for years in Oblivion and I still have trouble getting my sounds to play in skyrim when I want them to.

...the other issue here is that you would need to have several different sounds for each race and gender unless you are just making this for your own use for just one actor you are playing.

I would WANT to go with trying to use the method CCNA said as that is how the game was designed to play such sounds. But sadly I have not succeeded myself in do that method in skyrim.

User avatar
Julia Schwalbe
 
Posts: 3557
Joined: Wed Apr 11, 2007 3:02 pm

Post » Wed Nov 06, 2013 3:23 pm

Ah, I found out what the problem was... I hadn't assigned the power attack spell to the script properties in the quest. Since this wasn't explicitly stated in the guide my feeble mind wouldn't figure that out by itself.

The sound plays fine now, only problem is I don't really want it to apply to unarmed power attacks. So I need to exempt them somehow.

Spooky, have you tried using the Alternate feature in the sound descriptors? That will make the sound always be loaded into memory. Though that probably won't help if the problem is the script itself.

User avatar
~Amy~
 
Posts: 3478
Joined: Sat Aug 12, 2006 5:38 am

Post » Wed Nov 06, 2013 2:23 am

You can limit it using a http://www.creationkit.com/GetEquippedItemType condition if you want. For instance, to exclude unarmed attacks, add the condition

GetEquippedItemType != 0

to your magic effect, in addition to the IsPowerAttacking condition. The 0 means unarmed attack. The link gives other weapon types and their associated numers.

User avatar
Eduardo Rosas
 
Posts: 3381
Joined: Thu Oct 18, 2007 3:15 pm

Post » Wed Nov 06, 2013 2:11 pm

Gotcha. Thanks for troubleshooting me through this. Now I have a working proof of concept mod, but I'm still unsure if this is a feature I want to implement. I'll need to make a complementary power swing sound that fits all weapons and doesn't get obnoxious...

User avatar
Jessica Raven
 
Posts: 3409
Joined: Thu Dec 21, 2006 4:33 am


Return to V - Skyrim