Well it won't be particularly nice anyway, because sounds played via "Play Wave" are at 100% volume wherever the player is looking on the map. So you'll be able to hear the terrans 'dying' from anywhere.
Are they immortal or can they be killed by the player somehow? If they get killed by the player, do you want them to play your new sound?
Because this system will work. It needs 2 DCs, Current and Previous.
1. In triggers decreasing by the power of 2, give the infested terrans from the CPU player to P9-12 or another CPU player (doesn't matter, just some other player). Eg: player commands at least 16 terrans, give 16 terrans to [other player], player commands at least 8 terran, give 8 terrans to [other player], player commands at least 4 terran..., commands at least 2 terran..., commands at least 1 terran. Make enough of these triggers sufficient to cover all possible terrans on the field at once, if you can have a maximum of 48 then you'll need to go up to 32 (2 * largest trigger - 1 = maximum limit, eg 32 * 2 -1 = 63, which is bigger than 48).
2. In those same triggers above, add the number of terrans given in each trigger to Current DC.
3. After all terrans have been given, you'll end up with the original player commanding 0 terrans and the number of terrans they had in both Current and Store DCs.
4. Now have another set of triggers that work in powers of 2 to subtract DCs from both Current and Previous based on the DCs in Previous and Current. Eg previous is at least 16, current is at least 16: subtract 16 from previous, subtract 16 from current. Previous is at least 8, current is at least 8, subtract 8 from current, subtract 8 from previous. Do this all the way down to 1.
5. Now from the above, one or both of Current and Previous are now at 0. If they are both at 0, this means the number of terrans has not changed since the last time the algorithm was run. If Current is at least 1, it means the number of terrans has increased compared to Previous. If Previous is at least 1, it means the number of terrans in Current has decreased compared to previous: so we should play the special wav sound (or whatever other actions you wanted to take).
6. Set previous and current to 0.
7. Now use more powers of 2 triggers similar to #1 but giving the terrans back from [other player] to your original CPU player and add the number of terrans given in each trigger to Previous.
At the end of this run through the cycle, you'll have the number of terrans currently on the map stored in Previous, which will carry over to the next trigger cycle for the algorithm to use.
Note that this system isn't foolproof: if 3 terrans died since the last cycle, but we also created 5 more via triggers, then the net change will be +2 terrans and the trigger for the sound effect will not fire.
Note that when you're using Commands in subsequent triggers you need to clear the 'caching' of this data that Starcraft does. This can easily be done by adding an action such as Move Location to your trigger actions; it doesn't have to be any real or useful location movement at all, for example you can just do Move Location Anywhere to Map Revealer owned by Player 1 at Anywhere and it will be sufficient to clear out the cache. See this post by Heinerman for the gritty details:
http://www.staredit.net/307127/
Post has been edited 2 time(s), last time on Jan 11 2012, 10:39 am by Lanthanide.
None.