REM ****************************************************************************
REM  Campaigns Consolidation Project for KeeperFX strategy game.
REM ****************************************************************************
REM  Script for Level Elf's Dance
REM  Campaign: New game plus
REM  Authors:  based on Bullfrog script
REM            KeeperFX CCP Team
REM            Loobinex
REM  Date:     17 Dec 1996 - 15 Aug 2020
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 Flags used:
REM   PLAYER0,FLAG7 - Transfer flag, win level without attacking heroes.

SET_GENERATE_SPEED(400)

COMPUTER_PLAYER(PLAYER1,0)
COMPUTER_PLAYER(PLAYER2,0)
SET_COMPUTER_EVENT(PLAYER1,"EVENT ENEMY DOOR",400,25,2500,2,DRAWFROM(18000,22000))
SET_COMPUTER_EVENT(PLAYER2,"EVENT ENEMY DOOR",400,25,2500,2,DRAWFROM(18000,22000))

ALLY_PLAYERS(PLAYER1,PLAYER2,1)

START_MONEY(PLAYER0,3000)
START_MONEY(PLAYER1,6000)
START_MONEY(PLAYER2,6000)

MAX_CREATURES(PLAYER0,30)
MAX_CREATURES(PLAYER1,25)
MAX_CREATURES(PLAYER2,25)

ADD_CREATURE_TO_POOL(BUG,30)
ADD_CREATURE_TO_POOL(FLY,30)
ADD_CREATURE_TO_POOL(DEMONSPAWN,30)
ADD_CREATURE_TO_POOL(DARK_MISTRESS,20)
ADD_CREATURE_TO_POOL(SORCEROR,15)
ADD_CREATURE_TO_POOL(TROLL,30)
ADD_CREATURE_TO_POOL(SPIDER,30)
ADD_CREATURE_TO_POOL(BILE_DEMON,25)
ADD_CREATURE_TO_POOL(ORC,20)
ADD_CREATURE_TO_POOL(HELL_HOUND,20)
ADD_CREATURE_TO_POOL(DRAGON,20)

REM Creature availability
CREATURE_AVAILABLE(PLAYER0,TROLL,1,0)
CREATURE_AVAILABLE(PLAYER0,DEMONSPAWN,1,0)
CREATURE_AVAILABLE(PLAYER0,FLY,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,DARK_MISTRESS,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,SORCEROR,1,0)
CREATURE_AVAILABLE(PLAYER0,BUG,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,SPIDER,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,BILE_DEMON,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,ORC,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,DRAGON,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,HELL_HOUND,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(PLAYER0,BRIDGE,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,PRISON,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,SCAVENGER,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,TORTURE,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,PRISON,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,TEMPLE,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,GRAVEYARD,2,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(PLAYER1,POWER_DISEASE,1,0)
MAGIC_AVAILABLE(PLAYER2,POWER_CAVE_IN,1,0)

REM Doors and traps availability
DOOR_AVAILABLE(PLAYER0,WOOD,1,0)
DOOR_AVAILABLE(PLAYER0,BRACED,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,POISON_GAS,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,BOULDER,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,LAVA,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,STEEL,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,WORD_OF_POWER,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,MAGIC,1,0)

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

REM "Powerful creatures inhabit a cave south of here. There's a party of heroes between you and them but, if you reach them and convert them to your side before they join the other keepers, you will be unstoppable, unless you do something stupid."
DISPLAY_OBJECTIVE(88,ALL_PLAYERS)

IF(PLAYER1,DUNGEON_DESTROYED == 1)
	MAX_CREATURES(PLAYER2,40)
ENDIF

IF(PLAYER2,DUNGEON_DESTROYED == 1)
	MAX_CREATURES(PLAYER1,40)
ENDIF

IF(PLAYER1,DUNGEON_DESTROYED == 1)
	IF(PLAYER2,DUNGEON_DESTROYED == 1)
		IF_CONTROLS(PLAYER_GOOD,TOTAL_CREATURES <= 0)
			REM "You have overcome all resistance to your rule, O despicable one. It's time to flex the old misery muscle on the pathetic inhabitants of the land above."
			DISPLAY_OBJECTIVE(89,ALL_PLAYERS)
			WIN_GAME
		ENDIF
	ENDIF
ENDIF

REM Access to transfer special revoked when a hero is killed before a single keeper is destroyed, or when transfering a unit into this level.
IF_CONTROLS(PLAYER_GOOD,TOTAL_CREATURES < 27)
	IF(PLAYER1,DUNGEON_DESTROYED == 0)
		IF(PLAYER2,DUNGEON_DESTROYED == 0)
			IF(PLAYER0,FLAG7 <= 0)
				SET_FLAG(PLAYER0,FLAG7,1)
			ENDIF
		ENDIF
	ENDIF
ENDIF
IF(PLAYER0,GAME_TURN <= 10)
	IF(PLAYER0,TOTAL_CREATURES >= 1)
		SET_FLAG(PLAYER0,FLAG7,1)
	ENDIF
ENDIF
IF(PLAYER0,FLAG7 == 1)
	PLAY_MESSAGE(PLAYER0,SOUND,927)
	CHANGE_SLAB_TYPE(1,44,HARD)
	REVEAL_MAP_RECT(PLAYER0,3,132,1,1)
ENDIF
IF_SLAB_OWNER(1,44,PLAYER0)
	SET_FLAG(PLAYER0,FLAG7,2)
ENDIF

REM If one computer takes heart damage, the other one will remove the door.
IF(PLAYER1,HEART_HEALTH <= 28000)
	IF_SLAB_OWNER(46,42,PLAYER2)
		SET_DOOR(UNLOCKED,46,42)
	ENDIF
ENDIF
IF(PLAYER2,HEART_HEALTH <= 28000)
	IF_SLAB_OWNER(37,42,PLAYER1)
		SET_DOOR(UNLOCKED,37,42)
	ENDIF
ENDIF

SET_DOOR(LOCKED,41,30)

IF(PLAYER1,BATTLES_WON > 0)
	IF_SLAB_OWNER(37,42,PLAYER1)
		SET_DOOR(UNLOCKED,37,42)
	ENDIF
ENDIF
IF(PLAYER2,BATTLES_WON > 0)
	IF_SLAB_OWNER(46,42,PLAYER2)
		SET_DOOR(UNLOCKED,46,42)
	ENDIF
ENDIF

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