dkfans / keeperfx

Open source remake and Fan Expansion of Dungeon Keeper.
https://keeperfx.net/
GNU General Public License v2.0
748 stars 77 forks source link

SPAWNED_CREATURES level script variable #1426

Open Loobinex opened 2 years ago

Loobinex commented 2 years ago

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
PieterVdc commented 2 years ago

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

Loobinex commented 2 years ago

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.

PieterVdc commented 2 years ago

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?

Loobinex commented 2 years ago

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.