REM ****************************************************************************
REM  Campaigns Consolidation Project for KeeperFX strategy game.
REM ****************************************************************************
REM  Script for Level Waterdream Warm
REM  Campaign: New game plus
REM  Authors:  based on Bullfrog script
REM            KeeperFX CCP Team
REM            Loobinex
REM  Date:     17 Dec 1996 - 14 Mar 2015
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   RESEARCH
REM New creatures for the player:
REM   SORCEROR
REM New powers for the player:
REM   POWER_SPEED

REM Flags used:
REM   PLAYER_GOOD,FLAG0 - Sending waves of heroes; 0-not ready; 1-ready to start sending.
REM Timers used:
REM   PLAYER0,TIMER0 - First attack timer
REM   PLAYER0,TIMER1 - Delay after first attack
REM   PLAYER0,TIMER2 - Second attack timer
REM   PLAYER0,TIMER3 - Final attack timer (also counts delay after 2nd attack)
REM   PLAYER0,TIMER4 - Delay after final attack

SET_GENERATE_SPEED(400)

START_MONEY(PLAYER0,3000)

MAX_CREATURES(PLAYER0,12)

ADD_CREATURE_TO_POOL(BUG,10)
ADD_CREATURE_TO_POOL(FLY,2)
ADD_CREATURE_TO_POOL(DEMONSPAWN,20)
ADD_CREATURE_TO_POOL(SORCEROR,10)

SET_CREATURE_MAX_LEVEL(PLAYER0,DEMONSPAWN,10)

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

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,1)

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_DUNGEON_HEART,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)
	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,2,200,DEFEND_PARTY,0)
	ADD_TO_PARTY(LANDLORD,KNIGHT,2,2000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(LANDLORD,DWARFA,2,200,DEFEND_PARTY,0)
	ADD_TO_PARTY(LANDLORD,DWARFA,2,200,DEFEND_PARTY,0)

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

SET_TIMER(PLAYER0,TIMER0)

REM "Is that Imp playing football with a decapitated head? Stay alert, Keeper."
DISPLAY_OBJECTIVE(42,ALL_PLAYERS)


IF(PLAYER0,TIMER0 >= 5000)
		SET_FLAG(PLAYER_GOOD,FLAG0,1)
ENDIF

REM If a player sticks his nose where he shouldn't, commence first attack faster
IF_ACTION_POINT(1,PLAYER0)
	SET_FLAG(PLAYER_GOOD,FLAG0,1)
ENDIF

REM If we're signalled for first attack - do it
IF(PLAYER_GOOD,FLAG0 >= 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)
	SET_TIMER(PLAYER0,TIMER1)
ENDIF

IF(PLAYER0,TIMER1 > 100)
	IF_CONTROLS(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,TIMER2)
	ENDIF
ENDIF

REM Commence the 2nd attack some time after first wave is wiped out
IF(PLAYER0,TIMER2 > 1000)
	IF_CONTROLS(PLAYER0,TOTAL_CREATURES >= 8)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,THIEVES,-1,2)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DWARVES,-1,2)
		SET_TIMER(PLAYER0,TIMER3)
	ENDIF
ENDIF

IF(PLAYER0,TIMER3 > 100)
	IF_CONTROLS(PLAYER_GOOD,TOTAL_CREATURES <= 0)
		REM "All is quiet again. Use this time to ready yourself for the next attacks. The enemy is only regrouping. It is not yet defeated."
		DISPLAY_OBJECTIVE(41,ALL_PLAYERS)
	ENDIF
ENDIF

REM For final attack, count the delay without waiting for a previous wave to be killed
IF(PLAYER0,TIMER3 > 1500)
	IF_CONTROLS(PLAYER0,TOTAL_CREATURES >= 8)
		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)
		SET_TIMER(PLAYER0,TIMER4)
	ENDIF
ENDIF

REM When all are dead, win the game
IF(PLAYER0,TIMER4 > 100)
	IF_CONTROLS(PLAYER_GOOD,TOTAL_CREATURES <= 0)
		REM "Congratulations, the bloody carcasses of the fallen heroes lie with expressions of writhing agony at your creatures' feet..."
		DISPLAY_OBJECTIVE(40,ALL_PLAYERS)
		WIN_GAME
	ENDIF
ENDIF

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