REM ****************************************************************************
REM  Campaigns Consolidation Project for KeeperFX strategy game.
REM ****************************************************************************
REM  Script for Level Woodly Rhyme
REM  Campaign: DK Original
REM  Authors:  based on Bullfrog script
REM            KeeperFX CCP Team
REM  Date:     17 Dec 1996 - 11 Feb 2011
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 New powers for the player:
REM   POWER_ARMAGEDDON - researchable
REM New manufacture for the player:
REM   TRAP_WORD_OF_POWER - it's a good place to introduce it

REM Flags used:
REM   PLAYER0,FLAG0 - Computer players having Destroy Walls state; 0-don't have; 1-at least one have it.
REM   PLAYER_GOOD,FLAG5 - Action points AP2 and AP3 state; 0-neither triggered; 1-at least one was triggered by PLAYER0.
REM Timers used:
REM   PLAYER_GOOD,TIMER0 - Waves of witches counter after AP1 triggered

SET_GENERATE_SPEED(500)

REM Computer Player stuff
COMPUTER_PLAYER(PLAYER1,0)
COMPUTER_PLAYER(PLAYER2,1)

START_MONEY(PLAYER0,7500)
START_MONEY(PLAYER1,7500)
START_MONEY(PLAYER2,7500)

MAX_CREATURES(PLAYER0,40)
MAX_CREATURES(PLAYER1,35)
MAX_CREATURES(PLAYER2,35)

ADD_CREATURE_TO_POOL(TROLL,30)
ADD_CREATURE_TO_POOL(SORCEROR,25)
ADD_CREATURE_TO_POOL(DARK_MISTRESS,35)
ADD_CREATURE_TO_POOL(DRAGON,17)
ADD_CREATURE_TO_POOL(HELL_HOUND,15)
ADD_CREATURE_TO_POOL(VAMPIRE,3)
ADD_CREATURE_TO_POOL(ORC,25)

REM Creature availability
CREATURE_AVAILABLE(ALL_PLAYERS,TROLL,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,SORCEROR,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,DARK_MISTRESS,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,DRAGON,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,HELL_HOUND,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,VAMPIRE,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,ORC,1,1)

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,SCAVENGER,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_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_DESTROY_WALLS,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HOLD_AUDIENCE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_ARMAGEDDON,1,0)

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

CREATE_PARTY(ARCHERS)
	ADD_TO_PARTY(ARCHERS,ARCHER,4,500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(ARCHERS,ARCHER,4,500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(ARCHERS,ARCHER,4,500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(ARCHERS,ARCHER,4,500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(ARCHERS,WIZARD,5,600,ATTACK_ENEMIES,0)

CREATE_PARTY(DWARVES)
	ADD_TO_PARTY(DWARVES,DWARFA,4,800,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(DWARVES,DWARFA,4,800,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(DWARVES,DWARFA,4,800,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(DWARVES,DWARFA,4,800,ATTACK_ENEMIES,0)

CREATE_PARTY(WITCHES)
	ADD_TO_PARTY(WITCHES,WITCH,6,1800,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WITCHES,WITCH,6,1800,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WITCHES,WITCH,6,1800,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WITCHES,WITCH,6,1800,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(WITCHES,WITCH,6,1800,ATTACK_ENEMIES,0)

CREATE_PARTY(BARBS)
	ADD_TO_PARTY(BARBS,BARBARIAN,5,900,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(BARBS,BARBARIAN,5,900,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(BARBS,BARBARIAN,5,900,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(BARBS,BARBARIAN,5,900,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(BARBS,BARBARIAN,5,900,ATTACK_ENEMIES,0)
	
REM ****************************************************************************

REM "You seem to have started a trend. Two other Dungeon Keepers also have designs on this dark domain. Expect no quarter from your rivals."
DISPLAY_OBJECTIVE(113,PLAYER0)

REM Wait enough game turns to make sure the player will have enough creatures from portal
IF(PLAYER0,GAME_TURN >= 14000)
    REM If the player has lost creatures, he must've digged to water with heroes
	IF(PLAYER1,TOTAL_CREATURES <= 14)
		IF(PLAYER1,DUNGEON_DESTROYED == 0)
			REM "Can you see how vulnerable one of your opponents has become? Then kill him."
			DISPLAY_INFORMATION(114)
		ENDIF
	ENDIF
ENDIF

REM Again, wait enough game turns to make sure the player will have enough creatures from portal
IF(PLAYER0,GAME_TURN >= 16000)
    REM If the player has lost creatures, he must've digged to water with heroes
	IF(PLAYER2,TOTAL_CREATURES <= 14)
		IF(PLAYER2,DUNGEON_DESTROYED == 0)
			REM "I spy a keeper with hardly any creatures left under his control. I spy a Keeper who's about to die."
			DISPLAY_INFORMATION(115)
		ENDIF
	ENDIF
ENDIF

IF_AVAILABLE(PLAYER0,POWER_DESTROY_WALLS == 1)
	REM "This ancient dungeon possesses great archaeological significance. This simply means there should be some interesting treasure worth stealing. Now that's what I call practical archaeology."
	DISPLAY_INFORMATION(116)
	REM "Your librarians have learned a spell that can break through fortified walls. Give them a slap for not learning it earlier."
	DISPLAY_INFORMATION(117)
ENDIF

REM Show a message when any of computer players discovers POWER_DESTROY_WALLS
IF(PLAYER0,FLAG0 == 0)
	IF_AVAILABLE(PLAYER1,POWER_DESTROY_WALLS == 1)
		REM "One of your opponents has developed a spell that can break through fortified walls. Typical. Be on your guard."
		DISPLAY_INFORMATION(118)
		SET_FLAG(PLAYER0,FLAG0,1)
	ENDIF
	IF_AVAILABLE(PLAYER2,POWER_DESTROY_WALLS == 1)
		DISPLAY_INFORMATION(118)
		SET_FLAG(PLAYER0,FLAG0,1)
	ENDIF
ENDIF

IF_AVAILABLE(PLAYER0,POWER_ARMAGEDDON == 1)
	REM "You have developed the Armageddon spell. That's quite a name to live up to. Make sure you're the most powerful force in the region before casting it."
	DISPLAY_INFORMATION(119)
ENDIF

IF_AVAILABLE(PLAYER0,WORD_OF_POWER == 1)
	REM "Your latest discovery is the Word of Power Trap. When activated, the trap triggers an expanding ring of fire that incinerates anything caught in its area of effect."
	DISPLAY_INFORMATION(106)
ENDIF

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

REM Action points AP2 and AP3 are exclusive - add ARCHERS and BARBS only when first of those is reached

IF_ACTION_POINT(2,PLAYER0)
	SET_FLAG(PLAYER_GOOD,FLAG5,1)
ENDIF

IF_ACTION_POINT(3,PLAYER0)
	SET_FLAG(PLAYER_GOOD,FLAG5,1)
ENDIF

IF(PLAYER_GOOD,FLAG5 == 1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,ARCHERS,2,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,BARBS,2,1)
ENDIF

REM Action point AP1 triggers delayed waves of WITCHES

IF_ACTION_POINT(1,PLAYER0)
	SET_TIMER(PLAYER_GOOD,TIMER0)
ENDIF

IF(PLAYER_GOOD,TIMER0 >= 500)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DWARVES,4,1)
ENDIF

IF(PLAYER_GOOD,TIMER0 >= 1000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WITCHES,5,1)
ENDIF

REM To win, both computers must be defeated and all good creatures killed
IF(PLAYER1,DUNGEON_DESTROYED == 1)
	IF(PLAYER2,DUNGEON_DESTROYED == 1)
		IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
			WIN_GAME
		ENDIF
	ENDIF
ENDIF
