REM ****************************************************************************
REM  Campaigns Consolidation Project for KeeperFX strategy game.
REM ****************************************************************************
REM  Script for Bonus Level - Imp slapping Hidden Realm
REM  Campaign: New game plus
REM  Authors:  based on Bullfrog script
REM            KeeperFX CCP Team
REM            Loobinex
REM  Date:   17 Aug 1997 - 30 Jun 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,1200)


IF(PLAYER0,CAMPAIGN_FLAG2 <= 0)
	REM "These Imps have all turned rogue and therefore must die."
	DISPLAY_OBJECTIVE(140,PLAYER0)
	MAGIC_AVAILABLE(ALL_PLAYERS,POWER_LIGHTNING,1,1)
	MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HAND,0,0)

	SET_TIMER(PLAYER0,TIMER0)
	BONUS_LEVEL_TIME(4000)
ENDIF

IF(PLAYER0,TIMER0 >= 2000)
	IF(PLAYER0,FLAG1 == 0)
		REM "Tempus fugit, Keeper. You have been warned."
		DISPLAY_INFORMATION(141,ALL_PLAYERS)
	ENDIF
ENDIF

IF(PLAYER0,TIMER0 >= 4000)
	IF(PLAYER0,FLAG1 == 0)
		DISPLAY_OBJECTIVE(142,PLAYER0)
		SET_FLAG(PLAYER0,FLAG1,2)
		LOSE_GAME
	ENDIF
ENDIF

IF(PLAYER0,CAMPAIGN_FLAG2 <= 0)
	IF(PLAYER0,IMP == 0)
		IF(PLAYER0,DUNGEON_DESTROYED == 0)
			SET_FLAG(PLAYER0,FLAG2,1)
			ADD_CREATURE_TO_LEVEL(PLAYER0,IMP,PLAYER0,10,10,10000)
		ENDIF
	ENDIF
ENDIF

IF(PLAYER0,FLAG2 == 1)
	IF(PLAYER0,IMP <= 0)
		IF(PLAYER0,DUNGEON_DESTROYED == 0)
			IF(PLAYER0,FLAG1 == 0)
				REM "You are indeed a twisted soul, master. You made the Imps extinct with such panache that not one but two Dark Mistresses have devoted themselves to helping you achieve your next goal. You may proceed to your next conquest."
				DISPLAY_OBJECTIVE(143,PLAYER0)
				ADD_CREATURE_TO_LEVEL(PLAYER0,DARK_MISTRESS,PLAYER0,2,4,10000)
				REM Using a timer to make sure add creature command will be executed
				SET_TIMER(PLAYER0,TIMER1)
			ENDIF
		ENDIF
	ENDIF
ENDIF

IF(PLAYER0,CAMPAIGN_FLAG2 == 1)
KILL_CREATURE(PLAYER0,IMP,MOST_EXPERIENCED,50)
	IF(PLAYER0,FLAG3 == 1)
		IF(PLAYER0,DARK_MISTRESS <= 0)
			SET_FLAG(PLAYER0,CAMPAIGN_FLAG2,3)
		ENDIF
		IF(PLAYER0,DARK_MISTRESS <= 1)
			SET_FLAG(PLAYER0,CAMPAIGN_FLAG2,2)
		ENDIF
	ENDIF

	IF(PLAYER0,FLAG3 == 0)
		ADD_CREATURE_TO_LEVEL(PLAYER0,DARK_MISTRESS,PLAYER0,2,4,10000)
		DISPLAY_OBJECTIVE(143,PLAYER0)
		SET_FLAG(PLAYER0,FLAG3,1)
	ENDIF
	SET_FLAG(PLAYER0,FLAG1,1)
	WIN_GAME
ENDIF

IF(PLAYER0,CAMPAIGN_FLAG2 == 2)
KILL_CREATURE(PLAYER0,IMP,MOST_EXPERIENCED,50)
	IF(PLAYER0,FLAG3 == 1)
		IF(PLAYER0,DARK_MISTRESS <= 0)
			SET_FLAG(PLAYER0,CAMPAIGN_FLAG2,3)
		ENDIF
		IF(PLAYER0,DARK_MISTRESS <= 1)
			SET_FLAG(PLAYER0,CAMPAIGN_FLAG2,2)
		ENDIF
	ENDIF
	
	IF(PLAYER0,FLAG3 == 0)
		ADD_CREATURE_TO_LEVEL(PLAYER0,DARK_MISTRESS,PLAYER0,1,4,10000)
		SET_FLAG(PLAYER0,FLAG3,1)
	ENDIF

	WIN_GAME
ENDIF

IF(PLAYER0,CAMPAIGN_FLAG2 == 3)
	KILL_CREATURE(PLAYER0,IMP,MOST_EXPERIENCED,50)
	WIN_GAME
ENDIF

IF(PLAYER0,TIMER1 >= 100)
	MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HAND,1,1)
	SET_FLAG(PLAYER0,CAMPAIGN_FLAG2,1)
	SET_FLAG(PLAYER0,FLAG3,1)
ENDIF
