REM ****************************************************************************
REM  Campaigns Consolidation Project for KeeperFX strategy game.
REM ****************************************************************************
REM  Script for Level Moonbrush Wood
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 rooms for the player:
REM   GRAVEYARD - researchable from start
REM New creatures for the player:
REM   HORNY - possible to summon with sacrifices
REM   VAMPIRE - from GRAVEYARD but also on level; message if summoned
REM   DRAGON - from DEMONSPAWN; message in case of evolution
REM New powers for the player:
REM   POWER_HOLD_AUDIENCE - researchable from start
REM   POWER_DISEASE - researchable from start

REM Flags used:
REM   PLAYER0,FLAG0 - Transferrred DRAGON state; 0-not transferred to this level; 1-had transferred DRAGON from level start. 
REM Timers used:
REM   PLAYER_GOOD,TIMER0 - Delay after Lord of Land arrival

SET_GENERATE_SPEED(350)

START_MONEY(PLAYER0,5000)

MAX_CREATURES(PLAYER0,20)

ADD_CREATURE_TO_POOL(FLY,20)
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(SPIDER,20)
ADD_CREATURE_TO_POOL(BILE_DEMON,8)
ADD_CREATURE_TO_POOL(ORC,20)

REM	Creature availability
CREATURE_AVAILABLE(ALL_PLAYERS,TROLL,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,DEMONSPAWN,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,FLY,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,DARK_MISTRESS,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,SORCEROR,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,SPIDER,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,BILE_DEMON,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,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,0)
ROOM_AVAILABLE(ALL_PLAYERS,BARRACKS,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,GUARD_POST,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,BRIDGE,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,PRISON,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,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CALL_TO_ARMS,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,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_PROTECT,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CONCEAL,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HOLD_AUDIENCE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_DISEASE,1,0)

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

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

REM IF(PLAYER0,TOTAL_CREATURES >= 20)
REM		PRINT("I SENSE AN EVIL PRESENCE. The Avatar")
REM ENDIF

REM "This realm is ruled by four arrogant Wizards who think they've got everything under control, because their feeble magical power..."
DISPLAY_OBJECTIVE(81,PLAYER0)

IF(PLAYER0,HORNY > 0)
	REM "Behold, you have summoned a Horned Reaper. Try not make it angry. You'll fail, because everything makes a Horned Reaper angry."
	DISPLAY_INFORMATION(83,ALL_PLAYERS)
ENDIF

IF_AVAILABLE(PLAYER0,POWER_DISEASE >= 1)
	REM "Your researchers have concocted a Disease spell. Cast it on enemy creatures and watch the affliction spread like the plague."
	DISPLAY_INFORMATION(84,ALL_PLAYERS)
ENDIF

IF(PLAYER0,VAMPIRES_RAISED > 0)
	REM "A Vampire has risen from your Graveyard, nourished by the souls of the dead which have been brought here."
	DISPLAY_INFORMATION(85,ALL_PLAYERS)
ENDIF

IF_AVAILABLE(PLAYER0,GRAVEYARD >= 1)
	REM "You have researched the Graveyard. Your Imps will drag corpses here to rot... And possibly to rise again as Vampires..."
	DISPLAY_INFORMATION(86,ALL_PLAYERS)
ENDIF

IF_AVAILABLE(PLAYER0,STEEL >= 1)
	REM "You have manufactured an Iron Door. It's a formidable barrier. Use it well."
	DISPLAY_INFORMATION(87,ALL_PLAYERS)
ENDIF

IF(PLAYER0,TEMPLE > 0)
	ROOM_AVAILABLE(PLAYER0,TEMPLE,1,1)
ENDIF

IF_AVAILABLE(PLAYER0,POWER_HOLD_AUDIENCE == 1)
	REM "The Hold Audience spell has been researched. It will immediately teleport all of your creatures back to your Dungeon Heart..."
	DISPLAY_INFORMATION(107,ALL_PLAYERS)
ENDIF

REM If we had dragon at start (from Transfer Creature special), disable the evolution notice
IF(PLAYER0,GAME_TURN < 200)
	IF(PLAYER0,DRAGON >= 1)
		SET_FLAG(PLAYER0,FLAG0,1)
	ENDIF
ENDIF

REM Show the evolution notice; note that adding DRAGON to level would destroy the logic below
IF(PLAYER0,DRAGON >= 1)
	IF(PLAYER0,GAME_TURN >= 1000)
		IF(PLAYER0,FLAG0 == 0)
			DISPLAY_INFORMATION(174,ALL_PLAYERS)
		ENDIF
	ENDIF
ENDIF

SET_FLAG(PLAYER_GOOD,FLAG1,DRAWFROM(2~5))
IF_ACTION_POINT(1,PLAYER0)
	IF(PLAYER_GOOD,FLAG1 > 0)
		SET_FLAG(PLAYER_GOOD,FLAG1,1)
	ENDIF
ENDIF
IF(PLAYER_GOOD,WIZARD == 0)
	IF(PLAYER_GOOD,FLAG1 == 1)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,KNIGHT,-1,1,7,3000)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,-1,3,5,3000)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,-1,3,5,3000)
	ENDIF
	IF(PLAYER_GOOD,FLAG1 == 2)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,KNIGHT,2,1,7,3000)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,2,3,5,3000)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,2,3,5,3000)
		SET_FLAG(PLAYER_GOOD,FLAG1,0)
	ENDIF
	IF(PLAYER_GOOD,FLAG1 == 3)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,KNIGHT,3,1,7,3000)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,3,3,5,3000)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,3,3,5,3000)
		SET_FLAG(PLAYER_GOOD,FLAG1,0)
	ENDIF
	IF(PLAYER_GOOD,FLAG1 == 4)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,KNIGHT,4,1,7,3000)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,4,3,5,3000)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,4,3,5,3000)
		SET_FLAG(PLAYER_GOOD,FLAG1,0)
	ENDIF
	IF(PLAYER_GOOD,FLAG1 == 5)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,KNIGHT,5,1,7,3000)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,5,3,5,3000)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,5,3,5,3000)
		SET_FLAG(PLAYER_GOOD,FLAG1,0)
	ENDIF
	SET_TIMER(PLAYER_GOOD,TIMER0)
ENDIF

IF(PLAYER_GOOD,TIMER0 >= 100)
	IF_CONTROLS(PLAYER_GOOD,KNIGHT <= 0)
		REM "Well, you're done down here. Time to introduce yourself to the locals and re-organise their nice little lives."
		DISPLAY_OBJECTIVE(82,PLAYER0)
		WIN_GAME
	ENDIF
ENDIF

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