REM ****************************************************************************
REM  Campaigns Consolidation Project for KeeperFX strategy game.
REM ****************************************************************************
REM  Script for Bonus Level - Witch Hidden Realm
REM  Campaign: New game plus
REM  Authors:  based on Bullfrog script
REM            KeeperFX CCP Team
REM            Loobinex
REM  Date:   17 Aug 1997 - 24 Aug 2020
REM  Copying and copyrights:
REM This program is free software; you can redistribute it and/or modify
REM it under the terms of the GNU General Public License as published by
REM the Free Software Foundation; either version 2 of the License, or
REM (at your option) any later version.
REM ****************************************************************************

LEVEL_VERSION(1)
RUN_AFTER_VICTORY(1)

START_MONEY(PLAYER0,12000)

MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HEAL_CREATURE,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_DESTROY_WALLS,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CONCEAL,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_PROTECT,1,1)


IF(PLAYER0,CAMPAIGN_FLAG5 <= 1)
	REM "This region of the underworld will test your ability to traverse the network of caverns. Indeed, time is your enemy here. Defeat it and you will find where a legendary warrior is imprisoned. That warrior will serve you well in the future."
	DISPLAY_OBJECTIVE(153,PLAYER0)
	BONUS_LEVEL_TIME(4000)
	SET_TIMER(PLAYER0,TIMER1)
ENDIF

IF(PLAYER0,TIMER1 >= 2000)
	DISPLAY_OBJECTIVE(150,PLAYER0)
ENDIF

IF(PLAYER0,TIMER1 >= 4000)
    REM "Your time is up. You have failed. I'm embarrassed to come from the same inter-dimensional void as you."
	DISPLAY_OBJECTIVE(151,PLAYER0)
	LOSE_GAME
ENDIF

IF(PLAYER0,TOTAL_CREATURES == 0)
	IF(PLAYER0,GAME_TURN > 20)
		DISPLAY_OBJECTIVE(151,PLAYER0)
		LOSE_GAME
	ENDIF
ENDIF

IF(PLAYER0,WITCH > 0)
    REM "Well done. You have excelled in your use of large balls of stone for which the dark gods will repay you, by allowing you to use the warrior you found when you reach the next realm."
	DISPLAY_OBJECTIVE(152,PLAYER0)
	BONUS_LEVEL_TIME(0)
	SET_FLAG(PLAYER0,CAMPAIGN_FLAG5,1)
	SET_FLAG(PLAYER0,FLAG5,1)
	WIN_GAME
ENDIF

IF(PLAYER0,CAMPAIGN_FLAG5 == 1)
	IF(PLAYER0,FLAG5 == 1)
		IF(PLAYER0,WITCH <= 0)
			SET_FLAG(PLAYER0,CAMPAIGN_FLAG5,2)
		ENDIF
		IF(PLAYER0,SKELETON <= 0)
			SET_FLAG(PLAYER0,CAMPAIGN_FLAG6,1)
		ENDIF
	ENDIF
ENDIF

IF(PLAYER0,GAME_TURN <= 60)
	IF(PLAYER0,CAMPAIGN_FLAG5 >= 1)
		KILL_CREATURE(PLAYER0,IMP,MOST_EXPERIENCED,1)
	ENDIF
	IF(PLAYER0,CAMPAIGN_FLAG5 == 1)
		ADD_CREATURE_TO_LEVEL(PLAYER0,WITCH,PLAYER0,1,6,0)
	ENDIF
	IF(PLAYER0,CAMPAIGN_FLAG5 == 2)
		WIN_GAME
	ENDIF
ENDIF

IF(PLAYER0,CAMPAIGN_FLAG6 >= 1)
	KILL_CREATURE(PLAYER0,SKELETON,LEAST_EXPERIENCED,1)
ENDIF
