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 - 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_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(PLAYER2,0)
COMPUTER_PLAYER(PLAYER3,1)

START_MONEY(PLAYER0,7500)
START_MONEY(PLAYER2,15000)
START_MONEY(PLAYER3,15000)

MAX_CREATURES(PLAYER0,40)
MAX_CREATURES(PLAYER2,35)
MAX_CREATURES(PLAYER3,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,SORCEROR,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,DARK_MISTRESS,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,DRAGON,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,HELL_HOUND,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,VAMPIRE,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,TROLL,1,0)
CREATURE_AVAILABLE(PLAYER0,ORC,1,0)
CREATURE_AVAILABLE(PLAYER2,ORC,1,2)
CREATURE_AVAILABLE(PLAYER3,ORC,1,2)

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,2,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 SET_CREATURE_CONFIGURATION(GHOST,Size,0,0)


SET_COMPUTER_PROCESS(PLAYER2,"DIG TO CLOSE GOLD",0,50000,10000,5,25)
SET_COMPUTER_PROCESS(PLAYER3,"DIG TO GOLD",0,50000,800,7,15)
SET_COMPUTER_PROCESS(PLAYER3,"DIG TO GREEDY GOLD",0,50000,800,7,15)
SET_COMPUTER_EVENT(PLAYER2,"EVENT MOANING PRISONER",100,0,0,0,0)

QUICK_OBJECTIVE(1,"You've stumbled upon an important route used by the Heroes leading to a fortress stockpiling of wealth and weapons. The forces of good are bringing all of their treasures to the same place, so intercept what you can and move to claim this as your own. But obviously, you're not the only one who's noticed...")
REM Look at the lua map to see if I can have the occasional hero run past carrying a dungeon special, spellbook, trap crate, gold pot.

REM something like: 
REM    if player hasn't researched spell X after a reasonable time period has elapsed, roll to see if a hero will be carrying it (free research!)
REM    other things: spells you can't otherwise research (and will otherwise go to the stockpile)
REM    other things: useful trap crates (including hero traps)
REM    other things: dungeon specials (increase level, resurrect, create gold, make safe etc)
REM    other things: gold pots (1000)


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_CONTROLS(PLAYER2,TOTAL_CREATURES <= 14)
		IF(PLAYER2,DUNGEON_DESTROYED == 0)
			REM "Can you see how vulnerable one of your opponents has become? Then kill him."
			DISPLAY_INFORMATION(114,PLAYER2)
		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_CONTROLS(PLAYER3,TOTAL_CREATURES <= 14)
		IF(PLAYER3,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,PLAYER3)
		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,ALL_PLAYERS)
	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,ALL_PLAYERS)
ENDIF

REM Show a message when any of computer players discovers POWER_DESTROY_WALLS
IF(PLAYER0,FLAG0 == 0)
	IF_AVAILABLE(PLAYER2,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,ALL_PLAYERS)
		SET_FLAG(PLAYER0,FLAG0,1)
	ENDIF
	IF_AVAILABLE(PLAYER3,POWER_DESTROY_WALLS >= 1)
		DISPLAY_INFORMATION(118,ALL_PLAYERS)
		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,ALL_PLAYERS)
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,ALL_PLAYERS)
ENDIF

IF(PLAYER3,PRISON >= 9)
	SET_CREATURE_TENDENCIES(PLAYER3,IMPRISON,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 or captured
IF(PLAYER2,DUNGEON_DESTROYED == 1)
	IF(PLAYER3,DUNGEON_DESTROYED == 1)
		IF_CONTROLS(PLAYER_GOOD,TOTAL_CREATURES <= 0)
			WIN_GAME
		ENDIF
	ENDIF
ENDIF

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