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.
    [10:41 am]
    v9bettel -- Nice
    [01:39 am]
    Ultraviolet -- no u elky skeleton guy, I'll use em better
    [10:50 pm]
    Vrael -- Ultraviolet
    Ultraviolet shouted: How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
    hey cut it out I'm getting all the minerals
    [10:11 pm]
    Ultraviolet -- :P
    [10:11 pm]
    Ultraviolet -- How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
    [2024-4-17. : 11:50 pm]
    O)FaRTy1billion[MM] -- nice, now i have more than enough
    [2024-4-17. : 11:49 pm]
    O)FaRTy1billion[MM] -- if i don't gamble them away first
    [2024-4-17. : 11:49 pm]
    O)FaRTy1billion[MM] -- o, due to a donation i now have enough minerals to send you minerals
    [2024-4-17. : 3:26 am]
    O)FaRTy1billion[MM] -- i have to ask for minerals first tho cuz i don't have enough to send
    [2024-4-17. : 1:53 am]
    Vrael -- bet u'll ask for my minerals first and then just send me some lousy vespene gas instead
    Please log in to shout.


    Members Online: jun3hong, Callfbyad