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

How do I fix these sound triggers?

Status
Not open for further replies.
Level 9
Joined
Feb 16, 2011
Messages
595
The Idea behind it is to make a Voiceless unit emit a sound when issued an order.


  • Attack Sounds for Peasant
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Equal to Peasant
          • (Issued order) Equal to (Order(Attack))
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AttackSound Equal to 1.00
        • Then - Actions
          • Sound - Play PeasantYesAttack1 <gen> at 100.00% volume, located at (Position of (Ordered unit)) with Z offset 0.00
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AttackSound Equal to 2.00
        • Then - Actions
          • Sound - Play PeasantYesAttack2 <gen> at 100.00% volume, located at (Position of (Ordered unit)) with Z offset 0.00
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AttackSound Equal to 3.00
        • Then - Actions
          • Sound - Play PeasantYesAttack3 <gen> at 100.00% volume, located at (Position of (Ordered unit)) with Z offset 0.00
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AttackSound Equal to 4.00
        • Then - Actions
          • Sound - Play PeasantYesAttack4 <gen> at 100.00% volume, located at (Position of (Ordered unit)) with Z offset 0.00
        • Else - Actions
  • Attack Sound Randomizer
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Set AttackSound = (Random real number between 1.00 and 4.00)
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
Save sounds into sound array, I will call it sound_arr, when unit is issued an order, pick random number between 1 and 4 into integer variable, I will call it index_var. When unit is issued an order, play sound sound_arr[index_var].

Also, beware of the memory leaks you have in your trigger. I also don't know if it won't cause multiple sounds to play for same unit when you order multiple orders in short time.

Something like this:
  • Map Ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set sounds[1] = Some sound
      • Set sounds[2] = Some sound
      • Set sounds[3] = Some sound
      • Set sounds[4] = Some sound
  • Order
    • Events
      • Your order event
    • Conditions
      • Your conditions
    • Actions
      • Set number = (Random integer number between 1 and 4)
      • Sound - Play sounds[number] at ....
 
Status
Not open for further replies.
Top