REM ****************************************************************************
REM  Free Play levels - KeeperFX
REM ****************************************************************************
REM  Script for Level 456 - Shores of Battle
REM  Author:  Loobinex
REM  Date:    2017-09-13
REM		modified to use a pot file for messages by dayokay Jan2021
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 Brief: Player needs to use the rival keepers to get powerful, but he can't reach them. Claim the Destroy Walls spell from them to get access to the heroes and trigger final battles.

LEVEL_VERSION(1)
SET_GENERATE_SPEED(850)

COMPUTER_PLAYER(PLAYER1,0)
COMPUTER_PLAYER(PLAYER2,0)
COMPUTER_PLAYER(PLAYER3,0)
COMPUTER_PLAYER(PLAYER5,ROAMING)

ALLY_PLAYERS(PLAYER1,PLAYER2,1)
ALLY_PLAYERS(PLAYER1,PLAYER3,1)
ALLY_PLAYERS(PLAYER2,PLAYER3,1)
ALLY_PLAYERS(PLAYER1,PLAYER_GOOD,1)

START_MONEY(PLAYER0,15000)
START_MONEY(PLAYER1,40000)
START_MONEY(PLAYER2,50000)
START_MONEY(PLAYER3,40000)

MAX_CREATURES(PLAYER0,25)
MAX_CREATURES(PLAYER1,15)
MAX_CREATURES(PLAYER2,20)
MAX_CREATURES(PLAYER3,25)

SET_CREATURE_TENDENCIES(PLAYER2,IMPRISON,1)
SET_CREATURE_TENDENCIES(PLAYER1,FLEE,1)
SET_CREATURE_TENDENCIES(PLAYER2,FLEE,1)
SET_CREATURE_TENDENCIES(PLAYER3,FLEE,1)

RESEARCH_ORDER(ALL_PLAYERS,MAGIC,POWER_IMP,1000)
RESEARCH_ORDER(ALL_PLAYERS,ROOM,TREASURE,1000)
RESEARCH_ORDER(ALL_PLAYERS,ROOM,LAIR,1000)
RESEARCH_ORDER(ALL_PLAYERS,ROOM,GARDEN,1000)
RESEARCH_ORDER(ALL_PLAYERS,ROOM,TRAINING,1000)
RESEARCH_ORDER(ALL_PLAYERS,ROOM,RESEARCH,1000)
RESEARCH_ORDER(ALL_PLAYERS,ROOM,BRIDGE,4600)
RESEARCH_ORDER(ALL_PLAYERS,MAGIC,POWER_SPEED,5700)
RESEARCH_ORDER(ALL_PLAYERS,MAGIC,POWER_OBEY,6000)
RESEARCH_ORDER(ALL_PLAYERS,ROOM,GUARD_POST,6700)
RESEARCH_ORDER(ALL_PLAYERS,ROOM,BARRACKS,8000)
RESEARCH_ORDER(ALL_PLAYERS,MAGIC,POWER_CALL_TO_ARMS,7400)
RESEARCH_ORDER(ALL_PLAYERS,MAGIC,POWER_CONCEAL,9400)
RESEARCH_ORDER(ALL_PLAYERS,MAGIC,POWER_HOLD_AUDIENCE,9000)
RESEARCH_ORDER(ALL_PLAYERS,ROOM,WORKSHOP,9000)
RESEARCH_ORDER(ALL_PLAYERS,ROOM,PRISON,20000)
RESEARCH_ORDER(ALL_PLAYERS,MAGIC,POWER_SIGHT,15800)
RESEARCH_ORDER(ALL_PLAYERS,MAGIC,POWER_CAVE_IN,15000)
RESEARCH_ORDER(ALL_PLAYERS,MAGIC,POWER_LIGHTNING,25000)
RESEARCH_ORDER(ALL_PLAYERS,ROOM,GRAVEYARD,25000)
RESEARCH_ORDER(ALL_PLAYERS,MAGIC,POWER_PROTECT,15000)
RESEARCH_ORDER(ALL_PLAYERS,ROOM,SCAVENGER,27500)
RESEARCH_ORDER(ALL_PLAYERS,MAGIC,POWER_CHICKEN,20000)
RESEARCH_ORDER(ALL_PLAYERS,ROOM,TORTURE,25000)
RESEARCH_ORDER(ALL_PLAYERS,MAGIC,POWER_HEAL_CREATURE,14000)
RESEARCH_ORDER(ALL_PLAYERS,MAGIC,POWER_DISEASE,20000)
RESEARCH_ORDER(ALL_PLAYERS,ROOM,TEMPLE,25000)
RESEARCH_ORDER(ALL_PLAYERS,MAGIC,POWER_DESTROY_WALLS,75000)
RESEARCH_ORDER(ALL_PLAYERS,MAGIC,POWER_ARMAGEDDON,100000)

REM ****************************************************************************
REM Flags used:
REM  PLAYER0,FLAG1	- description
REM						1: Keepers destroyed
REM						2: Hero fortress breached
REM						3: Heroes break out of own fortress
REM  PLAYER0,FLAG2		1: Landlord spawned

REM Timers used:
REM   PLAYER0,TIMER0 	- Main timer, runs when player reaches portal limit.
REM   PLAYER1,TIMER1 	- Counts how long blue has been defeated.
REM   PLAYER2,TIMER2 	- Counts how long green has been defeated.
REM   PLAYER3,TIMER3 	- Counts how long yellow has been defeated.
REM   PLAYER_GOOD,TIMER4 	- Counts how long all keepers are defeated.

REM Action Points and Hero Gates
REM Action Point 1 - Corner behind Player 0
REM Action Point 2 - Corner behind Player 1
REM Action Point 3 - Corner behind Player 2
REM Action Point 4 - Corner behind Player 3
REM Action Point 5 - Hero heart room
REM Action Point 6 - Tunneler exit west
REM Action Point 7 - Hero front door
REM Action Point 8 - Tentacle pond
REM Action Point 9 - South lava entrance
REM Action Point 10- In front of Hero front door
REM Action Point 11- Player portal
REM Hero Gate 1~4  - Hero heart rooms
REM Hero Gate 5~6  - Outside hero heart room


REM ****************************************************************************
REM Initial availability
REM ****************************************************************************

ROOM_AVAILABLE(ALL_PLAYERS,TORTURE,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,BRIDGE,0,0)
ROOM_AVAILABLE(ALL_PLAYERS,SCAVENGER,0,0)
ROOM_AVAILABLE(ALL_PLAYERS,GRAVEYARD,0,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)
ROOM_AVAILABLE(PLAYER0,WORKSHOP,1,0)
ROOM_AVAILABLE(PLAYER0,BARRACKS,1,0)
ROOM_AVAILABLE(PLAYER0,GUARD_POST,1,0)
ROOM_AVAILABLE(PLAYER0,TORTURE,1,0)
ROOM_AVAILABLE(PLAYER0,TEMPLE,1,0)
ROOM_AVAILABLE(PLAYER0,PRISON,1,0)
ROOM_AVAILABLE(PLAYER0,GRAVEYARD,4,0)

ROOM_AVAILABLE(PLAYER1,LAIR,1,1)

MAGIC_AVAILABLE(PLAYER0,POWER_CALL_TO_ARMS,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_IMP,1,1)

MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HAND,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SLAP,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SIGHT,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HEAL_CREATURE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SPEED,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_LIGHTNING,0,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_PROTECT,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_CONCEAL,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_DISEASE,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_CAVE_IN,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CHICKEN,1,0)
MAGIC_AVAILABLE(PLAYER2,POWER_DESTROY_WALLS,1,0)
MAGIC_AVAILABLE(PLAYER3,POWER_DESTROY_WALLS,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_HOLD_AUDIENCE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_ARMAGEDDON,0,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_OBEY,0,0)

ADD_CREATURE_TO_POOL(FLY,5)
ADD_CREATURE_TO_POOL(BUG,6)
ADD_CREATURE_TO_POOL(SPIDER,2)
ADD_CREATURE_TO_POOL(TROLL,15)
ADD_CREATURE_TO_POOL(ORC,20)
ADD_CREATURE_TO_POOL(SORCEROR,20)
ADD_CREATURE_TO_POOL(DRUID,20)
ADD_CREATURE_TO_POOL(DEMONSPAWN,30)
ADD_CREATURE_TO_POOL(DRAGON,20)
ADD_CREATURE_TO_POOL(BILE_DEMON,15)
ADD_CREATURE_TO_POOL(DARK_MISTRESS,10)
ADD_CREATURE_TO_POOL(HELL_HOUND,0)
ADD_CREATURE_TO_POOL(TENTACLE,0)

CREATURE_AVAILABLE(ALL_PLAYERS,FLY,1,0)

CREATURE_AVAILABLE(PLAYER0,SPIDER,1,0)
CREATURE_AVAILABLE(PLAYER0,ORC,1,0)
CREATURE_AVAILABLE(PLAYER0,SORCEROR,1,0)
CREATURE_AVAILABLE(PLAYER0,DRUID,1,0)
CREATURE_AVAILABLE(PLAYER0,DEMONSPAWN,1,0)
CREATURE_AVAILABLE(PLAYER0,HELL_HOUND,1,1)
CREATURE_AVAILABLE(PLAYER0,TENTACLE,1,0)

CREATURE_AVAILABLE(PLAYER1,DRAGON,1,15)
CREATURE_AVAILABLE(PLAYER1,DARK_MISTRESS,1,7)
CREATURE_AVAILABLE(PLAYER1,BUG,1,0)

CREATURE_AVAILABLE(PLAYER2,BILE_DEMON,1,15)
CREATURE_AVAILABLE(PLAYER2,BUG,1,0)

CREATURE_AVAILABLE(PLAYER3,TROLL,1,15)
CREATURE_AVAILABLE(PLAYER3,ORC,1,15)
CREATURE_AVAILABLE(PLAYER3,BUG,1,0)

DOOR_AVAILABLE(ALL_PLAYERS,WOOD,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,BRACED,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,STEEL,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,MAGIC,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,ALARM,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,POISON_GAS,1,0)
TRAP_AVAILABLE(PLAYER3,LIGHTNING,1,0)
TRAP_AVAILABLE(PLAYER3,WORD_OF_POWER,1,0)
TRAP_AVAILABLE(PLAYER3,BOULDER,1,0)

REM ****************************************************************************
REM Additional availability
REM ****************************************************************************

IF(PLAYER0,GRAVEYARD >= 1)
	TUTORIAL_FLASH_BUTTON(15,100)
ENDIF

REM Computer players don't start digging until sight is researched or player draws first blood.
IF_AVAILABLE(PLAYER0,POWER_SIGHT == 1)
	MAGIC_AVAILABLE(ALL_PLAYERS,POWER_IMP,1,1)
ENDIF
IF(PLAYER0,BATTLES_WON >= 1)
	MAGIC_AVAILABLE(ALL_PLAYERS,POWER_IMP,1,1)
ENDIF

IF(PLAYER3,DUNGEON_DESTROYED == 1)
	TRAP_AVAILABLE(PLAYER0,LIGHTNING,1,0)
	TRAP_AVAILABLE(PLAYER0,WORD_OF_POWER,1,0)
ENDIF

REM ****************************************************************************
REM Hero Parties
REM ****************************************************************************

CREATE_PARTY(PrisonFood)
	ADD_TO_PARTY(PrisonFood,DWARFA,4,1000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(PrisonFood,DWARFA,4,1000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(PrisonFood,DWARFA,2,3000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(PrisonFood,ARCHER,2,3000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(PrisonFood,ARCHER,4,1000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(PrisonFood,ARCHER,4,1000,ATTACK_ENEMIES,0)

CREATE_PARTY(scouts)
	ADD_TO_PARTY(scouts,Giant,6,2000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(scouts,BARBARIAN,5,1500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(scouts,BARBARIAN,5,1500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(scouts,ARCHER,5,1000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(scouts,MONK,5,1500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(scouts,MONK,5,1500,ATTACK_ENEMIES,0)
	
CREATE_PARTY(blue)
	ADD_TO_PARTY(blue,SAMURAI,7,2400,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(blue,MONK,6,2000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(blue,MONK,6,2000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(blue,FAIRY,6,2000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(blue,BARBARIAN,5,1500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(blue,BARBARIAN,5,1500,ATTACK_ENEMIES,0)
	
CREATE_PARTY(thieves)
	ADD_TO_PARTY(thieves,THIEF,8,8000,STEAL_GOLD,0)
	ADD_TO_PARTY(thieves,THIEF,7,7000,STEAL_GOLD,0)
	ADD_TO_PARTY(thieves,THIEF,6,6000,STEAL_GOLD,0)
	ADD_TO_PARTY(thieves,THIEF,5,5000,STEAL_GOLD,0)
	
CREATE_PARTY(dday)
	ADD_TO_PARTY(dday,BARBARIAN,8,2000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(dday,ARCHER,7,2000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(dday,ARCHER,6,2000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(dday,GIANT,6,2000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(dday,BARBARIAN,5,1000,ATTACK_ENEMIES,0)
	
CREATE_PARTY(revenge)
	ADD_TO_PARTY(revenge,SAMURAI,9,2000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(revenge,WIZARD,8,2000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(revenge,WITCH,8,2000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(revenge,FAIRY,8,2000,ATTACK_ENEMIES,0)
	
CREATE_PARTY(landlord)
	ADD_TO_PARTY(landlord,KNIGHT,10,5000,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(landlord,SAMURAI,9,3000,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(landlord,SAMURAI,9,3000,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(landlord,WIZARD,9,3000,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(landlord,TIME_MAGE,9,3000,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(landlord,ARCHER,8,2000,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(landlord,GIANT,8,2000,ATTACK_DUNGEON_HEART,0)
	
CREATE_PARTY(hounds)
	ADD_TO_PARTY(hounds,HELL_HOUND,1,0,DEFEND_PARTY,0)
	ADD_TO_PARTY(hounds,HELL_HOUND,1,0,DEFEND_PARTY,0)
	
REM ****************************************************************************
REM Level starts here
REM ****************************************************************************

REM	"An ancient truce, the land divided. Kill them all, let none survive. And the heroes? We'll cross that bridge when we come to it."
DISPLAY_OBJECTIVE(74,ALL_PLAYERS)

REM Player gets a pair of hounds.
IF(PLAYER0,TOTAL_CREATURES >= 15)
	ADD_PARTY_TO_LEVEL(PLAYER0,hounds,11,1)
ENDIF

REM As soon as the player has access to a prison he and yellow are attacked from behind.
IF_AVAILABLE(PLAYER0,PRISON == 1)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,PrisonFood,1,DUNGEON,0,4,400)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,PrisonFood,3,DUNGEON,0,4,400)
ENDIF

REM Timer starts to run when player has maxed his portal limit. Spawns a tunneler party to dig path from Heroes to Player dungeon.
IF(PLAYER0,TOTAL_CREATURES >= 25)
	REM	"As the wise man looks for a bridge the fool crosses the river."
	DISPLAY_INFORMATION(75,ALL_PLAYERS)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,scouts,10,DUNGEON,0,6,600)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PrisonFood,3,1)
	SET_TIMER(PLAYER0,TIMER0)
ENDIF

REM When player is on a roll, his enemies will get more units.
IF(PLAYER0,BATTLES_WON >= 30)
	MAX_CREATURES(PLAYER1,25)
	MAX_CREATURES(PLAYER2,25)
	MAX_CREATURES(PLAYER3,35)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,PrisonFood,3,DUNGEON,0,4,400)
ENDIF

REM Enable claiming north-west corner when blue is destroyed. Tunneler will clear white wall blocking path. Also new tentacles added.
IF(PLAYER1,DUNGEON_DESTROYED == 1)
	ADD_CREATURE_TO_LEVEL(PLAYER5,TENTACLE,8,3,5,500)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PrisonFood,3,2)
	SET_TIMER(PLAYER1,TIMER1)
ENDIF
IF(PLAYER1,TIMER1 >= 3000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,PrisonFood,6,DUNGEON,0,4,400)
ENDIF

REM Ten minutes after blue is defeated, spawn a party from behind blue dungeon.
IF(PLAYER1,TIMER1 >= 12000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,Blue,2,DUNGEON,0,6,600)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PrisonFood,3,1)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,TENTACLE,8,3,5,500)
ENDIF

REM Feed green some more creatures and harrass the player when green is maxed out.
IF(PLAYER2,TOTAL_CREATURES >= 25)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,3,6,6,666)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,-5,3,6,666)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,-6,3,6,666)
ENDIF

REM	Five minutes after yellow is destroyed thieves spawn to steal/bring gold.
IF(PLAYER3,DUNGEON_DESTROYED == 1)
	SET_TIMER(PLAYER3,TIMER3)
ENDIF
IF(PLAYER3,TIMER3 >= 6000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,thieves,-5,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,thieves,-6,1)
ENDIF

REM If player tries to take on heroes before keepers, let him know it is futile.
IF(PLAYER0,FLAG1 <= 0)
	IF_ACTION_POINT(10,PLAYER0)
		REM	"Think of these heroes as dessert. Finish your main course first: Blue, Yellow and Green. After that, turn the Lord of the Land into whipped cream."
		DISPLAY_OBJECTIVE(76,10)
	ENDIF
ENDIF	

REM If the rival keepers are destroyed the player gets the bridge to claim Destroy_Walls and fight the heroes.
IF(PLAYER1,DUNGEON_DESTROYED == 1)
	IF(PLAYER2,DUNGEON_DESTROYED == 1)
		IF(PLAYER3,DUNGEON_DESTROYED == 1)
			REM	"With your rivals destroyed, plunder their dungeons and breach the center."
			DISPLAY_OBJECTIVE(77,PLAYER_GOOD)
			ROOM_AVAILABLE(PLAYER0,BRIDGE,1,1)
			TUTORIAL_FLASH_BUTTON(18,100)
			SET_TIMER(PLAYER_GOOD,TIMER4)
			SET_FLAG(PLAYER0,FLAG1,1)
		ENDIF
	ENDIF
ENDIF

REM The player has breached the white fortress. Final offensive commenses.
IF_ACTION_POINT(5,PLAYER0)
	SET_FLAG(PLAYER0,FLAG1,2)
ENDIF
IF(PLAYER0,FLAG1 >= 2)
	REM	"A bridge of blood and havoc stretches from the homes of heroes to the unforgiving nightmare emerging anew. Leave none alive."
	DISPLAY_OBJECTIVE(78,PLAYER_GOOD)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,dday,-1,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,dday,-2,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,dday,-3,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,dday,-4,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,revenge,1,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,revenge,2,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,revenge,3,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,revenge,4,1)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,TUNNELLER,4,3,7,500)
ENDIF
IF(PLAYER0,FLAG1 >= 2)
	IF_CONTROLS(PLAYER_GOOD,BARBARIAN <= 0)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,FAIRY,-1,2,8,1500)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,FAIRY,-2,2,8,1500)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,FAIRY,-3,2,8,1500)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,FAIRY,-4,2,8,1500)
		IF_CONTROLS(PLAYER_GOOD,FAIRY <= 0)
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,landlord,-5,1)
			SET_FLAG(PLAYER0,FLAG2,1)
		ENDIF
	ENDIF
ENDIF

REM If player takes too long to take on the heroes, persuade him.
IF(PLAYER0,FLAG1 <= 1)
	IF(PLAYER_GOOD,TIMER4 >= 8000)
		REM	"The heroes know conflict is imminent, destroy them now before they manage to take the offensive with a larger force."
		DISPLAY_OBJECTIVE(79,PLAYER_GOOD)
	ENDIF
	IF(PLAYER_GOOD,TIMER4 >= 10000)
		REM	"It's now or never. Kill or be killed."
		DISPLAY_OBJECTIVE(80,PLAYER_GOOD)
		MAGIC_AVAILABLE(PLAYER0,POWER_DESTROY_WALLS,1,1)
	ENDIF
	IF(PLAYER_GOOD,TIMER4 >= 12000)
		REM	"Here they come!"
		DISPLAY_OBJECTIVE(81,PLAYER_GOOD)
	ENDIF
	IF(PLAYER_GOOD,TIMER4 >= 12200)
		SET_FLAG(PLAYER0,FLAG1,3)
	ENDIF
ENDIF

REM If player waited too long, spawn additional creatures and parties to break out.
IF(PLAYER0,FLAG1 >= 3)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,Revenge,-1,DUNGEON,0,8,800)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,Revenge,-2,DUNGEON,0,8,800)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,Revenge,-3,DUNGEON,0,8,800)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,Revenge,-4,DUNGEON,0,8,800)
ENDIF

REM ****************************************************************************
REM Win game
REM ****************************************************************************

IF(PLAYER0,ALL_DUNGEONS_DESTROYED >= 1)
	IF_CONTROLS(PLAYER_GOOD,TOTAL_CREATURES <= 0)
		IF(PLAYER0,FLAG2 >= 1)
			REM	"I give your performance 2 out of 5 spleens. But I guess it's the result that counts. Victory!"
			DISPLAY_OBJECTIVE(82,ALL_PLAYERS)
			WIN_GAME
		ENDIF
	ENDIF
ENDIF

REM ****************************************************************************
REM End of file
REM ****************************************************************************
