dylbill Posted June 26, 2021 Share Posted June 26, 2021 Hmmm, I would maybe try the triggerbox method again then. ReDragon had a good idea to use states to cut down on events firing: MusicType Property MyCombatMusic Auto MusicType Property MUSCombat Auto ;vanilla combat music Form Property CurrentCombatMusicType Auto Hidden DefaultObjectManager Property kDefObjMan Auto Hidden Event OnInit() kDefObjMan = Game.GetFormFromFile(0x00000031, "Skyrim.esm") as DefaultObjectManager ;get DefaultObjectManager form from skyrim.esm GoToState("Waiting") Debug.Notification("Combat Music Trigger Init") EndEvent State Waiting Event OnTriggerEnter(ObjectReference akActionRef) ;Debug.Notification("Trigger Enter") If akActionRef == Game.GetPlayer() GoToState("InTriggerBox") Debug.Notification("Setting custom combat music") CurrentCombatMusicType = kDefObjMan.GetForm("BTMS") ;Save current Battle Music kDefObjMan.Setform("BTMS", MyCombatMusic) ;set battle music to MyCombatMusic Endif EndEvent EndState State InTriggerBox Event OnTriggerLeave(ObjectReference akActionRef) ;Debug.Notification("Trigger Leave") If akActionRef == Game.GetPlayer() GoToState("Waiting") Debug.Notification("Setting combat music back to vanilla.") kDefObjMan.SetForm("BTMS", CurrentCombatMusicType) ;set battle music back to what it was before Endif EndEvent EndStateMake sure you're getting all of the notifications, including the init one. Link to comment Share on other sites More sharing options...
ReDragon2013 Posted June 26, 2021 Share Posted June 26, 2021 (edited) maxarturo wrote: "Why don't you just use "Add()" / "Remove()", since you can only play 1 music track at any given point, adding a MUS will remove any other that its playing at that time."There exists a vanilla playeralias script calledRemoveSilenceMUS Scriptname RemoveSilenceMUS Extends ReferenceAlias musictype Property MUSTavernSilence Auto Event OnLocationChange(Location akOldLoc, Location akNewLoc) MUSTavernSilence.Remove() EndEvent RemoveSilenceMUS is part of vanilla "Bardsongs" quest and always running during gameplay. In case the mod "Falskaar" is running the alias script from above is running twice at the same time, terrible.This script may also responsible for game freezing, when using FastTravel() from Solstheim back to Skyrim (usually Windhelm). Edited June 26, 2021 by ReDragon2013 Link to comment Share on other sites More sharing options...
maxarturo Posted June 26, 2021 Share Posted June 26, 2021 maxarturo wrote: "Why don't you just use "Add()" / "Remove()", since you can only play 1 music track at any given point, adding a MUS will remove any other that its playing at that time." There exists a vanilla playeralias script calledRemoveSilenceMUS Scriptname RemoveSilenceMUS Extends ReferenceAlias musictype Property MUSTavernSilence Auto Event OnLocationChange(Location akOldLoc, Location akNewLoc) MUSTavernSilence.Remove() EndEvent RemoveSilenceMUS is part of vanilla "Bardsongs" quest and always running during gameplay. In case the mod "Falskaar" is running the alias script from above is running twice at the same time, terrible.This script may also responsible for game freezing, when using FastTravel() from Solstheim back to Skyrim (usually Windhelm). Well... that would explain a lot. Also, i've play once that mod ages ago and i do remember having problems with it. It seems my friend that you have gone through every single vanilla script, from time to times you show some vanilla scripts that i didn't even knew they existed and what they do... i really wish i had more free time... Link to comment Share on other sites More sharing options...
Laerithryn Posted June 27, 2021 Author Share Posted June 27, 2021 (edited) @Dylbill, ok I tried your last script; the one using states and just like before the bug is back. MUSCombat doesn't fade when combat is over and continues to play, even when exiting the game back to the Start Menu. May have been due to a dirty save. Now with all that being said and done, for s&g I tried it again same way and it worked flawlessly! Don't know what gives or whats going on. but sucessive attempts were very similar where it appears to be working most of the time. It may hiccup occasionally after dying and the game reloading from your last point, but not always. All further testing will be done using a fresh start from the desktop with a new character each time to avoid corrupted or dirty saves, then porting into my test cell via coc, or in-game world space. ---------------------Note the above tests were done in my test cell. But when used in other cells it doesn't work for some reason. No matter what cell I'm in "Tamriel world space" or any interior cell, I do get the debug notifications for "Combat Music Trigger Init", and then when in the actual cell with the trigger box I finally see the "Trigger Enter" and "setting custom combat music" notifications. But unfortunately I never hear the Combat music at all. Also noted that this script Trigger Enter and Trigger Leave notification trip all in game triggers, really weird. Edited June 27, 2021 by Laerithryn Link to comment Share on other sites More sharing options...
dylbill Posted June 27, 2021 Share Posted June 27, 2021 Hmmm, because that's a pretty bad bug, I would maybe try maxaturo's idea of using Add() and Remove(). You have to detect when the player enters combat, and to do this I would make a new spell ability that has the condition IsInCombat == 1 and add it to the player when they enter the cell. This is because the event OnCombatStateChanged doesn't work for the player. triggerbox script: Actor Property PlayerRef Auto Spell Property DetectCombatAbility Auto State Waiting Event OnTriggerEnter(ObjectReference akActionRef) ;Debug.Notification("Trigger Enter") If akActionRef == PlayerRef GoToState("InTriggerBox") PlayerRef.AddSpell(DetectCombatAbility, false) ;add spell to player silently. ;DetectCombatAbility's effect start when or if player enters combat. Debug.Notification("Setting custom combat music.") Endif EndEvent EndState State InTriggerBox Event OnTriggerLeave(ObjectReference akActionRef) ;Debug.Notification("Trigger Leave") If akActionRef == PlayerRef GoToState("Waiting") utility.wait(0.1) ;wait a small amount in case player is leaving cell. Wait until new cell is loaded. PlayerRef.RemoveSpell(DetectCombatAbility) Debug.Notification("Setting combat music back to vanilla.") Endif EndEvent EndStateThe script that goes on the DetectCombatAbility's magic effect. Have it extend ActiveMagicEffect: magic effect has condition IsInCombat == 1 run on the player. MusicType Property MyCombatMusic Auto Event OnEffectStart(Actor akTarget, Actor akCaster) ;effect start when player enters combat MyCombatMusic.Add() EndEvent Event OnEffectFinish(Actor akTarget, Actor akCaster) MyCombatMusic.Remove() EndEventNote that the wiki: https://www.creationkit.com/index.php?title=Add_-_MusicType says that using Add can make the musictype baked into the save. To prevent this, add the conditions: IsInCombat == 1 ANDGetInSameCell <object reference in your cell> == 1 to each of your music tracks in your custom musictype. Have them run on the Player. Also, make sure your custom musictype has a higher priority than the vanilla combat musictype. Link to comment Share on other sites More sharing options...
maxarturo Posted June 27, 2021 Share Posted June 27, 2021 The papyrus music functions are so buggy, mainly because there wasn't further development beyond what the game needed at that point. The "Infinite Playing Music" it's the most common, and the most serious that you can't see right away is the "No More Playing Music", complete music silence which needs a new game to get rid of it, because by the time you realize the issue... it's way too late... The most secure way to handle the change of music it's to have it on a 'scene sequence', Add the MUS on the start of your scene, and Remove it at the end. For random combat encounters you need to use the SM in combination with a 'Dummy Quest' monitoring the player. The "Ability Spell" approach can also work, but there is always the unfixable "Conditional Ability Bug", to be more precise: The infamous "Active effect time imprecision bug". https://www.creationkit.com/index.php?title=Active_effect_time_imprecision_bug And all of this with its corresponding "Fail Safes" to avoid and cut off the infinitive playing music, like using "OnPlayerLoadGame()".... etc. Accordingly always as to how your scene is set up the use of the corresponding 'Fail Safe' functions should be. * The infinitive music playing bug can occur under different conditions with the most common been the 'save' and 'load' during the combat scene. Have all a nice cool week. Link to comment Share on other sites More sharing options...
Laerithryn Posted June 27, 2021 Author Share Posted June 27, 2021 (edited) @Dylbill, the following reply is not focused on your last post, but instead toward the trigger box script from earlier as it was the only one I could get repeated successful results from, until finding it wouldn't work anywhere else including the cells in my own mod. Just so your clear on what script it's this one. Scriptname MyCombatMus01 extends ObjectReference ;courtesy of Dylbill on Nexux Forums MusicType Property MyCombatMusic Auto MusicType Property MUSCombat Auto ;vanilla combat music Form Property CurrentCombatMusicType Auto Hidden DefaultObjectManager Property kDefObjMan Auto Hidden Event OnInit() kDefObjMan = Game.GetFormFromFile(0x00000031, "Skyrim.esm") as DefaultObjectManager ;get DefaultObjectManager form from skyrim.esm GoToState("Waiting") Debug.Notification("Combat Music Trigger Init") EndEvent State Waiting Event OnTriggerEnter(ObjectReference akActionRef) ;Debug.Notification("Trigger Enter") If akActionRef == Game.GetPlayer() GoToState("InTriggerBox") Debug.Notification("Setting custom combat music") CurrentCombatMusicType = kDefObjMan.GetForm("BTMS") ;Save current Battle Music kDefObjMan.Setform("BTMS", MyCombatMusic) ;set battle music to MyCombatMusic Endif EndEvent EndState State InTriggerBox Event OnTriggerLeave(ObjectReference akActionRef) ;Debug.Notification("Trigger Leave") If akActionRef == Game.GetPlayer() GoToState("Waiting") Debug.Notification("Setting combat music back to vanilla.") kDefObjMan.SetForm("BTMS", CurrentCombatMusicType) ;set battle music back to what it was before Endif EndEvent EndState Ok through some exhaustive testing all morning I found the conflict causing the source of the bug it was exhibiting everywhere except for my test cell. I never set any audio at all for my test cell, like Default Acoustic Space, and Music Type. Through more testing I found that Default Acoustic Space has no effect what so ever, but any Music Type set for a cell is the source of the conflict for this script. As soon as I set Music Type of a cell to match my test cell (which equals the "Default" setting) it plays nice and loud. But if the cell uses anything else otherwise, it doesn't work. I don't know what can be done about this, if there's a way to change or alter a cell's Music Type setting temporarily then return it to vanilla? Edited June 27, 2021 by Laerithryn Link to comment Share on other sites More sharing options...
Laerithryn Posted June 27, 2021 Author Share Posted June 27, 2021 (edited) Deleted accidental duplicate post Edited June 27, 2021 by Laerithryn Link to comment Share on other sites More sharing options...
dylbill Posted June 27, 2021 Share Posted June 27, 2021 Hmm, that's interesting. It doesn't look like you can set the musictype for a cell with script. But, you could leave your cell set to default music type, then change the default object music type in the same way, and it might work. Like so: MusicType Property MyCombatMusic Auto MusicType Property MyDefaultMusic Auto MusicType Property MUSCombat Auto ;vanilla combat music Form Property CurrentCombatMusicType Auto Hidden Form Property CurrentDefaultMusicType Auto Hidden DefaultObjectManager Property kDefObjMan Auto Hidden Event OnInit() kDefObjMan = Game.GetFormFromFile(0x00000031, "Skyrim.esm") as DefaultObjectManager ;get DefaultObjectManager form from skyrim.esm GoToState("Waiting") Debug.Notification("Combat Music Trigger Init") EndEvent State Waiting Event OnTriggerEnter(ObjectReference akActionRef) ;Debug.Notification("Trigger Enter") If akActionRef == Game.GetPlayer() CurrentCombatMusicType = kDefObjMan.GetForm("BTMS") ;Save current Battle Music CurrentDefaultMusicType = kDefObjMan.GetForm("DFMS") ;Save current Battle Music GoToState("InTriggerBox") Debug.Notification("Setting custom combat music") kDefObjMan.Setform("BTMS", MyCombatMusic) ;set battle music to MyCombatMusic kDefObjMan.Setform("DFMS", MyDefaultMusic) ;set default music to MyDefaultMusic Endif EndEvent EndState State InTriggerBox Event OnTriggerLeave(ObjectReference akActionRef) ;Debug.Notification("Trigger Leave") If akActionRef == Game.GetPlayer() GoToState("Waiting") Debug.Notification("Setting combat music back to vanilla.") kDefObjMan.SetForm("BTMS", CurrentCombatMusicType) ;set battle music back to what it was before kDefObjMan.SetForm("DFMS", CurrentDefaultMusicType) ;set default music back to what it was before Endif EndEvent EndState Link to comment Share on other sites More sharing options...
Laerithryn Posted June 27, 2021 Author Share Posted June 27, 2021 (edited) Ok, tried that. I set one of my mod's cells to Music Type of Default, then set the property to MUSDungeonIce what I normally had set for the cell. In-game practice run, MyCombatMus plays just fine, but the cell is dead of any Music Type at all, before entering the trigger or leaving it, no music plays. Edited June 27, 2021 by Laerithryn Link to comment Share on other sites More sharing options...
Recommended Posts