• 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.

[JASS] Pick every unit and sound

Status
Not open for further replies.
Level 17
Joined
Mar 21, 2011
Messages
1,611
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