REM ****************************************************************************
REM  Campaigns Consolidation Project for KeeperFX strategy game.
REM ****************************************************************************
REM  Script for Level Cosyton
REM  Campaign: DK Original
REM  Campaign: New game plus
REM  Authors:  based on Bullfrog script
REM            KeeperFX CCP Team
REM            Loobinex
REM  Date:     17 Aug 1997 - 10 Aug 2019
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)

REM New rooms for the player:
REM   TRAINING
REM New creatures for the player:
REM   DEMON_SPAWN

REM Flags used:
REM   PLAYER0,FLAG3 - State of TRAINING building; 0-not built yet; 1-built.

REM Timers used:
REM   PLAYER0,TIMER0
REM   PLAYER0,TIMER1
REM   PLAYER0,TIMER2

SET_GENERATE_SPEED(350)

START_MONEY(PLAYER0,2500)

MAX_CREATURES(PLAYER0,14)

ADD_CREATURE_TO_POOL(BUG,3)
ADD_CREATURE_TO_POOL(FLY,3)
ADD_CREATURE_TO_POOL(DEMONSPAWN,24)

CREATURE_AVAILABLE(PLAYER0,FLY,1,0)
CREATURE_AVAILABLE(PLAYER0,BUG,1,0)
CREATURE_AVAILABLE(PLAYER0,DEMONSPAWN,1,0)

SET_CREATURE_MAX_LEVEL(PLAYER0,DEMONSPAWN,10)
SET_CREATURE_MAX_LEVEL(PLAYER_GOOD,KNIGHT,2)
SET_CREATURE_MAX_LEVEL(PLAYER_GOOD,THIEF,2)
SET_CREATURE_MAX_LEVEL(PLAYER_GOOD,DWARFA,2)
SET_CREATURE_MAX_LEVEL(PLAYER_GOOD,TUNNELLER,2)


ROOM_AVAILABLE(PLAYER0,TREASURE,1,1)
ROOM_AVAILABLE(PLAYER0,LAIR,1,1)
ROOM_AVAILABLE(PLAYER0,GARDEN,1,1)
ROOM_AVAILABLE(PLAYER0,TRAINING,1,1)

MAGIC_AVAILABLE(PLAYER0,POWER_SLAP,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_HAND,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_IMP,1,1)

CREATE_PARTY(THIEVES)
	ADD_TO_PARTY(THIEVES,THIEF,1,200,STEAL_GOLD,0)

CREATE_PARTY(DWARVES)
	ADD_TO_PARTY(DWARVES,DWARFA,1,200,ATTACK_ENEMIES,0)

CREATE_PARTY(ELITE)
	ADD_TO_PARTY(ELITE,DWARFA,1,200,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(ELITE,THIEF,1,200,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(ELITE,DWARFA,2,200,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(ELITE,THIEF,2,200,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(ELITE,DWARFA,3,200,ATTACK_ENEMIES,0)

CREATE_PARTY(LANDLORD)
	ADD_TO_PARTY(LANDLORD,KNIGHT,2,2000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(LANDLORD,DWARFA,2,200,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(LANDLORD,DWARFA,2,200,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(LANDLORD,DWARFA,2,200,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(LANDLORD,THIEF,2,200,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(LANDLORD,THIEF,2,200,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(LANDLORD,THIEF,2,200,ATTACK_ENEMIES,0)
	
REM ****************************************************************************

REM "The heroes are on their way. Make sure your creatures are well trained and ready for the attack."
DISPLAY_OBJECTIVE(30,ALL_PLAYERS)

SET_TIMER(PLAYER0,TIMER0)

IF(PLAYER2,FLAG1 == 0)
	SET_FLAG(PLAYER2,FLAG0,1)
	IF(PLAYER0,TIMER0 >= 4000)
		ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,THIEVES,1,DUNGEON,0,1,500)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DWARVES,1,1)
		IF_CONTROLS(PLAYER_GOOD,TOTAL_CREATURES <= 0)
			IF(PLAYER0,TOTAL_CREATURES >= 8)
				ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,ELITE,-1,DUNGEON,0,1,500)
				IF(PLAYER_GOOD,TOTAL_CREATURES <= 0)
					IF(PLAYER0,TOTAL_CREATURES >= 8)
						SET_FLAG(PLAYER2,FLAG0,2)
						ADD_PARTY_TO_LEVEL(PLAYER_GOOD,LANDLORD,-1,1)
					ENDIF
				ENDIF
			ENDIF
		ENDIF
	ENDIF
ENDIF

IF_ACTION_POINT(2,PLAYER0)
	IF(PLAYER2,FLAG0 == 0)
		SET_FLAG(PLAYER2,FLAG1,1)
		ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,THIEVES,1,DUNGEON,0,1,500)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DWARVES,1,1)
		IF_CONTROLS(PLAYER_GOOD,TOTAL_CREATURES <= 0)
			IF(PLAYER0,TOTAL_CREATURES >= 8)
				ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,ELITE,-1,DUNGEON,0,1,500)
				IF_CONTROLS(PLAYER_GOOD,TOTAL_CREATURES <= 0)
					IF(PLAYER0,TOTAL_CREATURES >= 8)
						SET_FLAG(PLAYER2,FLAG1,2)
						ADD_PARTY_TO_LEVEL(PLAYER_GOOD,LANDLORD,-1,1)
					ENDIF
				ENDIF
			ENDIF
		ENDIF
	ENDIF
ENDIF

IF_CONTROLS(PLAYER_GOOD,TOTAL_CREATURES <= 0)
	IF(PLAYER2,FLAG0 == 2)
		REM "Harder the heroes may have been but they were obviously no match for your forces."
		DISPLAY_OBJECTIVE(31,ALL_PLAYERS)
		WIN_GAME
	ENDIF
	IF(PLAYER2,FLAG1 == 2)
		REM "Congratulations. You have conquered the enemy hordes."
		DISPLAY_OBJECTIVE(33,ALL_PLAYERS)
		WIN_GAME
	ENDIF
ENDIF

REM ****************************************************************************
