REM ****************************************************************************
REM  Campaigns Consolidation Project for KeeperFX strategy game.
REM ****************************************************************************
REM  Script for Level Hearth
REM  Campaign: DK Original
REM  Authors:  based on Bullfrog script
REM            KeeperFX CCP Team
REM  Date:     17 Dec 1996 - 07 Sep 2014
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 powers for the player:
REM   POWER_CHICKEN - if the player can reach it
REM New manufacture for the player:
REM   TRAP_ALARM - not really new; anyway originally wasn't available
REM Removed:
REM   DOOR_MAGIC - WORKSHOP isn't big enough to build one and the player doesn't have time to put one
REM   TRAP_WORD_OF_POWER - WORKSHOP isn't big enough and the trap is too powerful
REM   TRAP_LAVA - WORKSHOP isn't big enough
REM Comment:
REM   Not much new added here, because player is quite busy during this level
REM   Chaz,Matt,Louise,Nick,Mum and various others - HELLO

REM Flags used:
REM   PLAYER_GOOD,FLAG0 - Continuous spawning of parties FIRST-FOURTH; 0-spawn; 1-stop spawning. 
REM Timers used:
REM   PLAYER_GOOD,TIMER1 - Counter for continuous spawning of party FIRST
REM   PLAYER_GOOD,TIMER2 - Counter for continuous spawning of party SECOND
REM   PLAYER_GOOD,TIMER3 - Counter for continuous spawning of party THIRD
REM   PLAYER_GOOD,TIMER4 - Counter for continuous spawning of party FOURTH
REM   PLAYER0,TIMER1 - Starts counting after first wave of heroes (parties FIRST-FOURTH) are killed
REM   PLAYER0,TIMER2 - Starts counting after Lord of the Land appearance

SET_GENERATE_SPEED(400)

START_MONEY(PLAYER0,10000)

MAX_CREATURES(PLAYER0,30)

ADD_CREATURE_TO_POOL(DEMONSPAWN,20)
ADD_CREATURE_TO_POOL(DARK_MISTRESS,20)
ADD_CREATURE_TO_POOL(SORCEROR,30)
ADD_CREATURE_TO_POOL(TROLL,20)
ADD_CREATURE_TO_POOL(BILE_DEMON,10)
ADD_CREATURE_TO_POOL(HELL_HOUND,30)
ADD_CREATURE_TO_POOL(DRAGON,15)
ADD_CREATURE_TO_POOL(ORC,15)

REM	Creature availability
CREATURE_AVAILABLE(PLAYER0,TROLL,1,0)
CREATURE_AVAILABLE(PLAYER0,DEMONSPAWN,1,0)
CREATURE_AVAILABLE(PLAYER0,DARK_MISTRESS,1,0)
CREATURE_AVAILABLE(PLAYER0,SORCEROR,1,0)
CREATURE_AVAILABLE(PLAYER0,BILE_DEMON,1,0)
CREATURE_AVAILABLE(PLAYER0,HELL_HOUND,1,0)
CREATURE_AVAILABLE(PLAYER0,DRAGON,1,0)
CREATURE_AVAILABLE(PLAYER0,ORC,1,0)
	
REM	Room availability
ROOM_AVAILABLE(ALL_PLAYERS,TREASURE,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,LAIR,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,GARDEN,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,TRAINING,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,RESEARCH,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,WORKSHOP,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,BARRACKS,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,GUARD_POST,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,BRIDGE,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,PRISON,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,SCAVENGER,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,TORTURE,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,TEMPLE,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,GRAVEYARD,1,0)

REM	Spells availability
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HAND,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_IMP,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SLAP,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SIGHT,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CALL_TO_ARMS,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HEAL_CREATURE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SPEED,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_LIGHTNING,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_PROTECT,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CONCEAL,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_DISEASE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CAVE_IN,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CHICKEN,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HOLD_AUDIENCE,1,0)

REM	Doors and traps availability
DOOR_AVAILABLE(ALL_PLAYERS,BRACED,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,POISON_GAS,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,STEEL,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,BOULDER,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,LIGHTNING,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,ALARM,1,0)

CREATE_PARTY(FIRST)
	ADD_TO_PARTY(FIRST,BARBARIAN,2,1500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(FIRST,GIANT,2,1500,ATTACK_ENEMIES,0)

CREATE_PARTY(SECOND)
	ADD_TO_PARTY(SECOND,MONK,3,1500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(SECOND,MONK,3,1500,ATTACK_ENEMIES,0)

CREATE_PARTY(THIRD)
	ADD_TO_PARTY(THIRD,ARCHER,4,1500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(THIRD,BARBARIAN,4,1500,ATTACK_ENEMIES,0)

CREATE_PARTY(FOURTH)
	ADD_TO_PARTY(FOURTH,WIZARD,4,1500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(FOURTH,GIANT,4,1500,ATTACK_ENEMIES,0)

CREATE_PARTY(FIFTH)
	ADD_TO_PARTY(FIFTH,WIZARD,5,1500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(FIFTH,WIZARD,5,1750,ATTACK_ENEMIES,0)

CREATE_PARTY(SIXTH)
	ADD_TO_PARTY(SIXTH,MONK,6,1500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(SIXTH,MONK,6,1500,ATTACK_ENEMIES,0)

CREATE_PARTY(SEVENTH)
	ADD_TO_PARTY(SEVENTH,FAIRY,6,1500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(SEVENTH,FAIRY,6,1500,ATTACK_ENEMIES,0)

CREATE_PARTY(EIGHTH)
	ADD_TO_PARTY(EIGHTH,WITCH,8,1500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(EIGHTH,WITCH,8,1500,ATTACK_ENEMIES,0)

CREATE_PARTY(LANDLORD)
	ADD_TO_PARTY(LANDLORD,KNIGHT,6,10000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(LANDLORD,ARCHER,6,900,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(LANDLORD,BARBARIAN,6,900,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(LANDLORD,MONK,6,900,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(LANDLORD,FAIRY,8,900,ATTACK_ENEMIES,0)

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

REM "If lands had legs this one would be on its knees. Its desperate inhabitants are preparing a full scale attack on your dungeon..."
DISPLAY_OBJECTIVE(105,PLAYER0)

IF_AVAILABLE(PLAYER0,POWER_CHICKEN >= 1)
	REM "You have discovered a devastating magical power. Target it against a creature to transform a fearsome monster into a clucking chicken. Marvellous."
   	DISPLAY_INFORMATION(97,ALL_PLAYERS)
ENDIF

IF_AVAILABLE(PLAYER0,ALARM >= 1)
	REM "Your manufacturers have built an Alarm Trap. It will warn you of your enemies' approach and summon nearby creatures to deal with the intruders."
	DISPLAY_INFORMATION(98,ALL_PLAYERS)
ENDIF

REM Spawn continuously the FIRST party
IF(PLAYER_GOOD,GAME_TURN >= 1000)
	SET_TIMER(PLAYER_GOOD,TIMER1)
ENDIF

IF(PLAYER_GOOD,FLAG0 == 0)
	IF(PLAYER_GOOD,TIMER1 > 1750)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FIRST,3,1)
		NEXT_COMMAND_REUSABLE
		SET_TIMER(PLAYER_GOOD,TIMER1)
	ENDIF
ENDIF

REM Spawn continuously the SECOND party
IF(PLAYER_GOOD,GAME_TURN >= 1750)
	SET_TIMER(PLAYER_GOOD,TIMER2)
ENDIF

IF(PLAYER_GOOD,FLAG0 == 0)
	IF(PLAYER_GOOD,TIMER2 > 2250)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SECOND,1,1)
		NEXT_COMMAND_REUSABLE
		SET_TIMER(PLAYER_GOOD,TIMER2)
	ENDIF
ENDIF

REM Spawn continuously the THIRD party
IF(PLAYER_GOOD,GAME_TURN >= 2500)
	SET_TIMER(PLAYER_GOOD,TIMER3)
ENDIF

IF(PLAYER_GOOD,FLAG0 == 0)
	IF(PLAYER_GOOD,TIMER3 > 2750)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,THIRD,2,1)
		NEXT_COMMAND_REUSABLE
		SET_TIMER(PLAYER_GOOD,TIMER3)
	ENDIF
ENDIF

REM Spawn continuously the FOURTH party
IF(PLAYER_GOOD,GAME_TURN >= 3250)
	SET_TIMER(PLAYER_GOOD,TIMER4)
ENDIF

IF(PLAYER_GOOD,FLAG0 == 0)
	IF(PLAYER_GOOD,TIMER4 > 3500)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FOURTH,4,1)
		NEXT_COMMAND_REUSABLE
		SET_TIMER(PLAYER_GOOD,TIMER4)
	ENDIF
ENDIF

REM Stop spawning continous parties after a given amount of turns
IF(PLAYER_GOOD,GAME_TURN >= 13000)
	SET_FLAG(PLAYER_GOOD,FLAG0,1)
	IF_CONTROLS(PLAYER_GOOD,TOTAL_CREATURES <= 0)
		REM "Your annihilation of the first wave has met with the approval of a pack of demons from the fifth plane of hell..."
		DISPLAY_OBJECTIVE(102,PLAYER0)
		SET_TIMER(PLAYER0,TIMER1)
	ENDIF
ENDIF

REM Start a second wave
IF(PLAYER0,TIMER1 >= 3000)
	REM "The enemy are upon us. I'm just telling you in case you were having a doze."
	DISPLAY_OBJECTIVE(103,PLAYER0)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FIFTH,1,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SIXTH,2,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SEVENTH,3,1)
ENDIF

IF(PLAYER0,TIMER1 >= 5000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,EIGHTH,4,1)
ENDIF	

IF(PLAYER0,TIMER1 >= 5500)
	IF_CONTROLS(PLAYER_GOOD,TOTAL_CREATURES < 3)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,LANDLORD,1,1)
		SET_TIMER(PLAYER0,TIMER2)
	ENDIF
ENDIF	

IF(PLAYER0,TIMER2 >= 200)
	IF_CONTROLS(PLAYER_GOOD,KNIGHT <= 0)
		REM "All the heroes are dead, which is as it should be. This land and all its spoils are yours. May I suggest that you waste everything?"
		DISPLAY_OBJECTIVE(104,PLAYER0)
		WIN_GAME
	ENDIF
ENDIF	

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