• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 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!
  • 🏆 HD Level Design Contest #1 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

Random variable/music etc.

Status
Not open for further replies.
Level 2
Joined
Aug 12, 2011
Messages
27
Hi!

I need help with triggers. I want to make a trigger which will play random sounds when player red types -Shuffle. Well... I tried and can't do that.

I found trigger set variable random number between[...] but it won't work while I test maps. It looks like this:
Event: Player red types -Shuffle
Condition: none
Actions: Set variable RANDOM to random number between 1-5

Then Im making another 5 triggers. Everyone is responsible for each sound.
Simple:
Event: variable RANDOM becomes 3
Actions: Play Music Theme 123

And it won't work ;/ I tried testing it during Map Test from editor and by manually launching map directly from warcraft 3. What am I doing wrong?
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set sounds[1] = some sound 1
      • Set sounds[2] = some sound 2
      • Set sounds[3] = some sound 3
      • Set sounds[4] = some sound 4
and in the trigger that detects the chat message:
  • Sound - Play sounds[(Random integer number between 1 and 4)]
 
Level 2
Joined
Aug 12, 2011
Messages
27
Hmm but I want to play MUSIC, not sound ;/ you know what I mean? I can't pick music to a variable. Only sounds.
 
Create a string variable, array'd; I called it "Options".
Then, in the Map Initialization, declare the values of each index. Music tracks have the common prefix of "Sound\\Music\\mp3Music\\". For the test, it can look like this:
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set udg_Options[1] = "Sound\\Music\\mp3Music\\BloodElfTheme.mp3"
      • Custom script: set udg_Options[2] = "Sound\\Music\\mp3Music\\Credits.mp3"
      • Custom script: set udg_Options[3] = "Sound\\Music\\mp3Music\\DarkVictory.mp3"
Then, I used an event to help the test on:
  • Test
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Sound - Stop music Immediately
      • Custom script: call PlayMusic (udg_Options[GetRandomInt(1,3)])
Tips:
• You don't need to create Music variables in the Sound Editor for this to work, since you play them with their filename, and not some default variable name.
• You will notice that everytime you test the map, the chances of each option are the same; you can fix this from File -> Preferences -> Test Map tab -> (Untick) Use Fixed Random Seed. If you load the map manually from Warcraft III, then you should not be concerned; this option affects a map loaded from WE.
 
Level 2
Joined
Aug 12, 2011
Messages
27
Pharaoh this one is dark magic for me :eek:

And mu music is imported. Does it have a difference?
 
I avoid that (although I prefer sounds myself, they are louder), especially in cinematics, because if a user minimizes Warcraft III, any sound will stop, while Music keeps on playing.

Edit: Here is a test map then.

Since you have imported your own music, check the path in the Import manager; the default should be "war3mapImported\\MusicFile.mp3". If you didn't rename it, then this is the file's name and it should look like:
  • Custom script: set udg_Options[1] = "war3mapImported\\MusicFile.mp3"
 

Attachments

  • TestMusic.w3x
    16.2 KB · Views: 89
Level 2
Joined
Aug 12, 2011
Messages
27
Thank you very much for a map ^^ I should understand it right now :)

Im saving the map and its all the time analysing the scripts u made... But I testes what u have sended to me. It works great ^^
 
Level 2
Joined
Aug 12, 2011
Messages
27
I made just like you and it is not working ;/

set udg_Options[3] = "war3mapImported\Music.mp3"

THe error occurs :/
 
Level 2
Joined
Aug 12, 2011
Messages
27
Well I decided to delete those mp3. I forgot about the weight of the map (it had... 72mb!). I deleted them and now i dont need to randomize any sound.

Sorry for all the trouble but thanks a lot for help. This might be usefull furher. Both of you guys are going to credits at my map. I should release it soon.

Again sorry :/
 
Status
Not open for further replies.
Top