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.
[12:07 am]
Vrael -- NudeRaider
NudeRaider shouted: Vrael ranting still is though
you're a gentleman and a scholar, thank you
[10:07 pm]
NudeRaider -- ya why phone people when you can just write letters
[09:37 pm]
IskatuMesk -- I have never and will never own a phone
[09:15 pm]
NudeRaider -- Vrael ranting still is though
[09:14 pm]
ClansAreForGays -- anticapitalism isnt edgy anymore
[03:31 pm]
Vrael -- it only costs 50% of my post-tax salary for life and in return I get to also become a drone whose sole purpose is CAPITALISM
[03:30 pm]
Vrael -- pssht, you're still using a phone? I just record 100% of my life using my ElonBrainChip
[2026-4-13. : 2:13 pm]
NudeRaider -- bro I don't go anywhere without my phone to record anything significant
[2026-4-13. : 1:28 pm]
Vrael -- Zoan
Zoan shouted: not if u wer there
id say even if you were there its tricky, human memory can be very faulty
[2026-4-12. : 11:55 pm]
Zoan -- not if u wer there
Please log in to shout.


Members Online: Zycorax