Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Does Create Units not invalidate Commands trigger?
Does Create Units not invalidate Commands trigger?
Nov 23 2024, 2:15 am
By: sethmachine  

Nov 23 2024, 2:15 am sethmachine Post #1



Hi,

I have a simpler trigger where if a player commands 0 of a unit, it spawns 1 of that unit. And then another trigger, where if that unit is dead, it creates an item (crystal) at the unit's last location.

But for some reason, when I first run the map, both triggers are running (create the unit, and spawn the item). But I put the create unit trigger before the spawn item trigger. So shouldn't creating the unit stop the condition of "Commands Exactly 0" ?

Unit is hero Hydralisk.

Code
BOSS_UNIT = UnitId.HUNTER_KILLER_HYDRALISK
BOSS_LOCATION = LocationReference(_name="boss-hydra-tracker")
BOSS_ITEM_SAFE_SPAWN_LOCATION = LocationReference(_name="boss-item-safe-spawn")
BOSS_ITEM_DROP = UnitId.KHALIS_CRYSTAL
ANYWHERE_LOC = LocationReference(_name="anywhere")


def spawn_boss_unit(map_build_context: MapBuildContext) -> RichTrigger:
   return RichTrigger(
       _conditions=[
           CommandCondition(
               _group=PlayerId.PLAYER_2,
               _comparator=NumericComparator.EXACTLY,
               _amount=0,
               _unit=BOSS_UNIT,
           )
       ],
       _actions=[
           CreateUnitAction(
               _group=PlayerId.PLAYER_2,
               _amount=1,
               _unit=BOSS_UNIT,
               _location=map_build_context.location_reference_resolver.resolve_exactly(
                   BOSS_LOCATION
               ),
           ),
           RunAiScriptAtLocationAction(
               _ai_script=KnownAiScript.JUNKYARD_DOG.value,
               _location=map_build_context.location_reference_resolver.resolve_exactly(
                   BOSS_LOCATION
               ),
           ),
           PreserveTrigger(),
       ],
       _players={PlayerId.PLAYER_2},
   )


def center_location_on_boss_if_alive(map_build_context: MapBuildContext) -> RichTrigger:
   return RichTrigger(
       _conditions=[
           CommandCondition(
               _group=PlayerId.PLAYER_2,
               _comparator=NumericComparator.EXACTLY,
               _amount=1,
               _unit=BOSS_UNIT,
           )
       ],
       _actions=[
           MoveLocationAction(
               _source_location=map_build_context.location_reference_resolver.resolve_exactly(
                   BOSS_LOCATION
               ),
               _unit=BOSS_UNIT,
               _group=PlayerId.PLAYER_2,
               _destination_location=map_build_context.location_reference_resolver.resolve_exactly(
                   ANYWHERE_LOC
               ),
           ),
           PreserveTrigger(),
       ],
       _players={PlayerId.PLAYER_2},
   )


def spawn_item_on_boss_when_dead(map_build_context: MapBuildContext):
   return RichTrigger(
       _conditions=[
           CommandCondition(
               _group=PlayerId.PLAYER_2,
               _comparator=NumericComparator.EXACTLY,
               _amount=0,
               _unit=BOSS_UNIT,
           )
       ],
       _actions=[
           CreateUnitAction(
               _group=PlayerId.PLAYER_2,
               _amount=1,
               _unit=BOSS_ITEM_DROP,
               _location=map_build_context.location_reference_resolver.resolve_exactly(
                   BOSS_LOCATION
               ),
           ),
           PreserveTrigger(),
       ],
       _players={PlayerId.PLAYER_2},
   )


class BossItemDropTriggerGenerator(TriggerGenerator):
   def generate_triggers(
       self, map_build_context: MapBuildContext
   ) -> list[RichTrigger]:
       return [
           spawn_boss_unit(map_build_context),
           center_location_on_boss_if_alive(map_build_context),
           spawn_item_on_boss_when_dead(map_build_context),
       ]




None.

Nov 23 2024, 10:31 am NudeRaider Post #2

We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

http://www.staredit.net/topic/2754/#54441

Last sentence of the box is the tl;dr




Nov 23 2024, 6:17 pm Ultraviolet Post #3

We do a little trolling

Checking for Bring to anywhere rather than Command will avoid the issue. Or you could change the condition to death of unit is at least/exactly 1.



My Projects:

Impossible Ultraviolet | Impossible UV 2 | Impossible UV 3
Mercenaries 2020 | Mercenaries III
Squad Defense

Legacy Projects (No guarantee of functionality in modern SC):

Pixel Adventure 2 | Space Snipers | Control the Ball

______________________________________________

Join me in Torn City

Nov 23 2024, 10:53 pm sethmachine Post #4



Thanks for confirming everyone!

Yes this was what NudeRaider alluded to:

Quote
Creating a unit does not tell SC that it needs to refresh the data. Therefore, if the next condition needs the 'same' type of data as the last one, it won't refresh.

Quote
Or you could change the condition to death of unit is at least/exactly 1.

Interesting, I guess that could work! I was also thinking of introducing a specific death counter to track that the unit was alive.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[2026-8-11. : 4:44 am]
Zycorax -- :wob:
[2026-8-11. : 2:30 am]
Symmetry -- :wob:
[2026-8-10. : 1:36 am]
Moose -- Thinking on it more, I vaguely remember it being annoying because it kept repeating some short loop of the Super Mario World theme LMAO
[2026-8-10. : 12:57 am]
Oh_Man -- I thought i remembered an old mario map but i searched super mario starcraft on utube and i couldnt see anything cept UMS
[2026-8-09. : 11:40 pm]
lil-Inferno -- Blizzard forgot about SC so it's okay
[2026-8-09. : 7:04 pm]
Symmetry -- malware maps for everyone
[2026-8-09. : 7:03 pm]
Moose -- probs lmao
[2026-8-09. : 6:57 pm]
Symmetry -- (and will be patched)
[2026-8-09. : 6:56 pm]
Symmetry -- The old stuff would've gotten patched no? this is current
[2026-8-09. : 6:55 pm]
Moose -- Just made? I thought we had that years ago
Please log in to shout.


Members Online: NudeRaider