• 🏆 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!

Load music to game from MPQ archive.

Status
Not open for further replies.
Level 11
Joined
Jun 2, 2013
Messages
613
I'm not 100% as I've never tried it, but for a custom map I would assume you go to your sound editor and browse the folders to where your music is located then"Use as Music" or "Use as Sound" like you would a normal sound.
Then in your map's triggers you would have it play that music.

Now, if you want those songs to play during the normal game, I would assume you would simply overwrite the songs that were originally in the MPQ with your song using the same path as the file you wish to replace. For example, if you wanted the Human Theme to be replaced in game, you would set the path of your custom song to that same path/filename to overwrite it.

Again, I've never tried this but logically that's how I think it would work.
Also, this may break the game so You probably want to keep a copy of your working MPQ.
 
Actually, it is very possible.
And even better: it doesn't even require an MPQ.

If players have local file support enabled, you can actually read and access any folder in the WC3 directory directly from within the game.

Just ship a folder with custom music for players to drop in the WC3 directory, then call the external music tracks via triggers.
You can find out if the folder exists or not by simply getting the length of the sound file. If it's 0, then the file doesn't exist and you can play a default music file instead.
 
I am pretty sure you need a variable from the sound editor to use it in GUI? I'd imagine it works in jass I suppose..

edit: Using PlaySound() might work since it takes a string.. I did only test in GUI before which use PlaySoundBJ()
In your case you might want to use this instead:
native PlayMusic takes string musicName returns nothing

You can check if the external music file exists by using this:
native GetSoundFileDuration takes string musicFileName returns integer

... so, in GUI, it would look like this

  • Set TempPlayer = Player 1
  • Set TempString = "MyExternalFolder\\MyMusic.mp3"
  • Custom Script: if GetLocalPlayer() == udg_TempPlayer then
  • Custom Script: if GetSoundFileDuration(udg_TempString) > 0 then
  • Custom Script: call PlayMusic(udg_TempString)
  • Custom Script: endif
  • Custom Script: endif
This will only play the file if the player actually has it. Otherwise, it will just continue playing whatever music was issued before that (or keep on playing the default WC3 music if you haven't set any).
 
Level 31
Joined
Aug 6, 2015
Messages
636
In your case you might want to use this instead:
native PlayMusic takes string musicName returns nothing

You can check if the external music file exists by using this:
native GetSoundFileDuration takes string musicFileName returns integer

... so, in GUI, it would look like this


  • Set TempPlayer = Player 1
  • Set TempString = "MyExternalFolder\\MyMusic.mp3"
  • Custom Script: if GetLocalPlayer() == udg_TempPlayer then
  • Custom Script: if GetSoundFileDuration(udg_TempString) > 0 then
  • Custom Script: call PlayMusic(udg_TempString)
  • Custom Script: endif
  • Custom Script: endif
This will only play the file if the player actually has it. Otherwise, it will just continue playing whatever music was issued before that (or keep on playing the default WC3 music if you haven't set any).

Thanks mate, problem solved :) i can just play the music from my archive with that :) thx alot
 
Last edited:
Level 31
Joined
Aug 6, 2015
Messages
636
Actually, it is very possible.
And even better: it doesn't even require an MPQ.

If players have local file support enabled, you can actually read and access any folder in the WC3 directory directly from within the game.

Just ship a folder with custom music for players to drop in the WC3 directory, then call the external music tracks via triggers.
You can find out if the folder exists or not by simply getting the length of the sound file. If it's 0, then the file doesn't exist and you can play a default music file instead.
i can't make all players do that, i want to put all my files into archive and load them into game, thats why i can't use that metod, but anyway ty.
 
Either way, even in an archive, you would have to have players download your archive and overwrite theirs just to play your map. If you want all players to have custom music in a custom map then your best bet is to import them through the import manager.
No you don't need to overwrite anything.

The players need the external folder, yes, but they don't need to overwrite any game files. It's completely external. I'm using this method for an expansion pack for my map that enables custom music and voice acted quests. It's definitely working.
The requirement is that the players have local files enabled and have the folder in the correct path. However, if they don't, the game and map will still work fine, as the script I posted above will only load the files if they actually exist. If not, it will play the default music.

i can't make all players do that, i want to put all my files into archive and load them into game, thats why i can't use that metod, but anyway ty.
Huh? Of course you can make all players do that. You just need to ship the folder together with your map. Obviously, every player that wants to hear the custom music needs the folder. Otherwise they will just hear the default music.
 
Status
Not open for further replies.
Top