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

Allow sound overlapping

Status
Not open for further replies.
Level 6
Joined
Apr 5, 2013
Messages
154
  • M249 Fire
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to m249 attak
    • Actions
      • Sound - Play m249_1 <gen>
      • Set AKUNIT = (Triggering unit)
      • Custom script: call SetUnitAnimationByIndex(udg_AKUNIT, 151)
      • Animation - Queue AKUNIT's stand animation
      • Player - Add 2 to (Owner of (Triggering unit)) Food used
The "M249 attak" is an extremely spammable ability, thus causing the attack sound to be cut off when another instance of the ability starts being casted. Is there any way to bypass this?
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
If you really want to use, you need to check out some basic jass tutorials.

Roughly, you need to use the action in GUI called
  • Custom Script
, and then for example, use the function
JASS:
function DefineSound takes string fileName, integer duration, boolean looping, boolean is3D returns integer
from the system like this:
  • Custom Script: call SoundUtils_DefineSound( "some path", someDuration, trueOrFalse, trueInYourCase)
.

It does not make sense to use it without basic understanding of how jass works. However you may read through the documentation of this system and see for yourself, if you are able to understand how to use it.

I, myself, encourage you to learn more and just try to use it, the worst thing may be that it will not work to compile. I guess that may be the reason that Dr. Super Good did not mention this...
 
Level 11
Joined
Aug 6, 2009
Messages
697
You can use call PlaySound(*Insert path of your sound here*).PlaySound can play the same sound multiple times at once. Example: call PlaySound("war3mapImported\\Lightning1.mp3"), you need the double slash for the path instead of one slash. The downside to PlaySound is that you can't stop the sound once its played, it will play until the sound has finished. So you can not do, call StopSound("war3mapImported\\Lightning1.mp3").

Update: I forgot about one very important downside to using PlaySound, it does not play the sound on the first time it is called. I made a trigger to fix this, here it is:

  • FixToEnableSoundsFirstSpell
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Custom script: local string s
      • Custom script: local sound s2
      • For each (Integer SoundLoop) from 1 to 5, do (Actions)
        • Loop - Actions
          • Custom script: set s = udg_PlaySound[udg_SoundLoop]
          • Custom script: set s2 = CreateSound(s, false, false, true, 12700, 12700, "")
          • Custom script: call StartSound(s2)
          • Custom script: call StopSound(s2,false,false)
udg_PlaySound[] is a string variable I use to make life easy for me. In an init I set the sound path to a string array variable so I can just loop through like this.
 
Last edited:
Status
Not open for further replies.
Top