REM ********************************************
REM  Ancient Keeper campaign for KeeperFX
REM  Script for Level 5
REM  Version 1.00
REM ********************************************

START_MONEY(PLAYER0,10000)

SET_FLAG(PLAYER0,FLAG0,0)
SET_FLAG(PLAYER0,FLAG1,0)

DISPLAY_OBJECTIVE(179,PLAYER0)

ADD_CREATURE_TO_POOL(DRAGON,8)
CREATURE_AVAILABLE(PLAYER0,DRAGON,1,1)

MAGIC_AVAILABLE(PLAYER0,POWER_IMP,1,1)

DOOR_AVAILABLE(PLAYER0,MAGIC,1,0)

IF_ACTION_POINT(1,PLAYER0)
  DISPLAY_OBJECTIVE(180,PLAYER0)
ENDIF

IF_ACTION_POINT(2,PLAYER0)
  DISPLAY_OBJECTIVE(181,PLAYER0)
ENDIF

IF(PLAYER_GOOD,KNIGHT == 5)
  SET_FLAG(PLAYER0,FLAG0,1)
  DISPLAY_OBJECTIVE(182,PLAYER0)
ENDIF

IF(PLAYER0,FLAG0 == 1)
  IF(PLAYER0,BRIDGE < 1)
    NEXT_COMMAND_REUSABLE
    ROOM_AVAILABLE(PLAYER0,BRIDGE,1,1)
  ENDIF
ENDIF

IF(PLAYER0,FLAG0 == 1)
  IF(PLAYER0,BRIDGE > 0)
    NEXT_COMMAND_REUSABLE
    ROOM_AVAILABLE(PLAYER0,BRIDGE,0,0)
  ENDIF
ENDIF

IF(PLAYER_GOOD,KNIGHT == 3)
  SET_FLAG(PLAYER0,FLAG0,2)
ENDIF

IF(PLAYER0,FLAG0 == 2)
  IF(PLAYER0,BRIDGE < 2)
    NEXT_COMMAND_REUSABLE
    ROOM_AVAILABLE(PLAYER0,BRIDGE,1,1)
  ENDIF
ENDIF

IF(PLAYER0,FLAG0 == 2)
  IF(PLAYER0,BRIDGE > 1)
    NEXT_COMMAND_REUSABLE
    ROOM_AVAILABLE(PLAYER0,BRIDGE,0,0)
  ENDIF
ENDIF

IF(PLAYER_GOOD,KNIGHT == 0)
  SET_FLAG(PLAYER0,FLAG0,3)
  ROOM_AVAILABLE(PLAYER0,BRIDGE,1,1)
ENDIF

IF(PLAYER0,FLAG1 == 0)
  IF(PLAYER0,TOTAL_CREATURES > 0)
    SET_FLAG(PLAYER0,FLAG1,1)
  ENDIF
ENDIF

IF(PLAYER0,FLAG1 == 1)
  IF(PLAYER0,TOTAL_CREATURES < 1)
    DISPLAY_OBJECTIVE(183,PLAYER0)
    LOSE_GAME
  ENDIF
ENDIF

IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
  DISPLAY_OBJECTIVE(184,PLAYER0)
  WIN_GAME
ENDIF

IF(PLAYER0,DUNGEON_DESTROYED == 1)
  LOSE_GAME
  DISPLAY_OBJECTIVE(183,PLAYER0)
ENDIF
