REM ****************************************************************************
REM  Campaigns Consolidation Project for KeeperFX strategy game.
REM ****************************************************************************
REM  Script for Level Waterdream Warm
REM  Campaign: DK Original
REM  Authors:  based on Bullfrog script
REM            KeeperFX CCP Team
REM  Date:     17 Dec 1996 - 06 Feb 2011
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 ****************************************************************************

REM New rooms for the player:
REM   RESEARCH - when four basic rooms are built
REM New creatures for the player:
REM   SORCEROR - when RESEARCH is built
REM New powers for the player:
REM   POWER_SPEED - when researched

SET_GENERATE_SPEED(400)

MAX_CREATURES(PLAYER0,8)

START_MONEY(PLAYER0,3000)

ADD_CREATURE_TO_POOL(BUG,10)
ADD_CREATURE_TO_POOL(FLY,10)
ADD_CREATURE_TO_POOL(DEMONSPAWN,20)
ADD_CREATURE_TO_POOL(SORCEROR,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)
SET_CREATURE_MAX_LEVEL(PLAYER_GOOD,ARCHER,2)

SET_CREATURE_MAX_LEVEL(PLAYER0,DEMONSPAWN,10)

SET_CREATURE_STRENGTH(KNIGHT,70)
SET_CREATURE_ARMOUR(KNIGHT,80)

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

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

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

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

CREATE_PARTY(DWARVES)
    ADD_TO_PARTY(DWARVES,DWARFA,1,200,ATTACK_ENEMIES,0)
    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)

CREATE_PARTY(LANDLORD)
    ADD_TO_PARTY(LANDLORD,ARCHER,1,200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(LANDLORD,KNIGHT,1,2000,ATTACK_ENEMIES,0)

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

REM "Build a dungeon with a treasure room, a lair, a hatchery and a training room. Make sure all rooms are at least 9 blocks in size."
DISPLAY_OBJECTIVE(34,PLAYER0)

IF(PLAYER0,TREASURE >= 9)
	SET_FLAG(PLAYER0,FLAG0,1)
ENDIF

IF(PLAYER0,LAIR >= 9)
	SET_FLAG(PLAYER0,FLAG1,1)
ENDIF

IF(PLAYER0,GARDEN >= 9)
	SET_FLAG(PLAYER0,FLAG2,1)
ENDIF

IF(PLAYER0,TRAINING >= 9)
	SET_FLAG(PLAYER0,FLAG3,1)
ENDIF

IF(PLAYER0,ENTRANCE > 0)
	SET_FLAG(PLAYER0,FLAG4,1)
ENDIF

IF(PLAYER0,FLAG0 == 1)
	IF(PLAYER0,FLAG1 == 1)
		IF(PLAYER0,FLAG2 == 1)
			IF(PLAYER0,FLAG3 == 1)
				IF(PLAYER0,FLAG4 == 1)
REM					"You can now build a research room. Lay one down, making sure that it is also at least 9 blocks in size."
					DISPLAY_OBJECTIVE(35,PLAYER0)
					ROOM_AVAILABLE(PLAYER0,RESEARCH,1,1)
					TUTORIAL_FLASH_BUTTON(9,-1)
					SET_FLAG(PLAYER0,FLAG6,1)
				ENDIF
			ENDIF
		ENDIF
	ENDIF
ENDIF

IF(PLAYER0, FLAG6 == 0)
	IF(PLAYER0,GAME_TURN > 12000)
		IF(PLAYER0,TREASURE > 0)
			IF(PLAYER0,LAIR > 0)
				IF(PLAYER0,GARDEN > 0)
					IF(PLAYER0,TRAINING > 0)
						IF(PLAYER0,ENTRANCE > 0)
REM							"You can now build a research room. Lay one down, making sure that it is also at least 9 blocks in size."
							DISPLAY_OBJECTIVE(35,PLAYER0)
							ROOM_AVAILABLE(PLAYER0,RESEARCH,1,1)
							TUTORIAL_FLASH_BUTTON(9,-1)
						ENDIF
					ENDIF
				ENDIF
			ENDIF
		ENDIF
	ENDIF
ENDIF

IF(PLAYER0,RESEARCH > 0)
REM	"The new research room will attract creatures that like to research spells and new rooms, like sorcerors."
	DISPLAY_INFORMATION(36)
	SET_TIMER(PLAYER0,TIMER6)
ENDIF

IF(PLAYER0,RESEARCH >= 9)
	IF(PLAYER0,FLAG7 == 0)
		SET_FLAG(PLAYER0,FLAG7,1)
	ENDIF
ENDIF

IF(PLAYER0,TIMER6 > 6000)
	IF(PLAYER0,FLAG7 == 0)
		SET_FLAG(PLAYER0,FLAG7,1)
	ENDIF
ENDIF

IF(PLAYER0,FLAG7 == 1)
	SET_FLAG(PLAYER0,FLAG5,1)
REM	"Well done. You can now drop most creatures in here to research. However, sorcerors make the best researchers."
	DISPLAY_OBJECTIVE(37,PLAYER0)
	MAX_CREATURES(PLAYER0,12)
	CREATURE_AVAILABLE(PLAYER0,BUG,1,0)
	CREATURE_AVAILABLE(PLAYER0,FLY,1,0)
	CREATURE_AVAILABLE(PLAYER0,DEMONSPAWN,1,0)
	CREATURE_AVAILABLE(PLAYER0,SORCEROR,1,1)
ENDIF

IF(PLAYER0,TOTAL_CREATURES >= 10)
	SET_FLAG(PLAYER1,FLAG0,1)
ENDIF

IF(PLAYER0,SORCEROR > 0)
REM	"A sorceror has joined you, attracted to your dungeon by the research room. They make excellent researchers and once trained, superb long range fighters."
	DISPLAY_OBJECTIVE(38,PLAYER0)
	CREATURE_AVAILABLE(PLAYER0,BUG,1,1)
	CREATURE_AVAILABLE(PLAYER0,FLY,1,1)
	CREATURE_AVAILABLE(PLAYER0,DEMONSPAWN,1,1)
	CREATURE_AVAILABLE(PLAYER0,SORCEROR,1,1)
	SET_FLAG(PLAYER2,FLAG0,1)
ENDIF

IF(PLAYER2,FLAG0 == 1)
	SET_TIMER(PLAYER0,TIMER2)
	IF(PLAYER0,TIMER2 >= 5000)
		IF(PLAYER_GOOD,FLAG0 == 0)
			SET_FLAG(PLAYER_GOOD,FLAG1,1)
			ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,THIEVES,-1,DUNGEON,0,1,500)
			ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,DWARVES,-1,DUNGEON,0,1,2000)
			IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
REM				"The first wave of attackers lie dead. Prepare for the next assault."
				DISPLAY_OBJECTIVE(39,PLAYER0)
				SET_TIMER(PLAYER0,TIMER3)
				IF(PLAYER0,TIMER3 > 2000)
					IF(PLAYER0,TOTAL_CREATURES >= 10)
						ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,ELITE,-1,DUNGEON,0,1,500)
						ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,LANDLORD,-1,DUNGEON,0,1,500)
						IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
REM							"Congratulations, the bloody carcasses of the fallen heroes lie with expressions of writhing agony at your creatures' feet. Press space to go on to the next land."
							DISPLAY_OBJECTIVE(40,PLAYER0)
							WIN_GAME
						ENDIF
					ENDIF
				ENDIF
			ENDIF
		ENDIF
	ENDIF
ENDIF

IF_ACTION_POINT(1,PLAYER0)
	IF(PLAYER_GOOD,FLAG1 == 0)
		SET_FLAG(PLAYER_GOOD,FLAG0,1)
		IF(PLAYER0,TOTAL_CREATURES >= 10)
			ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,THIEVES,-1,DUNGEON,0,1,500)
			ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,DWARVES,-1,DUNGEON,0,1,2000)
			IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
				DISPLAY_OBJECTIVE(41,PLAYER0)
				SET_TIMER(PLAYER0,TIMER3)
				IF(PLAYER0,TIMER3 > 2000)
					IF(PLAYER0,TOTAL_CREATURES >= 10)
						ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,ELITE,-1,DUNGEON,0,1,500)
						ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,LANDLORD,-1,DUNGEON,0,1,500)
						DISPLAY_INFORMATION(42)
						IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
							DISPLAY_OBJECTIVE(40,PLAYER0)
							WIN_GAME
						ENDIF
					ENDIF
				ENDIF
			ENDIF
		ENDIF
	ENDIF
ENDIF

IF(PLAYER0,TIMER2 >= 3750)
REM	"Be patient, heroes are soon to come. Make sure your creatures are trained. (Maybe try training a sorceror!)."
	DISPLAY_OBJECTIVE(43,PLAYER0)
ENDIF

IF_AVAILABLE(PLAYER0,POWER_SPEED == 1)
REM	"You have researched the speed up spell. Cast it on creatures to increase their speed."
	DISPLAY_INFORMATION(44)
ENDIF
