• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Need help with timers

Status
Not open for further replies.
Level 6
Joined
Jun 4, 2017
Messages
172
Hi guys, I have a problem with timers. My problem is that timers stop if the game is paused. This is a big problem because I use a trigger that randomize musics and starts a timer with the length of the music but, if someone pause the game the music will continue until its end but the timer will not continue so there will be a big moment of no music at all.

My trigger is this:

Events
Music expires

Conditions

Actions
If(all conditions are true) then do(Then actions) else do (else actions)
Conditions
(Random integer number between 1 and 2) equal to 1
then actions
Play mymusic1 theme
Start Music as one time timer that will expire in 166.00 seconds
else actions
Play mymusic2 theme
Start Music as one time timer that will expire in 198.00 seconds
 
Last edited by a moderator:
Level 6
Joined
Jun 4, 2017
Messages
172
You could try out a "wait" and after the wait "run this trigger".
I tested it and it didn't work. If you pause the game wait actions will stop too. I also tested wait game-time but it's the same thing.

Other option that comes offhand: replace default MusicFiles (SoundEditor) with your imported ones.
I can't do this because I have some musics for battle and some musics for calm moments so I needs to use triggers
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
This is one of the few times you should be using TriggerSleepAction (GUI Action: Wait) as that does not pause when the game pauses and approximately syncs with real time.

That said you might want to try hacking around with the in-built music system and letting that manage the tracks. That way music is not forced to be synchronized between all clients.
 
According to: Vexorian Own music list - Wc3C.net
Yes, but there is little documentation about the subject, and GUI is unable to do it.

You have to use this native:
minus.gif
common.j:
// Music Interface. Note that if music is disabled, these calls do nothing
native SetMapMusic takes string musicName, boolean random, integer index returns nothing
native ClearMapMusic takes nothing returns nothing




Well the thing is that string musicName contains the path of the music file or "music" for default or plenty of paths separated by ; ("path1;path2;path3")

You can use a custom script line to call it, For example :

minus.gif
Custom Script:
call SetMapMusic("music\\file1.mp3;music\\file2.mp3",false,0)

__________________
you could use use call setMapMusic(MusicFilePaths in the Map seperated with ";",true,0)

The weakness of setMapMusic is it starts after the current Music ends.

If you want to use Musiclists easy access would be presaving them as Strings and then call setMapMusic with the approached String.


  • start
    • Ereignisse
      • Map initialization
    • Bedingungen
    • Aktionen
      • Set Celtic = AmbientCeltic.mp3;AmbientCeltic2.mp3;AmbientCeltic3.mp3
      • Set Warlords = Music\2Ambient1.mp3;Music\2Ambient2.mp3;Music\2Ambient3.mp3
      • Set Win7 = Maid with the Flaxen Hair.mp3;Sleep Away.mp3
      • Set Victory = Sound\Music\mp3Music\NightElfVictory.mp3;Sound\Music\mp3Music\HumanVictory.mp3;Sound\Music\mp3Music\OrcVictory.mp3;Sound\Music\mp3Music\UndeadVictory.mp3
      • Trigger - Run Change Music <gen> (ignoring conditions)
  • Change Music
    • Ereignisse
      • Player - Spieler 1 (Rot) skips a cinematic sequence
    • Bedingungen
    • Aktionen
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Execution count of (This trigger)) mod 3) Gleich 0
        • Then - Actions
          • Spiel - Display to (All players) for 5.00 seconds the text: Celtic
          • Set Liste = Celtic
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Execution count of (This trigger)) mod 3) Gleich 1
            • Then - Actions
              • Spiel - Display to (All players) for 5.00 seconds the text: Warlods
              • Set Liste = Warlords
            • Else - Actions
              • Spiel - Display to (All players) for 5.00 seconds the text: Win7
              • Set Liste = Win7
      • Trigger - Run SetPlayList <gen> (ignoring conditions)
  • SetPlayList
    • Ereignisse
    • Bedingungen
    • Aktionen
      • -------- Don't know if this one is needed --------
      • Sound - Clear the music list
      • -------- Start Playing List, starts with Random Music --------
      • -------- after current Song Ends --------
      • Custom script: call SetMapMusic(udg_Liste, true, 0)

Edit: I had a better Idea of this Version "SetPlayList" COMBINING it with Play/Stop Music which would change music instantly. Its current bad point is, it could play one song twice in a row.

  • SetPlayList
    • Ereignisse
    • Bedingungen
    • Aktionen
      • Set Counter = 0
      • Set Songs[0] = <Leerer String>
      • -------- Find all Songs in this List and save them splitted in an new Array --------
      • For each (Integer A) from 1 to (Length of Liste), do (Actions)
        • Schleifen - Aktionen
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Substring(Liste, (Integer A), (Integer A))) Ungleich ;
            • Then - Actions
              • Set Songs[Counter] = (Songs[Counter] + (Substring(Liste, (Integer A), (Integer A))))
            • Else - Actions
              • Set Counter = (Counter + 1)
              • Set Songs[Counter] = <Leerer String>
      • -------- Shows Found Songs --------
      • For each (Integer A) from 0 to Counter, do (Actions)
        • Schleifen - Aktionen
          • Game - Display to (All players) for 30.00 seconds the text: Songs[(Integer A)]
      • -------- Don't know if this one is needed --------
      • Sound - Clear the music list
      • Sound - Stop music Sofort
      • Custom script: call PlayMusic( udg_Songs[GetRandomInt(0,udg_Counter)] )
      • Custom script: call SetMapMusic(udg_Liste, true, 0)

Does not work if you do it that way the music played directly will loop endlessly.
 
Last edited:
Level 6
Joined
Jun 4, 2017
Messages
172
This is one of the few times you should be using TriggerSleepAction (GUI Action: Wait) as that does not pause when the game pauses and approximately syncs with real time.
I already tested it and it didn't work because it seems that wait actions are paused too when game is paused.

That said you might want to try hacking around with the in-built music system and letting that manage the tracks. That way music is not forced to be synchronized between all clients.
I can't do these things because I don't know jass or other programming languages. The only programming languages which I know is C script.
According to: Vexorian Own music list - Wc3C.net

you could use use call setMapMusic(MusicFilePaths in the Map seperated with ";",true,0)

The weakness of setMapMusic is it starts after the current Music ends.

If you want to use Musiclists easy access would be presaving them as Strings and then call setMapMusic with the approached String.


  • start
    • Ereignisse
      • Map initialization
    • Bedingungen
    • Aktionen
      • Set Celtic = AmbientCeltic.mp3;AmbientCeltic2.mp3;AmbientCeltic3.mp3
      • Set Warlords = Music\2Ambient1.mp3;Music\2Ambient2.mp3;Music\2Ambient3.mp3
      • Set Win7 = Maid with the Flaxen Hair.mp3;Sleep Away.mp3
      • Set Victory = Sound\Music\mp3Music\NightElfVictory.mp3;Sound\Music\mp3Music\HumanVictory.mp3;Sound\Music\mp3Music\OrcVictory.mp3;Sound\Music\mp3Music\UndeadVictory.mp3
      • Trigger - Run Change Music <gen> (ignoring conditions)
  • Change Music
    • Ereignisse
      • Player - Spieler 1 (Rot) skips a cinematic sequence
    • Bedingungen
    • Aktionen
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Execution count of (This trigger)) mod 3) Gleich 0
        • Then - Actions
          • Spiel - Display to (All players) for 5.00 seconds the text: Celtic
          • Set Liste = Celtic
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Execution count of (This trigger)) mod 3) Gleich 1
            • Then - Actions
              • Spiel - Display to (All players) for 5.00 seconds the text: Warlods
              • Set Liste = Warlords
            • Else - Actions
              • Spiel - Display to (All players) for 5.00 seconds the text: Win7
              • Set Liste = Win7
      • Trigger - Run SetPlayList <gen> (ignoring conditions)
  • SetPlayList
    • Ereignisse
    • Bedingungen
    • Aktionen
      • -------- Don't know if this one is needed --------
      • Sound - Clear the music list
      • -------- Start Playing List, starts with Random Music --------
      • -------- after current Song Ends --------
      • Custom script: call SetMapMusic(udg_Liste, true, 0)
Edit: I had a better Idea of this Version "SetPlayList" COMBINING it with Play/Stop Music which would change music instantly. Its current bad point is, it could play one song twice in a row.
  • SetPlayList
    • Ereignisse
    • Bedingungen
    • Aktionen
      • Set Counter = 0
      • Set Songs[0] = <Leerer String>
      • -------- Find all Songs in this List and save them splitted in an new Array --------
      • For each (Integer A) from 1 to (Length of Liste), do (Actions)
        • Schleifen - Aktionen
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Substring(Liste, (Integer A), (Integer A))) Ungleich ;
            • Then - Actions
              • Set Songs[Counter] = (Songs[Counter] + (Substring(Liste, (Integer A), (Integer A))))
            • Else - Actions
              • Set Counter = (Counter + 1)
              • Set Songs[Counter] = <Leerer String>
      • -------- Shows Found Songs --------
      • For each (Integer A) from 0 to Counter, do (Actions)
        • Schleifen - Aktionen
          • Game - Display to (All players) for 30.00 seconds the text: Songs[(Integer A)]
      • -------- Don't know if this one is needed --------
      • Sound - Clear the music list
      • Sound - Stop music Sofort
      • Custom script: call PlayMusic( udg_Songs[GetRandomInt(0,udg_Counter)] )
      • Custom script: call SetMapMusic(udg_Liste, true, 0)
It doesn't work for me, idk why. However if it changes music only when a music is finished I don't think it's good for what I need because I need the music to stop immediately when there is a fight and should start the battle music list.
My trigger already works fine but the problem is only the timer.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
I already tested it and it didn't work because it seems that wait actions are paused too when game is paused.
Wait Game Time will be paused due to it internally using a timer but normal wait (TriggerSleepAction) should not. At least this is the case for multiplayer during the pause from waiting for player dialogs.

There are a lot of music natives which sound like they might be used to perform what you want. However before I can recommend any I will have to test them, which I will do later.
 
Blizzard is trollig:
PlayMusic(String) is the function you are looking for.
It Plays the Musicfiles insert and Repeats them.

If you use PlayMusic with a String containing Multiple Musics it will play all, but between each is a short break ca 20 to 40 seconds not so sure.
This Code will Play War2IntroMusic.mp3, Doom.mp3, TragicConfrontation.mp3, LichKingTheme.mp3 and repeats them if finished.
  • Sound - Clear the music list
  • Sound - Stop music Sofort
  • Set PlayLists[5] = Sound\Music\mp3Music\War2IntroMusic.mp3;Sound\Music\mp3Music\Doom.mp3;Sound\Music\mp3Music\TragicConfrontation.mp3;Sound\Music\mp3Music\LichKingTheme.mp3
  • Custom script: call PlayMusic( udg_PlayLists[5] )
Edit: Still trying to find out what SetMapMusik does.
Edit2: Hmm, there is a problem if one of the Musicfiles is a ".wav", with only ".mp3" it loops fine for me.
Warcraft 3: The MP3Player :).
3 Loops of the the Playlist i posted before were no Problem, with the mentioned timeouts between Songs.​
 
Last edited:
Level 6
Joined
Jun 4, 2017
Messages
172
Blizzard is trollig:
PlayMusic(String) is the function you are looking for.
It Plays the Musicfiles insert and Repeats them.

If you use PlayMusic with a String containing Multiple Musics it will play all, but between each is a short break ca 20 to 40 seconds not so sure.
This Code will Play War2IntroMusic.mp3, Doom.mp3, TragicConfrontation.mp3, LichKingTheme.mp3 and repeats them if finished.
  • Sound - Clear the music list
  • Sound - Stop music Sofort
  • Set PlayLists[5] = Sound\Music\mp3Music\War2IntroMusic.mp3;Sound\Music\mp3Music\Doom.mp3;Sound\Music\mp3Music\TragicConfrontation.mp3;Sound\Music\mp3Music\LichKingTheme.mp3
  • Custom script: call PlayMusic( udg_PlayLists[5] )
Edit: Still trying to find out what SetMapMusik does.
It works even if it hasn't timers or waits! Thank you, that is going to resolve the pause problem. I don't like too much that break but, I think we can't have all we want XD
I think I can consider this topic solved, thanks and +rep to you two guys :)
 
I have to say that for anyone might read and use that concept, this concept I recently rediscovered based on this Post from Vexorian Own music list - Wc3C.net.
After further test:

There are some Mp3-Files which do not loop and can not be part of a musicPlayList of Warcraft3.
An Example is the in Win7 included example MusicFiles. They do play only once and if used as multi argument only one of all is palyed and that one only one time.
 
Status
Not open for further replies.
Top