I'm trying to have a music track play when encountering the end boss of a dungeon using the below script:
Scriptname CJ03MalkiferCombatMusicScript extends Actor
MusicType property CJ03MusBossMalkifer Auto
Event OnCombatStateChanged(Actor akTarget, int aeCombatState)
if (akTarget == Game.GetPlayer())
if (aeCombatState != 0)
CJ03MusBossMalkifer.Add()
endif
endif
endEvent
Event OnDying (Actor akkiller)
CJ03MusBossMalkifer.Remove()
endEvent
The music reliably plays when combat starts (yay!) but often persists when the boss dies (boo!), which is a huge problem, because with the boss dead the music no longer has a trigger to ever stop. I'm a complete novice at scripting who basically can only repurpose existing scripts. Any insights on ways to make this script more reliable? Any help is appreciated. Thanks!