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.
    [09:38 pm]
    NudeRaider -- Ultraviolet
    Ultraviolet shouted: NudeRaider sing it brother
    trust me, you don't wanna hear that. I defer that to the pros.
    [07:56 pm]
    Ultraviolet -- NudeRaider
    NudeRaider shouted: "War nie wirklich weg" 🎵
    sing it brother
    [06:24 pm]
    NudeRaider -- "War nie wirklich weg" 🎵
    [2024-4-27. : 3:33 pm]
    O)FaRTy1billion[MM] -- o sen is back
    [2024-4-27. : 1:53 am]
    Ultraviolet -- :lol:
    [2024-4-26. : 6:51 pm]
    Vrael -- It is, and I could definitely use a company with a commitment to flexibility, quality, and customer satisfaction to provide effective solutions to dampness and humidity in my urban environment.
    [2024-4-26. : 6:50 pm]
    NudeRaider -- Vrael
    Vrael shouted: Idk, I was looking more for a dehumidifer company which maybe stands out as a beacon of relief amidst damp and unpredictable climates of bustling metropolises. Not sure Amazon qualifies
    sounds like moisture control is often a pressing concern in your city
    [2024-4-26. : 6:50 pm]
    Vrael -- Maybe here on the StarEdit Network I could look through the Forums for some Introductions to people who care about the Topics of Dehumidifiers and Carpet Cleaning?
    [2024-4-26. : 6:49 pm]
    Vrael -- Perhaps even here I on the StarEdit Network I could look for some Introductions.
    [2024-4-26. : 6:48 pm]
    Vrael -- On this Topic, I could definitely use some Introductions.
    Please log in to shout.


    Members Online: Roy