• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] Simple Sound Trigger

Status
Not open for further replies.
Hello, I'd like to ask a simple question..

How do I make it in a trigger such that:

When a unit attacks 1 random sound of 3 sounds is played.

Aka: I have 3 sound files setted up as Sound Variables

When a unit attacks I want one random sound of THESE 3 SOUNDS to be played and not a specific one.

How do I arrange that in a trigger?
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
In map ini trigger you make a list of sounds (going by what you wrote, I guess you have one already)
  • Map Ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set AttSound[1] = AxeMissile1 <gen>
      • Set AttSound[2] = AxeMissile2 <gen>
      • Set AttSound[3] = HeroShadowhunterMissileHit1 <gen>
This plays random sound from your list:
  • Sound
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Sound - Play AttSound[(Random integer number between 1 and 3)] at 100.00% volume, attached to (Attacking unit)
The function used in the AttSound's index is Math - Random number.

The problem: WCIII allows you to play only 1 sound via trigger at a time. So when multiple units attack, only 1 sound will be played (for the first unit) - e.g. only the first unit's swing will play sound.
 
Level 4
Joined
May 1, 2013
Messages
68
Alternative

I have an alternative, to how this could be done, which may be easier plus you only need one trigger and you dont need to create many variables.

  • Sound
    • Events
      • Unit - A unit Is attacked
      • Conditions
      • Actions
        • Set RandInt = (Random integer number between 1 and 3)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • RandInt Equal to 1
          • Then - Actions
            • Sound - Play MySound1
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • RandInt Equal to 2
                • Then - Actions
                  • Sound - Play MySound2
                  • Else - Actions
                    • Sound - Play MySound3
 
Last edited:
Status
Not open for further replies.
Top