Jump to content

Script to "temporarily" change combat music, does one exist?


Recommended Posts

  • Replies 59
  • Created
  • Last Reply

Top Posters In This Topic

I am not having any luck Dybill. The following are my settings/entries and I can't seem to find where I'm screwing up. In-game I get the debug notification about entering the trigger, followed by something about volume set to .80000000.


I placed 1 sound marker for MyCustomMusic, and 1 sound marker for combat MyCustomCombatMus, loaded a new game and I hear the MyCustomMusic just fine, but as I near the trigger I hear MyCustomCombatMusic already playing and then when I do enter the trigger and enter into combat I get the default vanilla combat music on top of MyCustomCombatMusic that was already playing. It's like the muting part of the vanilla isn't working for some reason. And why MyCustomCombatMusic is already playing before entering into combat has me confused as well. I'm lost.


The Properties filled out:


AudioCategoryMUS (AudioCategoryMUS)

DetectCombatAbility (DetectCombatAbilitySpell)

MyAudioCategoryMUS (AudioCategoryMUS_Taarakian)

MyCustomCombatMus (Custom combat music (sound markers))

MUS_Custom_HeavyMetal_HeavyMetal

MUS_Custom_HeavyMetal_Prefabricated

MUS_Custom_HeavyMetal_RadarRider

MUS_Custom_HeavyMetal_TheMobRules

MyCustomCombatMusicLengths

192.000000

161.000000

228.000000

172.000000

MyCustomMusic

MUS_Custom_DungeonIce01

MUS_Custom_DungeonIce02

MyCustomMusicLengths

135.000000

118.000000

PlayerRef

PlayerRef ('Player' )



My Entries:


SOUND CATEGORIES

AudioCategoryMUS_Taarakian

_AudioCategoryMaster (gray pulldown menu entry - ???)

AudioCategoryMUS_Taarakian_Combat

_AudioCategoryMaster (gray pulldown menu entry - ???)


SOUND DESCRIPTORS

MUS_Custom_Combat_HeavyMetal (Category: AudioCategoryMUS_Taarakian_Combat )

HEAVY METAL_The_Mob_Rules_Black_Sabbath.wav

HEAVY METAL_Riggs_Radar_Rider.wav

HEAVY METAL_Sammy_Hagar.wav

HEAVY METAL_Prefabricated_Trust.wav

MUS_Custom_DungeonIce (Category: AudioCategoryMUS_Taarakian)

mus_dungeon_ice_01.wav

mus_dungeon_ice_02.wav


SOUND MARKERS

MUS_Custom_DungeonIce01

MUS_Custom_DungeonIce02

MUS_Custom_HeavyMetal_HeavyMetal

MUS_Custom_HeavyMetal_Prefabricated

MUS_Custom_HeavyMetal_RadarRider

MUS_Custom_HeavyMetal_TheMobRules

Link to comment
Share on other sites

Don't actually place the sound markers in the creation kit render window. You just need the sound marker base forms in the arrays. If you're still hearing the vanilla music, it means the script didn't mute the vanilla music. After entering your triggerbox, go to settings / audio and the music setting should be all the way to the left, (muted.) When starting combat you should get a "Playing custom combat music" notification. If not, you might not have set up the detectCombatAbilitySpell correctly, or not filled the properties in the magic effect script.

Link to comment
Share on other sites

dylbill [Posted 29 June 2021 - 09:55 PM]

Adjust the suggested script as follow:

 

Event OnTriggerEnter(ObjectReference akActionRef)
        ;Debug.Notification("Trigger Enter")
        If akActionRef == PlayerRef
            debug.notification("Player entered trigger box.")
            
            GoToState("InTriggerBox") ;we are in the trigger box. Go to state that detects when we leave the trigger box.
            
            MusicVolume = Utility.GetIniFloat("fVal2:AudioMenu") ;get current volume that user has set music to
            
            debug.notification("MusicVolume = " + MusicVolume)
            
            If MusicVolume < 0.0
                MusicVolume = 0.0
            Endif
            
            ;manually fade out vanilla music
            Float MusicFade = MusicVolume ;use local variable to fade out vanilla music
            While MusicFade > 0.0
                MusicFade -= 0.1 ;subtract 0.01 from musicFade
                
                If MusicFade < 0.0 ;limit, music fade cannot go below 0
                    MusicFade = 0.0
                Endif
                
                AudioCategoryMUS.SetVolume(MusicFade) ;set vanilla music volume to value of musicFade
            EndWhile
            
            AudioCategoryMUS.SetVolume(0.0) ;mute vanilla music
            MyAudioCategoryMUS.SetVolume(MusicVolume) ;set volume of our custom music category to that of the user music audio setting
            
            
            If PlayerRef.IsInCombat() == false ;if the player is not in combat
                PlayCustomMusic() ;play a normal custom music track
            Else    ; ### add       
                PlayerRef.AddSpell(DetectCombatAbility, false) ;if player is in combat, this spell will play a combat music track.
            Endif    ; ### add

            RegisterForMenu("Journal Menu") ;Use OnMenuClose to detect if user changed the music volume setting.
        Endif
    EndEvent
 
 
     Event OnTriggerLeave(ObjectReference akActionRef)
        If akActionRef == PlayerRef
            debug.notification("Player left trigger box.")
            GoToState("Waiting") ;go back to waiting state that listens for when we enter the trigger box.
            
            PlayerRef.RemoveSpell(DetectCombatAbility)

            UnregisterForUpdate()
            FadeOutMusic(MyMusicID) ;current music playing fades out
            
            ;manually fade in vanilla music
            Float MusicFade = 0.0
            While MusicFade < MusicVolume        ; ### change
                MusicFade += 0.01 ;add 0.01 to MusicFade
                
  ;;;              If MusicFade > MusicVolume ;MusicFade cannot go above MusicVolume
  ;;;                  MusicFade = MusicVolume
  ;;;              Endif
                
                AudioCategoryMUS.SetVolume(MusicFade) ;Set vanilla music volume to value of MusicFade
            EndWhile
            
            AudioCategoryMUS.SetVolume(MusicVolume) ;Set vanilla music volume to what it was before entering trigger box.
            
            UnregisterForMenu("Journal Menu")
        EndIf
    EndEvent

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

@ReDragon. The spell is necessary whether you're in combat when entering the trigger box or not. The spell detects when you enter or leave combat while in the trigger box.

 

If you don't have the spell, combat music would continue to play even after combat ended.

Link to comment
Share on other sites

The 3 Debug notifications do show when entering the trigger, but I only get default vanilla combat music still.
Also, I removed the two sound markers you stated do not need to be in the cell/trigger.

 

Checked the Magic Effect, this is what I have:

MAGIC EFFECT

ID: DetectCombatAbility
Name: Detect Combat Ability
Effect Archtype: Value Modifier
Casting Type:: Constant Effect
Delivery: Self
Magic Skill: None
Minimum Skill Level: 0
Assoc. Item 1: None


TARGET CONDITIONS

Condition Item
Condition Function: IsInCombat
Parameters (Use Aliases): 1
Comparison: ==
Value: 1.0000
Run On: Player

Condition Item
Condition Function: GetInSameCell
Parameters (Use Aliases): Reference: 'defaultActivateSelfTRIG'
Comparison: ==
Value: 1.0000
Run On: Player


PAPYRUS SCRIPT
DetectCombatAbilityScript
Property: TriggerScript

Settings:
Cell: 00_IceTunnelUpper
Refernce: defaultActivateSelfTRIG

 

 

Scriptname DetectCombatAbilityScript extends ActiveMagicEffect
 ;courtesy of Dylbill on the Nexus Forums
 ;magic effect has the condition IsInCombat == 1 run on the player


MyCombatMus01 Property TriggerScript Auto ;script attached to trigger box.
;when filling in the CK, choose the cell the trigger box is in and the trigger box reference.


Event OnEffectStart(Actor akTarget, Actor akCaster) ;effect starts when player enters combat


    TriggerScript.PlayCustomCombatMusic()


EndEvent


Event OnEffectFinish(Actor akTarget, Actor akCaster) ;effect ends when player leaves combat  


    TriggerScript.PlayCustomMusic()


EndEvent

 

 

 

GAME AUDIO SETTINGS AFTER ENTERING TRIGGER BOX

(don't know why there are 3 Music)

MASTER: 100 %
EFFECTS: 100 %
FOOTSTEPS: 75 %
VOICE: 75 %
MUSIC: 100 %
MUSIC: 75 %
MUSIC: 50 %

Excuse all the friggin A's in this edit it's the phone app adding crap on edit.

Link to comment
Share on other sites

For your custom music category, make sure the Should Appear On Menu box is unchecked. Again, when you enter the triggerbox, music should be set to 0. If it's not, it's possible the AudioCategoryMUS wasn't filled in the script.

Link to comment
Share on other sites

Still the same after varifiying. I get the 3 Debug notifications while entering the trigger but then default vanilla combat music plays.

Also noted the 3 music entries in the audio settings menu have disappeared completely.



Removed / unchecked the box for "Should Appear on Menu" for all of the Categories used in this script, hope thats right? Also don't understand the gray pull-down menu below the Name and ID fields of the Sound Category window. I've put them all to NONE.




My Entries for the Properties of the MyCombatMus01 Script:


AudioCategoryMUS = AudioCategoryMUS

DetectCombatAbility = DetectCombatAbilitySpell

MyAudioCategoryMUS = AudioCategoryMUS_Taarakian

MyCustomCombatMusic :


  • MUS_Custom_HeavyMetal_TheMobRules
  • MUS_Custom_HeavyMetal_RadarRider
  • MUS_Custom_HeavyMetal_HeavyMetal
  • MUS_Custom_HeavyMetal_Prefabricator

MyCustomCombatMusicLengths:


  • 192.000000
  • 161.000000
  • 228.000000
  • 172.000000

MyCustomMusic:


  • MUS_Custom_DugeonIce01
  • MUS_Custom_DugeonIce02

MyCustomMusicLengths:


  • 135.000000
  • 118.000000

PlayerRef = PlayerRef



Question: For my Sound Descriptors, I currently only have two. One for MyCustomMusic with a list of two wave files and for MyCustomCombatMusic it has two files listed. Would it be better to separate the wav files into their own Descriptors or just keep is.


Also noted: Was I supposed to create/make a Sound Descriptor for AudioCategoryMUS as I see that is missing as well as any Sound Markers for it?

Link to comment
Share on other sites

@maxarturo, yes I've been reading what's going on. I'm disappointed Nexus is curating to collection (mod pack) makers rather than mod makers. They're essentially removing our right to control our own works, and seeing as so many of the author's with the bigger mods are pulling out, it's a sad time for the community. I haven't decided yet whether or not to Nuke my mods, but I probably won't be posting any new ones here. I'll still try to help modders when I can though.

 

@Laerithryn. Back to the topic at hand. I would use a different sound descriptor for each wav file, unless the wav files are the same length. If the 3 music settings disappeared, it might mean you unchecked the Should Appear on Menu box from AudioCategoryMUS. If you're still hearing vanilla music, it means AudioCategoryMUS wasn't muted in the script. I'm not sure why it's not working for you, cause as I said I tested it and it was working fine for me.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...