package JukeBox import Players import ClosureTimers class Music int spellid string path real duration string name construct(int id, string path, real duration) this.spellid = id this.path = path this.name = path.substring(path.lastIndexOf("\\") + 1, path.lastIndexOf(".")) this.duration = duration function play() returns Music PlayThematicMusic(path) return this class JukeRequest player juker Music music construct(player p, Music music) this.juker = p this.music = music public JukeBox jukeBox constant musics = new LinkedList() public class JukeBox let requests = new LinkedList() let randomQueue = new LinkedList() var lastWasRequest = false Music currentMusic CallbackSingle cb = null function playNextMusic() StopMusic(false) // If request in queue, play it if requests.size() > 0 lastWasRequest = true let req = requests.pop() currentMusic = req.music.play() printTimed("Jukebox: Playing |cff84DE52" + currentMusic.name + "|r as requested by " + req.juker.getNameColored(), 10) destroy req else // Play next random music lastWasRequest = false if randomQueue.size() == 0 randomQueue.addAll(musics) randomQueue.shuffle() currentMusic = randomQueue.pop().play() printTimed("Jukebox: Playing |cff84DE52" + currentMusic.name + "|r", 10) if cb != null destroy cb cb = doAfter(currentMusic.duration + 1) -> cb = null playNextMusic() function checkSpell(int id) for music in musics if music.spellid == id let p = GetTriggerUnit().getOwner() for req in requests if req.juker == p printTimedToPlayer("You already have a track queued in the jukebox!", 10, p) return printTimed("The Track |cff84DE52" + music.name + "|r has been requested by " + p.getNameColored(), 10) requests.add(new JukeRequest(p, music)) if requests.size() == 1 and not lastWasRequest playNextMusic() return init doAfter(0.1) -> musics.add(new Music('A03T', "Sound\\Music\\mp3Music\\Doom.mp3", 66.125)) musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Human1.mp3", 273.032)) musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Human2.mp3", 236.983)) musics.add(new Music('A03L', "Sound\\Music\\mp3Music\\HumanX1.mp3", 284.646)) musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Orc1.mp3", 311.954)) musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Orc2.mp3", 313.496)) musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Orc3.mp3", 282.706)) musics.add(new Music('0000', "Sound\\Music\\mp3Music\\OrcX1.mp3", 324.953)) musics.add(new Music('A02R', "Sound\\Music\\mp3Music\\PursuitTheme.mp3", 86.537)) musics.add(new Music('A03P', "Sound\\Music\\mp3Music\\SadMystery.mp3", 84.515)) musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Tension.mp3", 19.540)) musics.add(new Music('A03U', "Sound\\Music\\mp3Music\\TragicConfrontation.mp3", 72.264)) musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Undead1.mp3", 303.507)) musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Undead2.mp3", 309.242)) musics.add(new Music('A03O', "Sound\\Music\\mp3Music\\PH1.mp3", 281.582)) musics.add(new Music('A03M', "Sound\\Music\\mp3Music\\ArthasTheme.mp3", 122.295)) musics.add(new Music('0000', "Sound\\Music\\mp3Music\\BloodElfTheme.mp3", 144.552)) musics.add(new Music('A03S', "Sound\\Music\\mp3Music\\War2IntroMusic.mp3", 81.136)) musics.add(new Music('A03Q', "Sound\\Music\\mp3Music\\Credits.mp3", 83.017)) musics.add(new Music('0000', "Sound\\Music\\mp3Music\\Comradeship.mp3", 124.927)) musics.add(new Music('A03N', "Sound\\Music\\mp3Music\\DarkAgents.mp3", 64.950)) musics.add(new Music('0000', "Sound\\Music\\mp3Music\\IllidansTheme.mp3", 108.006)) musics.add(new Music('0000', "Sound\\Music\\mp3Music\\LichKingTheme.mp3", 79.193)) musics.add(new Music('A03R', "Sound\\Music\\mp3Music\\NagaTheme.mp3", 87.1877)) jukeBox = new JukeBox()