REM ****************************************************************************
REM  Campaigns Consolidation Project for KeeperFX strategy game.
REM ****************************************************************************
REM  Script for DD Level Belial
REM  Campaign: Deeper Dungeons
REM  Authors:  based on Bullfrog script
REM            KeeperFX CCP Team
REM  Date:     17 Dec 1996 - 9 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)

SET_GENERATE_SPEED(500)

START_MONEY(PLAYER0,15000)

MAX_CREATURES(PLAYER0,20)

ADD_CREATURE_TO_POOL(TENTACLE,20)
ADD_CREATURE_TO_POOL(SORCEROR,20)
ADD_CREATURE_TO_POOL(BILE_DEMON,20)
ADD_CREATURE_TO_POOL(DARK_MISTRESS,20)
ADD_CREATURE_TO_POOL(DRAGON,20)
ADD_CREATURE_TO_POOL(ORC,20)
ADD_CREATURE_TO_POOL(BUG,20)
ADD_CREATURE_TO_POOL(FLY,20)
ADD_CREATURE_TO_POOL(SPIDER,20)
ADD_CREATURE_TO_POOL(TROLL,20)

CREATURE_AVAILABLE(PLAYER0,HELL_HOUND,1,0)
CREATURE_AVAILABLE(PLAYER0,TENTACLE,1,0)
CREATURE_AVAILABLE(PLAYER0,SORCEROR,1,0)
CREATURE_AVAILABLE(PLAYER0,BILE_DEMON,1,0)
CREATURE_AVAILABLE(PLAYER0,DARK_MISTRESS,1,0)
CREATURE_AVAILABLE(PLAYER0,DRAGON,1,0)
CREATURE_AVAILABLE(PLAYER0,VAMPIRE,1,0)
CREATURE_AVAILABLE(PLAYER0,ORC,1,0)
CREATURE_AVAILABLE(PLAYER0,FLY,1,0)
CREATURE_AVAILABLE(PLAYER0,SPIDER,1,0)
CREATURE_AVAILABLE(PLAYER0,BUG,1,0)
CREATURE_AVAILABLE(PLAYER0,TROLL,1,0)

ROOM_AVAILABLE(PLAYER0,TREASURE,1,1)
ROOM_AVAILABLE(PLAYER0,LAIR,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,BRIDGE,1,0)

MAGIC_AVAILABLE(PLAYER0,POWER_HAND,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_SLAP,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_CAVE_IN,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_CALL_TO_ARMS,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_SPEED,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_IMP,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_PROTECT,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_LIGHTNING,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_CONCEAL,1,0)

TRAP_AVAILABLE(ALL_PLAYERS,ALARM,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,POISON_GAS,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,LAVA,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,STEEL,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,BOULDER,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,MAGIC,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,LIGHTNING,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,WORD_OF_POWER,1,0)
		
CREATE_PARTY(ONE)
	ADD_TO_PARTY(ONE,THIEF,2,500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(ONE,THIEF,2,500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(ONE,ARCHER,4,750,ATTACK_ENEMIES,0)		

CREATE_PARTY(TWO)
	ADD_TO_PARTY(TWO,ARCHER,4,750,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(TWO,ARCHER,2,500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(TWO,BARBARIAN,3,700,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TWO,BARBARIAN,4,700,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(WEAKARCHERS)
	ADD_TO_PARTY(WEAKARCHERS,ARCHER,3,900,STEAL_GOLD,0)
	ADD_TO_PARTY(WEAKARCHERS,ARCHER,4,900,STEAL_GOLD,0)	
	ADD_TO_PARTY(WEAKARCHERS,ARCHER,5,900,STEAL_GOLD,0)
	ADD_TO_PARTY(WEAKARCHERS,ARCHER,5,900,STEAL_GOLD,0)

CREATE_PARTY(WEAKSAMIES)
	ADD_TO_PARTY(WEAKSAMIES,SAMURAI,2,550,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WEAKSAMIES,SAMURAI,2,550,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WEAKSAMIES,SAMURAI,3,750,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WEAKSAMIES,SAMURAI,4,950,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WEAKSAMIES,SAMURAI,4,950,ATTACK_ENEMIES,0)

CREATE_PARTY(FAIRIES)
	ADD_TO_PARTY(FAIRIES,FAIRY,4,900,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(FAIRIES,FAIRY,4,900,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(FAIRIES,FAIRY,4,900,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(FAIRIES,FAIRY,4,900,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(FAIRIES,FAIRY,4,900,ATTACK_ENEMIES,0)

CREATE_PARTY(DWARVES)
	ADD_TO_PARTY(DWARVES,DWARFA,4,500,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(DWARVES,DWARFA,4,500,ATTACK_DUNGEON_HEART,0)	
	ADD_TO_PARTY(DWARVES,DWARFA,4,500,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(DWARVES,DWARFA,4,500,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(DWARVES,DWARFA,4,500,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(FINAL)
	ADD_TO_PARTY(FINAL,FAIRY,10,5000,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(FINAL,FAIRY,8,800,DEFEND_PARTY,0)
	ADD_TO_PARTY(FINAL,FAIRY,8,800,DEFEND_PARTY,0)
	ADD_TO_PARTY(FINAL,FAIRY,8,800,DEFEND_PARTY,0)
	ADD_TO_PARTY(FINAL,FAIRY,8,800,DEFEND_PARTY,0)

CREATE_PARTY(DEFEND3)
	ADD_TO_PARTY(DEFEND3,ARCHER,7,1000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(DEFEND3,ARCHER,7,1000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(DEFEND3,ARCHER,7,1000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(DEFEND3,ARCHER,7,1000,ATTACK_ENEMIES,0)

CREATE_PARTY(DEFEND4)
	ADD_TO_PARTY(DEFEND4,ARCHER,7,1000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(DEFEND4,ARCHER,7,1000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(DEFEND4,WITCH,7,1500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(DEFEND4,WITCH,7,1500,ATTACK_ENEMIES,0)

CREATE_PARTY(DEFENDER)
	ADD_TO_PARTY(DEFENDER,GIANT,6,1800,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(DEFENDER,GIANT,6,1800,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(DEFENDER,GIANT,6,1800,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(DEFENDER,GIANT,6,1800,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(DEFENDER,GIANT,6,1800,ATTACK_ENEMIES,0)

CREATE_PARTY(WAITA)
	ADD_TO_PARTY(WAITA,DWARFA,5,750,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WAITA,ARCHER,5,850,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WAITA,DWARFA,5,750,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WAITA,DWARFA,5,750,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WAITA,ARCHER,5,850,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WAITA,DWARFA,5,750,ATTACK_ENEMIES,0)

CREATE_PARTY(WAITB)
	ADD_TO_PARTY(WAITB,DWARFA,6,750,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WAITB,ARCHER,6,850,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WAITB,ARCHER,6,750,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WAITB,WIZARD,7,1250,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WAITB,ARCHER,6,850,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WAITB,WIZARD,7,1250,ATTACK_ENEMIES,0)

CREATE_PARTY(WAITC)
	ADD_TO_PARTY(WAITC,WIZARD,7,1550,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WAITC,WIZARD,7,1550,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WAITC,WITCH,7,1550,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WAITC,WITCH,7,1550,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WAITC,MONK,8,1850,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WAITC,MONK,8,1750,ATTACK_ENEMIES,0)

CREATE_PARTY(MEDSAMIES)
	ADD_TO_PARTY(MEDSAMIES,SAMURAI,6,1000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(MEDSAMIES,SAMURAI,6,1000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(MEDSAMIES,SAMURAI,6,1000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(MEDSAMIES,SAMURAI,6,1000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(MEDSAMIES,SAMURAI,6,1000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(MEDSAMIES,SAMURAI,6,1000,ATTACK_ENEMIES,0)

CREATE_PARTY(ELITESAMIES)
	ADD_TO_PARTY(ELITESAMIES,SAMURAI,9,1500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(ELITESAMIES,SAMURAI,9,1500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(ELITESAMIES,SAMURAI,9,1500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(ELITESAMIES,SAMURAI,9,1500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(ELITESAMIES,SAMURAI,9,1500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(ELITESAMIES,SAMURAI,9,1500,ATTACK_ENEMIES,0)

CREATE_PARTY(LORDGUARD)
	ADD_TO_PARTY(LORDGUARD,MONK,7,1000,DEFEND_PARTY,0)
	ADD_TO_PARTY(LORDGUARD,GIANT,8,1250,DEFEND_PARTY,0)
	ADD_TO_PARTY(LORDGUARD,SAMURAI,9,1000,DEFEND_PARTY,0)
	ADD_TO_PARTY(LORDGUARD,SAMURAI,9,1000,DEFEND_PARTY,0)
	ADD_TO_PARTY(LORDGUARD,SAMURAI,9,1000,DEFEND_PARTY,0)
	ADD_TO_PARTY(LORDGUARD,ARCHER,5,1000,ATTACK_DUNGEON_HEART,0)

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

REM "The Avatar is a wretched being, full of happiness and good cheer. Food is scarce in his land and the only Hatchery..."
DISPLAY_OBJECTIVE(918,PLAYER0)

IF(PLAYER_GOOD,GAME_TURN >= 9000)
	IF_CONTROLS(PLAYER0,TOTAL_CREATURES >= 8)
		REM "Food is scarce in this land and the only Hatchery available to you is inside a hero dungeon..."
		DISPLAY_INFORMATION(907,ALL_PLAYERS)
	ENDIF
ENDIF

IF(PLAYER_GOOD,GAME_TURN >= 10000)			  
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,WAITA,15,DUNGEON,0,1,250)
ENDIF

IF(PLAYER_GOOD,GAME_TURN >= 25000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,WAITB,16,DUNGEON,0,1,250)
ENDIF

IF(PLAYER_GOOD,GAME_TURN >= 30000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,WAITC,17,DUNGEON,0,1,250)
ENDIF

IF(PLAYER_GOOD,GAME_TURN >= 35000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,MEDSAMIES,18,DUNGEON,0,1,250)
ENDIF

IF_CONTROLS(PLAYER0,VAMPIRE >= 1)
	REM "Entombed in stone by a cruel band of heroes, the Vampire you have rescued demands revenge for his imprisonment..."
	DISPLAY_INFORMATION(908,ALL_PLAYERS)
ENDIF

IF(PLAYER0,WORKSHOP >= 1)
	ROOM_AVAILABLE(PLAYER0,WORKSHOP,1,1)
ENDIF

IF(PLAYER0,PRISON >= 1)
	ROOM_AVAILABLE(PLAYER0,PRISON,1,1)
ENDIF

REM If hero GARDEN is taken over from heroes, we can expand it by ourselves
IF(PLAYER_GOOD,GARDEN <= 0)
	ROOM_AVAILABLE(PLAYER0,GARDEN,1,1)
ENDIF

IF_CONTROLS(PLAYER0,BILE_DEMON >= 1)
	REM "The Bile Demon you have rescued will be a valuable but hungry asset to your dungeon. Make sure your Hatchery can satisfy his voracious appetite."
	DISPLAY_INFORMATION(924,ALL_PLAYERS)
ENDIF

IF_ACTION_POINT(1,PLAYER0)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,ONE,2,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,ONE,3,1)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,3,1,5,750)
ENDIF

IF_ACTION_POINT(2,PLAYER0)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TWO,4,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WEAKARCHERS,7,1)
ENDIF

IF_ACTION_POINT(3,PLAYER0)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TWO,5,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WEAKARCHERS,8,1)
ENDIF

IF_ACTION_POINT(4,PLAYER0)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WEAKSAMIES,6,1)
ENDIF

IF_ACTION_POINT(5,PLAYER0)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WEAKSAMIES,11,1)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,SAMURAI,11,1,5,650)
ENDIF

REM Trigger FAIRIES with either AP6 or AP11

IF_ACTION_POINT(6,PLAYER0)
	SET_FLAG(PLAYER_GOOD,FLAG0,1)
ENDIF

IF_ACTION_POINT(11,PLAYER0)
	SET_FLAG(PLAYER_GOOD,FLAG0,1)
ENDIF

IF(PLAYER_GOOD,FLAG0 >= 1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FAIRIES,12,1)
ENDIF

IF_ACTION_POINT(7,PLAYER0)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WEAKSAMIES,9,1)
ENDIF

IF_ACTION_POINT(8,PLAYER0)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FAIRIES,10,1)
ENDIF

IF_ACTION_POINT(13,PLAYER0)
	REM "Decimate this outpost and send fear into the heart of the Avatar."
	DISPLAY_OBJECTIVE(920,PLAYER0)
	SET_TIMER(PLAYER_GOOD,TIMER0)
ENDIF

IF(PLAYER_GOOD,TIMER0 >= 250)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DWARVES,14,1)
ENDIF

IF(PLAYER_GOOD,TIMER0 >= 45000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DEFENDER,-3,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DEFEND4,-3,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FINAL,-3,1)
ENDIF

IF_ACTION_POINT(19,PLAYER0)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DWARVES,19,1)
ENDIF

IF_ACTION_POINT(20,PLAYER0)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,ONE,20,1)
ENDIF

IF_ACTION_POINT(22,PLAYER0)
	ROOM_AVAILABLE(PLAYER0,PRISON,1,1)
ENDIF

REM Show objective if either AP24 or AP25 is reached

IF_ACTION_POINT(24,PLAYER0)
	SET_FLAG(PLAYER_GOOD,FLAG4,1)
ENDIF

IF_ACTION_POINT(25,PLAYER0)
	SET_FLAG(PLAYER_GOOD,FLAG4,1)
ENDIF

IF(PLAYER_GOOD,FLAG4 == 1)
	REM "The Avatar's castle is ripe for the taking. Train your forces well, Keeper. The ultimate battle awaits ..."
	DISPLAY_OBJECTIVE(921,PLAYER0)
ENDIF

REM Initiate the final events chain when AP21 reached

IF_ACTION_POINT(21,PLAYER0)
	REM "The Avatar has massed an army of heroic Lords to confront you. Prepare to be attacked!"
	DISPLAY_OBJECTIVE(919,PLAYER0)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,MEDSAMIES,16,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DEFENDER,17,2)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WEAKARCHERS,26,1)
	SET_TIMER(PLAYER_GOOD,TIMER5)
ENDIF

IF(PLAYER_GOOD,TIMER5 >= 650)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAITC,PLAYER_GOOD,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,LORDGUARD,-4,2)
ENDIF

IF(PLAYER_GOOD,TIMER5 >= 1000)
	DISPLAY_OBJECTIVE(922,PLAYER0)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,AVATAR,23,1,10,100000)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,KNIGHT,23,8,7,4000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,ELITESAMIES,23,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,ELITESAMIES,-4,1)
ENDIF

IF(PLAYER_GOOD,TIMER5 >= 1200)
	IF_CONTROLS(PLAYER_GOOD,AVATAR <= 0)
		IF(PLAYER_GOOD,DUNGEON_DESTROYED == 1)
			REM "Finally, you stand unchallenged. The world is yours to waste and despoil. I bet you have never felt so bad."
			DISPLAY_OBJECTIVE(172,PLAYER0)
			REM "Your achievements are legendary Keeper. Tales of your evil and cunning will become the horror stories of generations."
			DISPLAY_INFORMATION(934,ALL_PLAYERS)
			WIN_GAME
		ENDIF
	ENDIF
ENDIF

REM ***  End of File  **********************************************************
