REM ****************************************************
REM The Phoenix Penitentiary
REM
REM Assmist Isle Campaign by Kix
REM
REM v2.0 for DAT file objectives (by dayokay)
REM 17-Oct-2020
REM ****************************************************

LEVEL_VERSION(1)

REM aps:
rem 1 empty water room
rem 2 empty pillar room
rem 3 empty room
rem 4 hero heart
rem 5 last hero room
REM 6 fairies
rem 7 hero gems
rem 8 library
rem 9 walled knight

REM flags:
rem flag0 general progress
rem flag1 fairies halt
rem flag2 forth knight arrived

COMPUTER_PLAYER(PLAYER1,0)
COMPUTER_PLAYER(PLAYER2,4)

START_MONEY(PLAYER1,50000)
START_MONEY(PLAYER2,9000000)

ADD_GOLD_TO_PLAYER(PLAYER0,IMPORT(PLAYER0,CAMPAIGN_FLAG3))
ADD_CREATURE_TO_LEVEL(PLAYER0,BARBARIAN,-1,IMPORT(PLAYER0,CAMPAIGN_FLAG6),4,3000)

MAX_CREATURES(PLAYER0,50)
MAX_CREATURES(PLAYER1,25)
ADD_CREATURE_TO_POOL(DARK_MISTRESS,5)
CREATURE_AVAILABLE(ALL_PLAYERS,DARK_MISTRESS,1,0)
ADD_CREATURE_TO_POOL(DRAGON,6)
CREATURE_AVAILABLE(ALL_PLAYERS,DRAGON,1,0)
ADD_CREATURE_TO_POOL(BILE_DEMON,6)
CREATURE_AVAILABLE(ALL_PLAYERS,BILE_DEMON,1,0)
ADD_CREATURE_TO_POOL(ORC,8)
CREATURE_AVAILABLE(ALL_PLAYERS,ORC,1,0)

REVEAL_MAP_LOCATION(PLAYER0,8,18)
REVEAL_MAP_LOCATION(PLAYER0,9,18)

ROOM_AVAILABLE(ALL_PLAYERS,TREASURE,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,LAIR,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,GARDEN,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,RESEARCH,1,0)
ROOM_AVAILABLE(PLAYER0,WORKSHOP,1,0)

MAGIC_AVAILABLE(PLAYER1,POWER_IMP,1,1)
MAGIC_AVAILABLE(PLAYER2,POWER_IMP,1,1)
MAGIC_AVAILABLE(PLAYER1,POWER_CALL_TO_ARMS,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HOLD_AUDIENCE,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_ARMAGEDDON,1,0)
MAGIC_AVAILABLE(PLAYER2,POWER_SPEED,1,1)
MAGIC_AVAILABLE(PLAYER1,POWER_SPEED,1,0)

CREATE_PARTY(SS)
ADD_TO_PARTY(SS,SAMURAI,6,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SS,SAMURAI,6,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SS,SAMURAI,6,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SS,SAMURAI,6,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SS,SAMURAI,6,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SS,SAMURAI,6,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(SS2)
ADD_TO_PARTY(SS2,WITCH,9,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SS2,SAMURAI,9,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SS2,SAMURAI,9,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SS2,SAMURAI,9,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SS2,SAMURAI,9,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SS2,FAIRY,10,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(F1)
ADD_TO_PARTY(F1,FAIRY,2,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F1,FAIRY,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F1,FAIRY,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F1,FAIRY,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F1,FAIRY,1,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(F2)
ADD_TO_PARTY(F2,FAIRY,3,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F2,FAIRY,3,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F2,FAIRY,3,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F2,FAIRY,2,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F2,FAIRY,2,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F2,FAIRY,2,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F2,FAIRY,2,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(F3)
ADD_TO_PARTY(F3,FAIRY,4,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F3,FAIRY,3,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F3,FAIRY,3,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F3,FAIRY,3,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F3,FAIRY,3,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(F4)
ADD_TO_PARTY(F4,FAIRY,5,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F4,FAIRY,4,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F4,FAIRY,4,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F4,FAIRY,4,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F4,FAIRY,3,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F4,FAIRY,3,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F4,FAIRY,3,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(F5)
ADD_TO_PARTY(F5,FAIRY,9,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F5,FAIRY,8,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F5,FAIRY,8,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F5,FAIRY,8,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(F6)
ADD_TO_PARTY(F6,FAIRY,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F6,FAIRY,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(F6,FAIRY,10,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(A1)
ADD_TO_PARTY(A1,ARCHER,3,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A1,ARCHER,3,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A1,ARCHER,3,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A1,ARCHER,3,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A1,ARCHER,3,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(A2)
ADD_TO_PARTY(A2,ARCHER,4,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A2,ARCHER,4,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A2,ARCHER,4,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A2,ARCHER,4,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A2,ARCHER,4,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(A3)
ADD_TO_PARTY(A3,DWARFA,5,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A3,ARCHER,5,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A3,ARCHER,5,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A3,ARCHER,5,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A3,ARCHER,5,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A3,ARCHER,5,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(A4)
ADD_TO_PARTY(A4,DWARFA,7,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A4,DWARFA,5,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A4,DWARFA,5,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A4,DWARFA,5,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A4,DWARFA,5,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(A5)
ADD_TO_PARTY(A5,DWARFA,9,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A5,BARBARIAN,8,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A5,BARBARIAN,8,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A5,ARCHER,8,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A5,ARCHER,8,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(A5,ARCHER,8,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(THF1)
ADD_TO_PARTY(THF1,THIEF,7,0,STEAL_GOLD,0)
ADD_TO_PARTY(THF1,THIEF,7,0,STEAL_GOLD,0)
ADD_TO_PARTY(THF1,THIEF,7,0,STEAL_GOLD,0)
ADD_TO_PARTY(THF1,THIEF,7,0,STEAL_GOLD,0)
ADD_TO_PARTY(THF1,THIEF,7,0,STEAL_GOLD,0)
ADD_TO_PARTY(THF1,THIEF,7,0,STEAL_GOLD,0)

CREATE_PARTY(THF2)
ADD_TO_PARTY(THF2,THIEF,10,0,STEAL_GOLD,0)
ADD_TO_PARTY(THF2,THIEF,10,0,STEAL_GOLD,0)
ADD_TO_PARTY(THF2,THIEF,10,0,STEAL_GOLD,0)
ADD_TO_PARTY(THF2,THIEF,9,0,STEAL_GOLD,0)
ADD_TO_PARTY(THF2,THIEF,9,0,STEAL_GOLD,0)
ADD_TO_PARTY(THF2,THIEF,9,0,STEAL_GOLD,0)

CREATE_PARTY(KN1)
ADD_TO_PARTY(KN1,KNIGHT,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(KN1,WITCH,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(KN1,WITCH,10,0,ATTACK_DUNGEON_HEART,0)

REM	QUICK_OBJECTIVE(1,"The Phoenix Penitentiary. A place kept by corrupt knights where convicted sorcerors spend the rest of their lives. And where Polish government sends their warlocks for injecting whole marijuanas. And a home to two and a half keepers. Every keeper in this land has his own reason for dwelling this place. It's futile to expect mercy from any of them, though. As if you care, right? Now, eliminate them. Both keepers and all knights.",ALL_PLAYERS)
DISPLAY_OBJECTIVE(123, ALL_PLAYERS)
REM	QUICK_INFORMATION(4,"Hint: get some imps from the cavern east to your dungeon.",ALL_PLAYERS)
DISPLAY_INFORMATION(124,ALL_PLAYERS)

IF(PLAYER0,TORTURE>0)
	ROOM_AVAILABLE(PLAYER0,TORTURE,1,1)
	TUTORIAL_FLASH_BUTTON(17,110)
ENDIF

IF(PLAYER0,TRAINING>0)
	ROOM_AVAILABLE(PLAYER0,TRAINING,1,1)
	TUTORIAL_FLASH_BUTTON(10,110)
ENDIF

IF(PLAYER0,SCAVENGER>0)
	ROOM_AVAILABLE(PLAYER0,SCAVENGER,1,1)
	TUTORIAL_FLASH_BUTTON(14,110)
	ADD_TO_FLAG(PLAYER0,FLAG0,1)
ENDIF

IF(PLAYER2,DUNGEON_DESTROYED>0)
	ROOM_AVAILABLE(PLAYER0,BRIDGE,1,0)
	ROOM_AVAILABLE(PLAYER1,BRIDGE,1,1)
	TUTORIAL_FLASH_BUTTON(18,110)
ENDIF

IF(PLAYER0,BATTLES_WON>45)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,SAMURAI,4,10,10,500)
	ADD_TO_FLAG(PLAYER0,FLAG0,1)
ENDIF

IF(PLAYER0,BATTLES_WON>300)
	ADD_TO_FLAG(PLAYER0,FLAG0,1)
ENDIF

IF_ACTION_POINT(1,PLAYER0)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SS,1,3)
	ADD_TO_FLAG(PLAYER0,FLAG0,1)
ENDIF
IF_ACTION_POINT(2,PLAYER0)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SS,2,2)
ENDIF
IF_ACTION_POINT(3,PLAYER0)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SS,3,4)
	ADD_TO_FLAG(PLAYER0,FLAG0,1)
ENDIF
IF(PLAYER_GOOD,WIZARD==0)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,WIZARD,5,10,10,0)
	ADD_TO_FLAG(PLAYER0,FLAG0,1)
ENDIF

IF(PLAYER2,DUNGEON_DESTROYED>0)
	ADD_TO_FLAG(PLAYER0,FLAG0,1)
ENDIF

IF(PLAYER0,RESEARCH>0)
	ADD_TO_FLAG(PLAYER0,FLAG0,1)
ENDIF

IF(PLAYER0,IMP>0)
	ADD_TO_FLAG(PLAYER0,FLAG0,1)
	SET_TIMER(PLAYER0,TIMER0)
REM	QUICK_INFORMATION(2,"The four knights are not exactly the loyal types. Try to convert as many of them as possible. Perhaps you could talk them into joining you in the next realm.",ALL_PLAYERS)
	DISPLAY_INFORMATION(125,ALL_PLAYERS)
ENDIF

IF_ACTION_POINT(6,PLAYER0)
	SET_FLAG(PLAYER0,FLAG1,1)
	rem spit
	PLAY_MESSAGE(PLAYER0,SOUND,59)
	rem SPEECH spit?
	PLAY_MESSAGE(PLAYER0,SPEECH,98)
REM	QUICK_INFORMATION(11,"Portal desecrated. The fairies should be no more.",6)
	DISPLAY_INFORMATION(126,6)
ENDIF

IF_ACTION_POINT(7,PLAYER0)
REM	QUICK_INFORMATION(3,"You have triggered an alarm heroes had placed near gems to detect intruders. Guess what. They are on their way...",-1)
	DISPLAY_INFORMATION(127,-1)
	rem alarm
	PLAY_MESSAGE(PLAYER0,SOUND,90)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,F5,-1,DUNGEON,0,9,5000)
ENDIF

IF(PLAYER0,TIMER0>6500)
	SET_TIMER(PLAYER0,TIMER1)
	NEXT_COMMAND_REUSABLE
	SET_TIMER(PLAYER0,TIMER0)
	IF(PLAYER0,FLAG1<1)
		IF(PLAYER0,FLAG0==1)
			NEXT_COMMAND_REUSABLE
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,F1,6,1)
			REM	QUICK_INFORMATION(10,"The heroes have opened a fairy portal in a lava cove nearby. Though annoying, it is very delicate: desecrate the portal by touching it and it'll stop working. Simple, right?",6)
		DISPLAY_INFORMATION(128,6)
		ENDIF
		IF(PLAYER0,FLAG0==2)
			NEXT_COMMAND_REUSABLE
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,F1,6,1)
			NEXT_COMMAND_REUSABLE
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,F2,6,1)
		ENDIF
		IF(PLAYER0,FLAG0==3)
			NEXT_COMMAND_REUSABLE
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,F2,6,1)
			NEXT_COMMAND_REUSABLE
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,F3,6,1)
		ENDIF
		IF(PLAYER0,FLAG0==4)
			NEXT_COMMAND_REUSABLE
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,F3,6,1)
			NEXT_COMMAND_REUSABLE
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,F4,6,1)
		ENDIF
		IF(PLAYER0,FLAG0==5)
			NEXT_COMMAND_REUSABLE
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,F4,6,2)
		ENDIF
		IF(PLAYER0,FLAG0==6)
			NEXT_COMMAND_REUSABLE
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,F4,6,1)
			NEXT_COMMAND_REUSABLE
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,F5,6,1)
		ENDIF
		IF(PLAYER0,FLAG0==7)
			NEXT_COMMAND_REUSABLE
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,F5,6,2)
		ENDIF
		IF(PLAYER0,FLAG0>7)
			NEXT_COMMAND_REUSABLE
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,F6,6,2)
			IF(PLAYER0,TIMER1>85000)
				REM	QUICK_OBJECTIVE(5,"You are taking too long, keeper. You don't want to be here when the heroes come to clean up.",ALL_PLAYERS)
				ADD_PARTY_TO_LEVEL(PLAYER_GOOD,F6,6,2)
				DISPLAY_OBJECTIVE(129,ALL_PLAYERS)
			ENDIF
			IF(PLAYER0,TIMER1>120000)
				NEXT_COMMAND_REUSABLE
				ADD_PARTY_TO_LEVEL(PLAYER_GOOD,F6,6,6)
			ENDIF
		ENDIF
	ENDIF
ENDIF

IF(PLAYER0,TIMER1>3400)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,A1,-2,5)
ENDIF
IF(PLAYER0,TIMER1>15400)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,A2,-2,5)
ENDIF
IF(PLAYER0,TIMER1>28000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,A3,-2,5)
ENDIF
IF(PLAYER0,TIMER1>52000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,A4,-2,5)
ENDIF
IF(PLAYER0,TIMER1>88000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,A5,-2,5)
ENDIF

IF(PLAYER0,FLAG0>6)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,A5,-2,7)
ENDIF

IF(PLAYER_GOOD,KNIGHT<3)
	QUICK_INFORMATION(12,"2 knights left",ALL_PLAYERS)
	SET_TIMER(PLAYER0,TIMER2)
ENDIF
IF(PLAYER_GOOD,KNIGHT==1)
	QUICK_INFORMATION(13,"1 knight left",ALL_PLAYERS)
	SET_TIMER(PLAYER0,TIMER3)
ENDIF

IF(PLAYER0,TIMER2>10000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,KN1,-2,1)
	SET_FLAG(PLAYER0,FLAG2,1)
ENDIF

IF(PLAYER_GOOD,DUNGEON_DESTROYED==1)
	SET_TIMER(PLAYER0,TIMER4)
ENDIF
IF(PLAYER0,TIMER4>80000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SS2,-1,1)
REM	QUICK_OBJECTIVE(6,"Careful keeper, retribution has arrived. Eliminate every rival keeper and the four knights to win. Don't forget to convert knights if you wish to see them accompany you in the next realm! There is also a hidden realm special!",-1)
	DISPLAY_OBJECTIVE(130,-1)
ENDIF

IF(PLAYER0,MONEY>45000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,THF1,-2,1)
	IF(PLAYER0,FLAG0>1)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,THF2,-2,1)
	ENDIF
ENDIF

IF(PLAYER0,MONEY>70000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,THF2,-2,1)
	IF(PLAYER0,FLAG0>3)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,THF2,-2,2)
	ENDIF
ENDIF

IF(PLAYER0,ALL_DUNGEONS_DESTROYED>0)
IF(PLAYER_GOOD,KNIGHT==0)
IF(PLAYER0,FLAG2>0)
	REM	QUICK_OBJECTIVE(7,"Impressive job, Keeper. Most of the isle is yours.",-1)
	DISPLAY_OBJECTIVE(131,-1)
	rem EXPORT_VARIABLE(PLAYER0,KNIGHT,CAMPAIGN_FLAG4)
	SET_TIMER(PLAYER0,TIMER5)
	SET_FLAG(PLAYER0,CAMPAIGN_FLAG4,0)
	IF(PLAYER0,KNIGHT>1)
		SET_FLAG(PLAYER0,CAMPAIGN_FLAG4,1)
		REM	QUICK_OBJECTIVE(8,"Impressive job, Keeper. One of your knights will join you in the next realm.",-1)
		DISPLAY_OBJECTIVE(132,-1)
	ENDIF
	IF(PLAYER0,KNIGHT>3)
		SET_FLAG(PLAYER0,CAMPAIGN_FLAG4,2)
		REM	QUICK_OBJECTIVE(9,"Impressive job, Keeper. A couple of your knights will join you in the next realm.",-1)
		DISPLAY_OBJECTIVE(133,-1)
	ENDIF
ENDIF
ENDIF
ENDIF

IF(PLAYER0,TIMER5>50)
	WIN_GAME
ENDIF
