keeperfx icon indicating copy to clipboard operation
keeperfx copied to clipboard

SPAWNED_CREATURES level script variable

Open Loobinex opened this issue 3 years ago • 4 comments

Mapmakers often want players to not just destroy hearts, but also to kill the heroes on the map. This is to make sure the player does not simply avoid the heroes meant to defend it, and kill the heart without a fight. However, as a downside, this means that the player also has to find and kill all heroes hidden on the map, which is not always obvious and usually no fun for the player. It appears like the entire map is won, everything defeated and then he has to play hide and seek to trigger the victory condition.

A way around this trade-off would be to offer the map-maker a script variable to check how many of the creatures spawned by the script are still alive. This way he can have the player win the map when he kills the heart and all defenders, but not the hero pockets defending hidden areas.

Example:

IF_CONTROLS(PLAYER_GOOD,SPAWNED_CREATURES == 0)
  IF(PLAYER0,ALL_DUNGEONS_DESTROYED == 1)
    WIN_GAME
  ENDIF
ENDIF

Loobinex avatar Apr 08 '22 14:04 Loobinex

so a code wise, a new function/option to function like count_creatures_in_dungeon that also takes creation_turn into account?

PieterVdc avatar Apr 09 '22 11:04 PieterVdc

Hero units could exist without a dungeon, we'd still want to count those.

It could be a simple as adding a field to units that determines if the creatures have been placed by level script.

Loobinex avatar Apr 11 '22 14:04 Loobinex

yeah might've mischecked but tough that was the function currently used to count them if you use creation_turn you don't need an extra field right?

PieterVdc avatar Apr 11 '22 14:04 PieterVdc

if there is a creation turn for spawned units and not for preplaced units or units that came through a portal or joined the enemy, then sure.

Loobinex avatar Apr 11 '22 17:04 Loobinex