LEVEL_VERSION(1)

START_MONEY(PLAYER0,0)

MAX_CREATURES(PLAYER0,10)
MAX_CREATURES(PLAYER1,20)
MAX_CREATURES(PLAYER3,10)

SET_FLAG(PLAYER1,FLAG1,0)

IF(PLAYER0,TOTAL_CREATURES>=10)
	IF(PLAYER1,FLAG1==0)
		NEXT_COMMAND_REUSABLE
		SET_CREATURE_TENDENCIES(PLAYER0,IMPRISON,0)
	ENDIF
ENDIF

SET_CREATURE_TENDENCIES(PLAYER_GOOD,IMPRISON,1)

SET_GENERATE_SPEED(600)

COMPUTER_PLAYER(PLAYER1,0)
COMPUTER_PLAYER(PLAYER2,0)
COMPUTER_PLAYER(PLAYER3,0)

START_MONEY(PLAYER1,1000000)
START_MONEY(PLAYER3,10000)

ALLY_PLAYERS(PLAYER1,PLAYER_GOOD)
ALLY_PLAYERS(PLAYER1,PLAYER2)
ALLY_PLAYERS(PLAYER1,PLAYER3)
ALLY_PLAYERS(PLAYER2,PLAYER3)

ADD_CREATURE_TO_POOL(ORC,10)
ADD_CREATURE_TO_POOL(TROLL,10)
ADD_CREATURE_TO_POOL(BILE_DEMON,10)
ADD_CREATURE_TO_POOL(SORCEROR,10)
ADD_CREATURE_TO_POOL(DRAGON,10)
ADD_CREATURE_TO_POOL(DARK_MISTRESS,10)
ADD_CREATURE_TO_POOL(TENTACLE,10)

CREATURE_AVAILABLE(PLAYER1,ORC,1,1)
CREATURE_AVAILABLE(PLAYER3,ORC,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,TROLL,1,1)
CREATURE_AVAILABLE(PLAYER1,BILE_DEMON,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,SORCEROR,1,1)
CREATURE_AVAILABLE(PLAYER1,DRAGON,1,1)
CREATURE_AVAILABLE(PLAYER1,DARK_MISTRESS,1,1)
CREATURE_AVAILABLE(PLAYER1,TENTACLE,1,1)

ROOM_AVAILABLE(PLAYER1,TREASURE,1,1)
ROOM_AVAILABLE(PLAYER1,LAIR,1,1)
ROOM_AVAILABLE(PLAYER1,GARDEN,1,1)
ROOM_AVAILABLE(PLAYER1,TRAINING,1,1)
ROOM_AVAILABLE(PLAYER1,RESEARCH,1,1)
ROOM_AVAILABLE(PLAYER1,BRIDGE,1,1)
ROOM_AVAILABLE(PLAYER1,GUARD_POST,1,1)
ROOM_AVAILABLE(PLAYER1,WORKSHOP,1,1)
ROOM_AVAILABLE(PLAYER1,BARRACKS,1,1)
ROOM_AVAILABLE(PLAYER1,PRISON,1,1)
ROOM_AVAILABLE(PLAYER1,TORTURE,1,1)
ROOM_AVAILABLE(PLAYER1,TEMPLE,1,1)
ROOM_AVAILABLE(PLAYER1,GRAVEYARD,1,1)
ROOM_AVAILABLE(PLAYER1,SCAVENGER,1,1)

TRAP_AVAILABLE(PLAYER1,ALARM,1,0)
TRAP_AVAILABLE(PLAYER1,LIGHTNING,1,0)
TRAP_AVAILABLE(PLAYER1,WORD_OF_POWER,1,0)

DOOR_AVAILABLE(PLAYER1,STEEL,1,7)
DOOR_AVAILABLE(PLAYER1,MAGIC,1,7)

MAGIC_AVAILABLE(PLAYER1,POWER_IMP,1,1)
MAGIC_AVAILABLE(PLAYER1,POWER_SIGHT,1,1)
MAGIC_AVAILABLE(PLAYER1,POWER_SPEED,1,1)
MAGIC_AVAILABLE(PLAYER1,POWER_OBEY,1,1)
MAGIC_AVAILABLE(PLAYER1,POWER_CALL_TO_ARMS,1,1)
MAGIC_AVAILABLE(PLAYER1,POWER_CONCEAL,1,1)
MAGIC_AVAILABLE(PLAYER1,POWER_HOLD_AUDIENCE,1,1)
MAGIC_AVAILABLE(PLAYER1,POWER_CAVE_IN,1,0)
MAGIC_AVAILABLE(PLAYER1,POWER_HEAL_CREATURE,1,0)
MAGIC_AVAILABLE(PLAYER1,POWER_LIGHTNING,1,0)
MAGIC_AVAILABLE(PLAYER1,POWER_PROTECT,1,0)
MAGIC_AVAILABLE(PLAYER1,POWER_CHICKEN,1,1)
MAGIC_AVAILABLE(PLAYER1,POWER_ARMAGEDDON,1,1)
MAGIC_AVAILABLE(PLAYER1,POWER_DESTROY_WALLS,1,1)

ROOM_AVAILABLE(PLAYER0,TREASURE,1,0)
ROOM_AVAILABLE(PLAYER0,LAIR,1,0)
ROOM_AVAILABLE(PLAYER0,GARDEN,1,0)
ROOM_AVAILABLE(PLAYER0,TRAINING,1,0)
ROOM_AVAILABLE(PLAYER0,RESEARCH,1,0)
ROOM_AVAILABLE(PLAYER0,GUARD_POST,1,0)
ROOM_AVAILABLE(PLAYER0,WORKSHOP,1,0)
ROOM_AVAILABLE(PLAYER0,BARRACKS,1,0)
ROOM_AVAILABLE(PLAYER0,PRISON,1,0)
ROOM_AVAILABLE(PLAYER0,TEMPLE,1,0)

TRAP_AVAILABLE(PLAYER0,ALARM,1,0)
TRAP_AVAILABLE(PLAYER0,POISON_GAS,1,0)
TRAP_AVAILABLE(PLAYER0,LIGHTNING,1,0)
DOOR_AVAILABLE(PLAYER0,WOOD,1,7)
DOOR_AVAILABLE(PLAYER0,BRACED,1,7)

MAGIC_AVAILABLE(PLAYER0,POWER_SPEED,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_OBEY,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_CALL_TO_ARMS,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_HOLD_AUDIENCE,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_PROTECT,1,0)

ROOM_AVAILABLE(PLAYER2,TREASURE,1,0)
ROOM_AVAILABLE(PLAYER2,LAIR,1,0)
ROOM_AVAILABLE(PLAYER2,GARDEN,1,0)
ROOM_AVAILABLE(PLAYER2,TRAINING,1,0)
ROOM_AVAILABLE(PLAYER2,RESEARCH,1,0)
ROOM_AVAILABLE(PLAYER2,GUARD_POST,1,0)
ROOM_AVAILABLE(PLAYER2,WORKSHOP,1,0)

TRAP_AVAILABLE(PLAYER2,ALARM,1,0)
TRAP_AVAILABLE(PLAYER2,POISON_GAS,1,0)
TRAP_AVAILABLE(PLAYER2,LIGHTNING,1,0)
DOOR_AVAILABLE(PLAYER2,WOOD,1,7)
DOOR_AVAILABLE(PLAYER2,BRACED,1,7)

MAGIC_AVAILABLE(PLAYER2,POWER_IMP,1,1)
MAGIC_AVAILABLE(PLAYER2,POWER_SPEED,1,0)
MAGIC_AVAILABLE(PLAYER2,POWER_OBEY,1,0)
MAGIC_AVAILABLE(PLAYER2,POWER_CALL_TO_ARMS,1,0)
MAGIC_AVAILABLE(PLAYER2,POWER_HOLD_AUDIENCE,1,0)
MAGIC_AVAILABLE(PLAYER2,POWER_PROTECT,1,0)

ROOM_AVAILABLE(PLAYER0,TREASURE,1,1)
ROOM_AVAILABLE(PLAYER0,LAIR,1,1)
ROOM_AVAILABLE(PLAYER0,GARDEN,1,1)
ROOM_AVAILABLE(PLAYER0,TRAINING,1,1)
ROOM_AVAILABLE(PLAYER0,RESEARCH,1,1)
ROOM_AVAILABLE(PLAYER0,GUARD_POST,1,0)
ROOM_AVAILABLE(PLAYER0,WORKSHOP,1,0)
ROOM_AVAILABLE(PLAYER0,BARRACKS,1,0)
ROOM_AVAILABLE(PLAYER0,PRISON,1,0)
ROOM_AVAILABLE(PLAYER0,TEMPLE,1,0)

TRAP_AVAILABLE(PLAYER3,ALARM,1,0)
TRAP_AVAILABLE(PLAYER3,POISON_GAS,1,0)
TRAP_AVAILABLE(PLAYER3,LIGHTNING,1,0)
DOOR_AVAILABLE(PLAYER3,STEEL,1,7)
DOOR_AVAILABLE(PLAYER3,BRACED,1,7)

MAGIC_AVAILABLE(PLAYER3,POWER_IMP,1,1)
MAGIC_AVAILABLE(PLAYER3,POWER_SPEED,1,0)
MAGIC_AVAILABLE(PLAYER3,POWER_OBEY,1,0)
MAGIC_AVAILABLE(PLAYER3,POWER_CALL_TO_ARMS,1,0)
MAGIC_AVAILABLE(PLAYER3,POWER_HOLD_AUDIENCE,1,0)
MAGIC_AVAILABLE(PLAYER3,POWER_PROTECT,1,0)

SET_CREATURE_TENDENCIES(PLAYER2,FLEE,1)

SET_FLAG(PLAYER0,FLAG0,0)

IF(PLAYER0,IMP>=1)
	QUICK_OBJECTIVE_WITH_POS(4,"Good, you've found some imps. Be careful with them, these will be the only imps you recieve. However, there is another way you can obtain them... Look there. This is the Hero Dungeon Heart. Go there, and destroy it.",224,92)
	REVEAL_MAP_LOCATION(PLAYER0,20)
	SET_FLAG(PLAYER0,FLAG0,1)
ENDIF

IF_ACTION_POINT(1,PLAYER0)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,MONK,1,4,2,0)
	SET_TIMER(PLAYER_GOOD,TIMER3)
	PLAY_MESSAGE(PLAYER0,SPEECH,119)
	IF(PLAYER0,FLAG0==0)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,SAMURAI,1,50,9,0)
	ENDIF
ENDIF

IF(PLAYER_GOOD,TIMER3>=14400)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,WITCH,2,4,10,0)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,FAIRY,3,3,7,0)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,FAIRY,4,3,7,0)
	IF(PLAYER_GOOD,TIMER3>=21600)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,WIZARD,5,8,10,0)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,DWARFA,6,7,7,0)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,BARBARIAN,7,15,1,0)
	ENDIF
ENDIF

IF_ACTION_POINT(8,PLAYER0)
	PLAY_MESSAGE(PLAYER0,SPEECH,124)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,SAMURAI,PLAYER_GOOD,4,5,0)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,BARBARIAN,PLAYER_GOOD,7,6,0)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,PLAYER_GOOD,10,6,0)
ENDIF

REVEAL_MAP_RECT(PLAYER0,47,71,24,24)

QUICK_OBJECTIVE_WITH_POS(0,"Your only hope has been captured by heroes. Your minions are also held by enemy hands. The heroes plan to create skeletons out of your creatures. How unheroic. But it doesn't matter now, you have to get out of there. Given your situation, you must have revenge. Take no prisoner unless you are running low on minions. I shall enforce it as well.",48,104)

IF(PLAYER0,GAME_TURN>=6)
	QUICK_INFORMATION_WITH_POS(1,"Look at such a poor design in this prison. Someone hasn't been keeping this place clean. Don't these heroes know that it repells creatures from their prison? Go out and get out of the rusty metal.",48,74)
ENDIF

IF(PLAYER2,DUNGEON_DESTROYED==0)
	IF(PLAYER2,MONEY<10000)
		NEXT_COMMAND_REUSABLE
		ADD_GOLD_TO_PLAYER(PLAYER2,10000)
	ENDIF
	IF(PLAYER2,FLY==0)
		NEXT_COMMAND_REUSABLE
		ADD_CREATURE_TO_LEVEL(PLAYER2,FLY,PLAYER2,1,10,0)
	ENDIF
ENDIF

IF(PLAYER3,DUNGEON_DESTROYED==0)
	IF(PLAYER3,MONEY<25000)
		NEXT_COMMAND_REUSABLE
		ADD_GOLD_TO_PLAYER(PLAYER3,25000)
	ENDIF
	IF(PLAYER_GOOD,DUNGEON_DESTROYED==1)
		ADD_CREATURE_TO_LEVEL(PLAYER3,ORC,PLAYER3,5,10,0)
	ENDIF
ENDIF

IF(PLAYER_GOOD,DUNGEON_DESTROYED==1)
	ADD_GOLD_TO_PLAYER(PLAYER0,25000)
	QUICK_OBJECTIVE_WITH_POS(2,"The Heroes' Dungeon Heart has been battered dead, and now you must focus on a new enemy: The Green Keeper.",215,233)
	QUICK_INFORMATION_WITH_POS(3,"Look there, the Green Keeper is in a similar situation. His creatures too have been locked up. And now ghosts and skeletons remain of those who have fallen.",170,155)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,GHOST,11,7,3,0)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,TENTACLE,10,6,6,0)
	REVEAL_MAP_LOCATION(PLAYER0,21)
	REVEAL_MAP_LOCATION(PLAYER0,11)
ENDIF


IF(PLAYER1,DUNGEON_DESTROYED==0)
	IF(PLAYER1,MONEY<100000)
		NEXT_COMMAND_REUSABLE
		ADD_GOLD_TO_PLAYER(PLAYER1,100000)
	ENDIF
	IF(PLAYER_GOOD,DUNGEON_DESTROYED==1)
		MAX_CREATURES(PLAYER1,30)
		MAX_CREATURES(PLAYER3,15)
	ENDIF
	IF(PLAYER2,DUNGEON_DESTROYED==1)
		MAX_CREATURES(PLAYER1,40)
		MAX_CREATURES(PLAYER3,20)
	ENDIF
	IF(PLAYER3,DUNGEON_DESTROYED==1)
		NEXT_COMMAND_REUSABLE
		MAX_CREATURES(PLAYER1,50)
	ENDIF
	IF(PLAYER1,TIMER1>=7200)
		QUICK_INFORMATION_WITH_POS(8,"You are limited on creature beings this time around. May I suggest slaying Keeper Larquidos' to obtain the almighty Vampire? His Graveyard is here, have a look see.",53,212)
		REVEAL_MAP_LOCATION(PLAYER0,13)
		IF(PLAYER1,TIMER1>=14400)
			QUICK_INFORMATION(9,"It looks as if Keeper Larquidos has a few heroes sitting in his cell. Maybe let them out, they might prove to have some carnage stored up against him.",PLAYER0)
			IF(PLAYER1,TIMER1>=21600)
				QUICK_INFORMATION(10,"What a fine collection of books Keeper Larquidos holds in his library. But I don't think he'll want you to have them. Like you care, take them by force. But be warned of being too greedy on that, in the situation your in frontal attack is not an option.",PLAYER0)
				IF(PLAYER1,TIMER1>=28800)
					QUICK_INFORMATION(11,"Keeper Larquidos seems to have a few Horned Reapers running around. The only thing keeping them happy is their Temple. Why not destroy it, that way the Horned Reapers will go rouge. Then you would have eliminated quite a few of his creatures, as well as his most powerful warriors. Taking two heads with one blade, marvelous.",PLAYER0)
				ENDIF
			ENDIF
		ENDIF
	ENDIF
ENDIF


IF(PLAYER2,DUNGEON_DESTROYED==1)
	QUICK_OBJECTIVE_WITH_POS(5,"Now the Green Keeper is slain. You must focus on defeating the Yellow Keeper now. He is nearby the northern Hero Prison Complex, sepparated by impenetrable rock.",113,74)
	QUICK_INFORMATION_WITH_POS(6,"You must pass through this area before you can pass through to the Yellow Keeper's realm. But as you can see, it is guarded. Make sure you are ready to face these creatures when you do.",107,152)
	REVEAL_MAP_LOCATION(PLAYER0,22)
	REVEAL_MAP_LOCATION(PLAYER0,10)
	ADD_GOLD_TO_PLAYER(PLAYER0,25000)
ENDIF

IF(PLAYER3,DUNGEON_DESTROYED==1)
	QUICK_OBJECTIVE_WITH_POS(7,"Now is time for you to fulfill your final part in this mission. You must defeat the Blue Keeper, otherwise known as Keeper Larquidos. Beware, he is no easy challange. On top of having lots of experiance, he has many more creatures with quick recovery and has more spells and rooms than you do. The creatures here even like him better, and prefer his dungeon. His Dungeon Heart is heavily guarded, and it make take several attempts to destroy it. But in the end, only you are powerful enough to eliminate it.",149,212)
	ADD_GOLD_TO_PLAYER(PLAYER0,25000)
	REVEAL_MAP_LOCATION(PLAYER0,14)
	IF_ACTION_POINT(12,PLAYER1)
		SET_FLAG(PLAYER1,FLAG1,1)
	ENDIF
	IF_ACTION_POINT(12,PLAYER0)
		SET_FLAG(PLAYER1,FLAG1,1)
	ENDIF
ENDIF

IF(PLAYER1,FLAG1==1)
	SET_TIMER(PLAYER1,TIMER1)
ENDIF

IF(PLAYER1,DUNGEON_DESTROYED==1)
	ADD_GOLD_TO_PLAYER(PLAYER0,25000)
	QUICK_OBJECTIVE(12,"You have not scored victory yet, keeper. You may have destroyed Keeper Larquidos' Dungeon Heart, or his body, but his spirit is still alive. He has made a deal with the Avatar. The Avatar has come down to deal with you, while Larquidos trys to recreate his body in another land. We need not to deal with Larquidos again, therefore you must find his spirit and destroy it. It may be near where the Avatar dropped...",PLAYER0)
	PLAY_MESSAGE(PLAYER0,SPEECH,107)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,AVATAR,14,1,10,1000000)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,FLOATING_SPIRIT,15,1,10,0)
	SET_TIMER(PLAYER_GOOD,TIMER4)
	IF(PLAYER_GOOD,FLOATING_SPIRIT==0)
		IF(PLAYER_GOOD,AVATAR==0)
			PLAY_MESSAGE(PLAYER0,SPEECH,109)
			WIN_GAME
			QUICK_OBJECTIVE(13,"Larquidos's spirit has been destroyed, and the Avatar lies dead. With the strongest of the heroes and the evil defeated, not including you of course, no other enemy will dare show themselves in battle against you again. And with that said, enjoy this victory. Because after something like this, I may easily say 'Let's go and take over the world'. But it looks as if that's already been done with this winning.",PLAYER0)
		ENDIF
	ENDIF
ENDIF

IF_ACTION_POINT(16,PLAYER0)
	SET_CREATURE_TENDENCIES(PLAYER_GOOD,IMPRISON,0)
	PLAY_MESSAGE(PLAYER0,SPEECH,125)
	QUICK_INFORMATION(14,"Do you hear that? Looks like the heroes don't want to re-capture you but kill you instead. Make with it then.",PLAYER0)
ENDIF

IF_ACTION_POINT(17,PLAYER0)
	PLAY_MESSAGE(PLAYER0,SPEECH,121)
ENDIF

IF_ACTION_POINT(11,PLAYER0)
	PLAY_MESSAGE(PLAYER0,SPEECH,123)
ENDIF

IF(PLAYER_GOOD,TIMER4>=25)
	PLAY_MESSAGE(PLAYER0,SPEECH,118)
	IF(PLAYER_GOOD,TIMER4>=50)
		PLAY_MESSAGE(PLAYER0,SPEECH,119)
		IF(PLAYER_GOOD,TIMER4>=75)
			PLAY_MESSAGE(PLAYER0,SPEECH,120)
			IF(PLAYER_GOOD,TIMER4>=100)
				PLAY_MESSAGE(PLAYER0,SPEECH,121)
				IF(PLAYER_GOOD,TIMER4>=125)
					PLAY_MESSAGE(PLAYER0,SPEECH,122)
					IF(PLAYER_GOOD,TIMER4>=150)
						PLAY_MESSAGE(PLAYER0,SPEECH,123)
						IF(PLAYER_GOOD,TIMER4>=175)
							PLAY_MESSAGE(PLAYER0,SPEECH,124)
							IF(PLAYER_GOOD,TIMER4>=200)
								PLAY_MESSAGE(PLAYER0,SPEECH,125)
							ENDIF
						ENDIF
					ENDIF
				ENDIF
			ENDIF
		ENDIF
	ENDIF
ENDIF
