Jump to content

How to script weapon sounds


PeteTheBard

Recommended Posts

Hi people!

 

I am fairly inexperienced at modding and scripting and have been making a mod, I want to ask:

 

- How do I attach a script to a weapon to make that weapon play a sound when the player swings the weapon

- What might such a script look like?

 

 

I've tried using RegisterForAnimationEvent to register for weapon swings, but every time I compile it within my Form script it shows an error saying that it is not a function. I have SKSE installed.

 

I am really confused and would appreciate any input you guys might have,

 

Thank you!

 

 

P.S: I know that you can add sounds to a weapon directly in the weapon edit screen but I am creating a mod that requires the sound to be played by a script.

 

 

 

Link to comment
Share on other sites

So I solved my problem but in case any others come here from a google search, here is the code I used, which I attached directly to the weapon:

Scriptname a_DOVAKHIN extends Form


Event OnInit()
    RegisterForAnimationEvent(Game.GetPlayer(), "weaponSwing")
EndEvent
 
Event OnAnimationEvent(ObjectReference akSource, string asEventName)
 	if (akSource == Game.GetPlayer()) && (asEventName == "weaponSwing")
            int instanceID = Doh1.play(akSource)        
            Sound.SetInstanceVolume(instanceID, 1.0)        
 	endIf
endEvent


Sound Property Doh1  Auto
Link to comment
Share on other sites

  • Recently Browsing   0 members

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