• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] sound on a point/unit delay

Status
Not open for further replies.
Level 5
Joined
Jul 15, 2012
Messages
101
hi hive, i've been struggling to make a sound that can play without waiting for itself to finish.

  • Custom script: call PlaySound("Sound\\Units\\Combat\\MetalHeavySliceFlesh3.wav")
this works fine except it's not on a point or a unit.

  • Sound - Play Warning <gen> at 100.00% volume, attached to (Triggering unit)
this works on a unit except it has to wait for itself to finish, also it leaks for now.

all functions i have tried end up like the latter :vw_unimpressed:
 
Level 39
Joined
Feb 27, 2007
Messages
5,048
Put this function in your map's custom script section and then call it instead.

JASS:
function PlaySoundAttached takes string soundName, unit attachUnit returns nothing
    local sound soundHandle = CreateSound(soundName, false, false, true, 12700, 12700, "")
    call StartSound(soundHandle)
    call KillSoundWhenDone(soundHandle)
    call AttachSoundToUnit(soundHandle, attachUnit)
    set soundHandle = null
endfunction
 
Level 5
Joined
Jul 15, 2012
Messages
101
I put the function into the section and called it, it can play multiple times at once but you can hear it on every point of the map, therefore it's not attached to an unit, or the sound's range is global.
 
Level 5
Joined
Jul 15, 2012
Messages
101
That's the fadein fadeout rate I believe. I tested it both with 10 and 12700 values before even checking what it is. (10 because that's the default for sounds in the Sound Editor)

The Sound Editor

Fade in Rate This is how long it will take for a Sound to Fade in.

JASS:
string fileName, boolean looping, boolean is3D, boolean stopwhenoutofrange, integer fadeInRate, integer fadeOutRate, string eaxSetting
As I said, whatever function I try to add, same result :vw_unimpressed:

Maybe it should be "is3D" true instead of false, but the sound doesn't even play if so.
If the sound is not a variable (when you use "StartSound") it's not 3D by default I think?

It seems whenever I use this it has a delay before it can play again,
JASS:
call PlaySoundBJ(soundHandle)
and this is always a global sound
JASS:
call StartSound(soundHandle)
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,048
Sounds could still broken in some way since Blizz updated the sound engine a few patches ago. Honestly I don’t do too much sound stuff so I’m not up to snuff.

I thought the 3D flag should be true too but if it doesn’t play like that then idk. Try searching on this site for other people playing sounds and use the settings they use.

You can also try picking apart the PlaySoundBJ function to see what it actually does to the sound function that makes it attach. That’s what I did to build the function I posted above but apparently I did something wrong.
 
Status
Not open for further replies.
Top