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

[JASS] Pick every unit and sound

Status
Not open for further replies.
Level 17
Joined
Mar 21, 2011
Messages
1,597
Hi,
i have 2 questions:

1. How to remove a sound efficiently?
JASS:
local sound s
set s = CreateSound("gg_snd_SomeSound", false, false, true, 12700, 12700, "")
call StartSound(s)
call KillSoundWhenDone(s)
set s = null
that's my current code.

2. How to pick every unit in playable map area?
JASS:
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
is this correct?

thanks :)
 
1. Yes, that is the correct way. However, (according to TrollBrain) sounds aren't played when sounds are muted/disabled (probably as an optimization). That also means KillSoundWhenDone won't actually work under those conditions. You don't have an easy workaround. Instead, you should just create one sound handle on map initialization, store it somewhere, and reuse it throughout your map. GUI uses a similar method with their generated globals--they make them once and then you can use them as often as you want. After all, even with 1000 imported sounds, you'll only have up to 1000 sound handles in memory. That is static throughout the map, which really isn't too bad.

2. Yep, that is correct.
 
Status
Not open for further replies.
Top