Music Intro and then Music Repeat

Status
Not open for further replies.
Level 1
Joined
Jun 21, 2009
Messages
282
Alright so i'm needing atleast 2-3 triggers with this:

Music Intro starts at the beginning of the game which lasts 90 seconds, and then after thats done the main music for the game starts which lasts 245 seconds, and I need it so when the main music is done it'll keep repeating, i've not done this before with 2 music themes so if someone would show me then I can take it from there.

Thanks!
 
For the first one, play it at map init or at map time 0.00
For the 2nd one, create a loop with a (245-90) seconds wait at the end (before the endloop), then after the first music is done, call this function...

JASS:
scope Music initializer init
/*
   note: I'm not sure if this works fine or if its leakless, this is just a rough idea on how to do it...
*/

    private function SecondMusic takes nothing returns nothing
        local sound blahblah =
        loop
             call PlaySound(blahblah)
             call TriggerSleepAction(245-90)
        endloop
    endfunction

    private function FirstMusic takes nothing returns nothing
        local sound blahblah = 
        call DestroyTimer(GetExpiredTimer())
        call PlaySound(blahblah)
        call KillSoundWhenDone(blahblah)
        call TriggerSleepAction(90.00)
        call SecondMusic()
    endfunction

    private function init takes nothing returns nothing
         call TimerStart(CreateTimer(), 0.00, false, function FirstMusic)
    endfunction

endscope
 
JASS:
//Note: Plays 1 sound first and then loops a second sound when the first finishes.
//Note: This is untested. I'm not sure if the first PlayThematicMusic() will work on initialization.

scope gameMusic initializer i
    globals
        private constant string OPENINGTHEME="Sound\\Music\\mp3Music\\HeroicVictory.mp3" //Replace this with your custom opening track
        private constant string LOOPINGTHEME="Sound\\Music\\mp3Music\\OrcVictory.mp3" //Replace this with your looping audio track
        private constant real   OPENINGTIME= 90. //Set this to the length of your opening audio track
        private constant real   LOOPTIMER=   245. //Set this to the length of your looping audio track
        private timer time=CreateTimer()
    endglobals
    
    private function p takes nothing returns nothing
        call EndThematicMusic()
        call PlayThematicMusic(LOOPINGTHEME)
    endfunction
    
    private function c takes nothing returns boolean
        call EndThematicMusic()
        call PlayThematicMusic(LOOPINGTHEME)
        call TimerStart(time,LOOPTIMER,true,function p)
        return false
    endfunction
    
    private function i takes nothing returns nothing
        local trigger t=CreateTrigger()
        call PlayThematicMusic(OPENINGTHEME)
        call TriggerRegisterTimerEvent(t,OPENINGTIME,false)
        call TriggerAddCondition(t,Condition(function c))
    endfunction
endscope
 
first why use a trigger with a timer event plus a condition if you can directly call function c with a TimerStart action on init...

JASS:
local trigger t=CreateTrigger()
call PlayThematicMusic(OPENINGTHEME)
call TriggerRegisterTimerEvent(t,OPENINGTIME,false)
call TriggerAddCondition(t,Condition(function c))

/*
   could be transformed into just this
*/

call PlayThematicMusic(OPENINGTHEME)
call TimerStart(CreateTimer(), OPENINGTIME, false, function c)
 
Level 20
Joined
Oct 21, 2006
Messages
3,230
  • Intro
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Sound - Play INTRO
      • Wait (Length of INTRO) seconds
      • Trigger - Run Loop <gen> (checking conditions)
  • Loop
    • Events
    • Conditions
    • Actions
      • Sound - Play MUSIC
      • Wait (Length of MUSIC) seconds
      • Trigger - Run Loop <gen> (checking conditions)
:|
 
  • Intro
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Sound - Play INTRO
      • Wait (Length of INTRO) seconds
      • Trigger - Run Loop <gen> (checking conditions)
  • Loop
    • Events
    • Conditions
    • Actions
      • Sound - Play MUSIC
      • Wait (Length of MUSIC) seconds
      • Trigger - Run Loop <gen> (checking conditions)
:|

As has been corrected multiple times in this thread already, don't use TSA
 
This is the most officiant way(I think)
Trigger:
  • Starting Music
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Sound - Play Music
      • Wait 90.00 game-time seconds
      • Trigger - Add to Music <gen> the event (Time - Every 245.00 seconds of game time)
  • Looping Music
    • Events
    • Conditions
    • Actions
      • Sound - Play Music
I think that should work:/ and why no TSA?
 
This is the most officiant way(I think)
Trigger:
  • Starting Music
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Sound - Play Music
      • Wait 90.00 game-time seconds
      • Trigger - Add to Music <gen> the event (Time - Every 245.00 seconds of game time)
  • Looping Music
    • Events
    • Conditions
    • Actions
      • Sound - Play Music
I think that should work:/ and why no TSA?

You're three days late.
That is the not the most efficient way.
That leaks (makes a new event about every 245 seconds)
That won't play at the right timing.
That won't play a second sound.
That uses TSA.

No TSA because for longer waits it is less accurate. The music needs to appear looping, not looping with a plus or minus 3 to 5 second delay between each part.
 
TSA is fine for long periods. The margin of error is not that much for long durations, only about 0.1 seconds on average. It is fine to use in this case.

Really? I could never seem to get warcraft to ever work accurately with sound files, precision seems near impossible in wc3 when it comes to sound.
 
Status
Not open for further replies.
Top