REM ****************************************************************************
REM  Campaigns Consolidation Project for KeeperFX strategy game.
REM ****************************************************************************
REM  Script for Level Wishvale
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 rooms for the player:
REM   BARRACKS - OK
REM New creatures for the player:
REM   ORC - OK

SET_GENERATE_SPEED(250)

MAX_CREATURES(PLAYER0,25)
MAX_CREATURES(PLAYER1,20)

START_MONEY(PLAYER0,3000)
START_MONEY(PLAYER1,7500)

COMPUTER_PLAYER(PLAYER1,5)
REM       Name            Priority MoneyMinimum TurnScale GoldDugAtOnce MaxDistance
REM  "DIG TO CLOSE GOLD",       0,       30999,      500,             5,        71

SET_COMPUTER_PROCESS(PLAYER1,"DIG TO CLOSE GOLD",0,1250,50000,5,20)
SET_COMPUTER_CHECKS(PLAYER1,"CHECK FOR NEUTRAL PLACES",15000,0,0,0,65000)
SET_COMPUTER_PROCESS(PLAYER1,"ATTACK SAFE ATTACK",-1,100,22,100,0)

SET_CREATURE_MAX_LEVEL(PLAYER0,DEMONSPAWN,10)

ADD_CREATURE_TO_POOL(BUG,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,10)
ADD_CREATURE_TO_POOL(ORC,10)

REM	Creature availability
CREATURE_AVAILABLE(ALL_PLAYERS,TROLL,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,DEMONSPAWN,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,FLY,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,DARK_MISTRESS,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,SORCEROR,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,BUG,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,SPIDER,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,BILE_DEMON,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,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)

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)

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)

CREATE_PARTY(ICHI)
    ADD_TO_PARTY(ICHI,DWARFA,2,200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ICHI,DWARFA,2,200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ICHI,THIEF,2,200,STEAL_GOLD,0)
    ADD_TO_PARTY(ICHI,THIEF,2,200,STEAL_GOLD,0)

CREATE_PARTY(NI)
    ADD_TO_PARTY(NI,ARCHER,2,150,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(NI,ARCHER,2,150,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(NI,BARBARIAN,2,200,ATTACK_ENEMIES,0)

CREATE_PARTY(SAN)
    ADD_TO_PARTY(SAN,ARCHER,2,150,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SAN,BARBARIAN,2,200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SAN,WIZARD,2,300,STEAL_SPELLS,0)

CREATE_PARTY(YON)
    ADD_TO_PARTY(YON,BARBARIAN,2,200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(YON,BARBARIAN,2,200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(YON,WIZARD,2,300,STEAL_SPELLS,0)

CREATE_PARTY(GO)
    ADD_TO_PARTY(GO,BARBARIAN,2,200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(GO,BARBARIAN,2,200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(GO,GIANT,2,400,ATTACK_ENEMIES,0)

CREATE_PARTY(LANDLORD)
    ADD_TO_PARTY(LANDLORD,BARBARIAN,2,200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(LANDLORD,BARBARIAN,2,200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(LANDLORD,KNIGHT,4,200,ATTACK_ENEMIES,0)

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

REM "You have arrived in the middle of a battle already started. Try to avoid the crossfire until you can eliminate both sides."
DISPLAY_OBJECTIVE(71,PLAYER0)

IF(PLAYER0,TOTAL_CREATURES >= 5)
    ADD_CREATURE_TO_LEVEL(PLAYER0,ORC,4,1,2,0)
    CREATURE_AVAILABLE(ALL_PLAYERS,ORC,1,1)
REM "An orc has joined you and brought with him the plans to a barracks room, wherein you will be able to form your creatures into teams."
    DISPLAY_INFORMATION(72)
    ROOM_AVAILABLE(PLAYER0,BARRACKS,1,1)
ENDIF

SET_TIMER(PLAYER_GOOD,TIMER0)

IF(PLAYER_GOOD,FLAG0 == 0)
	IF(PLAYER_GOOD,TIMER0 > 2000)
		IF(PLAYER_GOOD,TOTAL_CREATURES <= 5)
			NEXT_COMMAND_REUSABLE
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,ICHI,-1,1)
			NEXT_COMMAND_REUSABLE
			SET_TIMER(PLAYER_GOOD,TIMER0)
		ENDIF
	ENDIF
ENDIF

SET_TIMER(PLAYER_GOOD,TIMER1)

IF(PLAYER_GOOD,FLAG0 == 0)
	IF(PLAYER_GOOD,TOTAL_CREATURES <= 5)
		IF(PLAYER_GOOD,TIMER1 > 4000)
			NEXT_COMMAND_REUSABLE
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,NI,-2,1)
			NEXT_COMMAND_REUSABLE
			SET_TIMER(PLAYER_GOOD,TIMER1)
		ENDIF
	ENDIF
ENDIF

SET_TIMER(PLAYER_GOOD,TIMER2)

IF(PLAYER_GOOD,FLAG0 == 0)
	IF(PLAYER_GOOD,TIMER2 > 7500)
		IF(PLAYER_GOOD,TOTAL_CREATURES <= 5)
			NEXT_COMMAND_REUSABLE
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SAN,-3,1)
			NEXT_COMMAND_REUSABLE
			SET_TIMER(PLAYER_GOOD,TIMER2)
		ENDIF
	ENDIF
ENDIF

SET_TIMER(PLAYER_GOOD,TIMER3)

IF(PLAYER_GOOD,FLAG0 == 0)
	IF(PLAYER_GOOD,TIMER3 > 10000)
		IF(PLAYER_GOOD,TOTAL_CREATURES <= 5)
			NEXT_COMMAND_REUSABLE
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,YON,-2,1)
			NEXT_COMMAND_REUSABLE
			SET_TIMER(PLAYER_GOOD,TIMER3)
		ENDIF
	ENDIF
ENDIF

SET_TIMER(PLAYER_GOOD,TIMER4)

IF(PLAYER_GOOD,FLAG0 == 0)
	IF(PLAYER_GOOD,TIMER4 > 15000)
		IF(PLAYER_GOOD,TOTAL_CREATURES <= 5)
			NEXT_COMMAND_REUSABLE
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,GO,-1,1)
			NEXT_COMMAND_REUSABLE
			SET_TIMER(PLAYER_GOOD,TIMER4)
		ENDIF
	ENDIF
ENDIF

SET_TIMER(PLAYER_GOOD,TIMER5)

IF(PLAYER1,DUNGEON_DESTROYED == 1)
	SET_FLAG(PLAYER_GOOD,FLAG0,1)
ENDIF

IF(PLAYER_GOOD,TIMER5 >= 20000)
	SET_FLAG(PLAYER_GOOD,FLAG0,1)
	IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,LANDLORD,-2,1)
		SET_FLAG(PLAYER_GOOD,FLAG1,1)
REM		"The heroes have been defeated and their lord arrives for one last desperate stand."
		DISPLAY_OBJECTIVE(73,PLAYER0)
		IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
			IF(PLAYER_GOOD,FLAG0 == 0)
REM				"The heroes are decimated.  Now destroy the enemy dungeon keeper."
				DISPLAY_OBJECTIVE(74,PLAYER0)
			ENDIF
		ENDIF
	ENDIF
ENDIF

IF(PLAYER_GOOD,FLAG1 == 1)
	IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
		IF(PLAYER1,DUNGEON_DESTROYED == 1)
REM			"You have defeated both sides and now control the entire land."
			DISPLAY_OBJECTIVE(75,PLAYER0)
			WIN_GAME
		ENDIF
	ENDIF
ENDIF
