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),
]
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.





