Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Detecting unit amount (custom 'unit ready' speech)
Detecting unit amount (custom 'unit ready' speech)
Sep 3 2016, 6:27 am
By: SPyro_Malin  

Sep 3 2016, 6:27 am SPyro_Malin Post #1



What i want to do is changing unit production sound.
If possible i would like to do that without modding.
I haven't figured out how to detect when a new unit is build.
I would like to do that for 4 units, which are regular combat units (they will die for sure some times) so it has to play that wav only when the counter goes up.
If it have been talked about already - sorry, i couldn't find it.



None.

Sep 3 2016, 12:04 pm Roy Post #2

An artist's depiction of an Extended Unit Death

You'll basically need to build an inverse of a Kills to Cash system, except using the Unit score instead of the Kills score. I'm not entirely sure if the score values are the same for all units, but the kill score values can be found here: http://www.staredit.net/wiki/index.php?title=Unit#Kill_Score

An example trigger would look like this:

Battlecruiser
Players

  • All Players
  • Conditions

  • Current Player has suffered exactly 0 deaths of Cantina.
  • Current Player units score is at least 2400.
  • Current Player commands at least 1 Terran Battlecruiser.
  • Actions

  • Modify death counts for Current Player: Set to 12 for Cantina.
  • Play 'CustomBattlecruiserReady.wav'
  • Modify score for Current Player: Subtract 2400 units.
  • Preserve Trigger.


  • In English:
    • The first condition is using Death Counters to prevent multiple wavs from running within one second of each other.
    • The second condition is checking if the player's build score is at least high enough for a Terran Battlecruiser
    • The third condition is a safety check to actually verify that the player owns a Terran Battlecruiser
    • The first action is using Death Counters to prevent these triggers from running (based on the first condition)
    • The second action is playing the custom ready sound you want to use when creating a Terran Battlecruiser
    • The third action is removing the points awarded for building a Terran Battlecruiser
    • The fourth action allows the trigger to run more than once

    Repeat the above trigger for every unit you can build in your game, regardless of whether or not you want a custom sound; for the units that you aren't playing a custom sound for, remove the 'Play Wav' action (and, if preferred, the 'Set Deaths' action). Make sure to order the triggers in descending order of the unit's score, or else you could misattribute scores to incorrect units.

    Finally, at the bottom of these triggers, have the following as a general safety clean up (for cases where you might build units simultaneously) and to decrement the Death Counter timer:

    Cleanup
    Players

  • All Players
  • Conditions

  • Always
  • Actions

  • Modify score for Current Player: Set to 0 units.
  • Modify death counts for Current Player: Subtract 1 for Cantina.
  • Preserve Trigger.


  • Finally, the caveats of this method:
    • You'll need to make triggers even for the units you don't want to play a custom sound for, because otherwise their build score can falsely trigger one of the wavs. For those triggers, remove the 'Play Wav' action, but keep the action to reduce the score.
    • A unit will still play their normal ready sound with the above setup. You can fix this by muting unit speech, though this applies to all speech, not just ready sounds.
    • Some units have the same score, so if you have both types of units, it's impossible to detect which one has been created.
    • This is a complicated mapping problem to solve, but it would be an easy modding problem.

    A potential alternate method to avoid creating triggers for units you aren't interested in is by tracking how many of a type of unit the player commands vs how many of that type have died. This significantly increases complexity and there's no simple way to do arithmetic between variables in SC, so I don't see it as being a more viable approach than what I've suggested.

    Post has been edited 7 time(s), last time on Sep 3 2016, 12:31 pm by Roy.




    Sep 6 2016, 8:56 am SPyro_Malin Post #3



    That should work.
    I fooled around with kill to kash but I didn't think about using it that way, ur creative for sure :).
    Gotta remove mind control, no way I'm doing this for all 3 races xD.

    Many thanks, you helped me a lot.



    None.

    Options
      Back to forum
    Please log in to reply to this topic or to report it.
    Members in this topic: None.
    [2026-7-18. : 2:27 am]
    Symmetry -- https://staredit.net/topic/18903/ THE REVIEWS ARE HERE! "ok these are pretty good memes" - ssj9Kevin
    [2026-7-17. : 2:58 pm]
    Ultraviolet -- Symmetry
    Symmetry shouted: Man I wish we had this tech back in the day when people played ums lmao
    fr fr
    [2026-7-17. : 2:39 am]
    Symmetry -- Man I wish we had this tech back in the day when people played ums lmao
    [2026-7-16. : 6:28 am]
    NudeRaider -- EUD actions, specifically. The conditions remained. Today we can even have actions again, but they're all virtualized/whitelisted (not sure on the actual technical implementation) so you can only use them for specific intended purposed, not arbitrary code injections.
    [2026-7-16. : 6:26 am]
    NudeRaider -- I mean yes, maps - through EUDs - were theoretically able to do that as well, but that was patched quickly.
    [2026-7-16. : 6:25 am]
    NudeRaider -- Symmetry
    Symmetry shouted: Ohhh imagine a SC map that could delete itself
    not the map, the editor
    [2026-7-16. : 2:28 am]
    Symmetry -- I vaguely remember Voy doing some ACE back in the day, but I had no idea EUDs could do that kind of shit. I am very much catching up on the technology
    [2026-7-16. : 2:28 am]
    Symmetry -- Ohhh imagine a SC map that could delete itself
    [2026-7-15. : 8:51 pm]
    NudeRaider -- Symmetry
    Symmetry shouted: NudeRaider Is EUD editor capable of writing shit onto the player's harddrive? That seems like it would be dangerous
    yeah an editor that isn't allowed to write files sounds rather pointless, so I'd assume it can. Like most other programs too btw. and yes, obviously that's dangerous, but also kinda necessary. MS introduced that virtualization for exactly that reason.
    [2026-7-15. : 4:10 am]
    Ultraviolet -- I don't think so. I think they shut that shit down after 1.16, maybe even earlier
    Please log in to shout.


    Members Online: Symmetry