REM ****************************************************
REM Comet Landing Grotto
REM
REM Assmist Isle Campaign by Kix
REM
REM v2.0 for DAT file objectives (by dayokay)
REM 14-Nov-2020
REM ****************************************************

LEVEL_VERSION(1)

COMPUTER_PLAYER(PLAYER1,0)

SET_CREATURE_HEALTH(WIZARD,1000)
SET_CREATURE_HEALTH(DEMONSPAWN,400)

START_MONEY(PLAYER0,25000)
START_MONEY(PLAYER1,9000000)

ROOM_AVAILABLE(PLAYER0,TREASURE,1,1)
ROOM_AVAILABLE(PLAYER0,LAIR,1,1)
ROOM_AVAILABLE(PLAYER0,GARDEN,1,1)
ROOM_AVAILABLE(PLAYER0,BRIDGE,1,0)
ROOM_AVAILABLE(PLAYER0,RESEARCH,1,0)
ROOM_AVAILABLE(PLAYER0,WORKSHOP,1,0)
DOOR_AVAILABLE(PLAYER0,STEEL,1,10)
TRAP_AVAILABLE(PLAYER0,POISON_GAS,1,0)
TRAP_AVAILABLE(PLAYER0,WORD_OF_POWER,1,0)

MAGIC_AVAILABLE(PLAYER0,POWER_IMP,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_SIGHT,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_SPEED,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_HOLD_AUDIENCE,1,0)

SET_GENERATE_SPEED(220)
ADD_CREATURE_TO_POOL(DEMONSPAWN,8)
ADD_CREATURE_TO_POOL(TROLL,5)
ADD_CREATURE_TO_POOL(BILE_DEMON,5)
ADD_CREATURE_TO_POOL(ORC,3)
ADD_CREATURE_TO_POOL(SPIDER,3)
CREATURE_AVAILABLE(PLAYER0,DEMONSPAWN,1,0)
CREATURE_AVAILABLE(PLAYER0,TROLL,1,0)
CREATURE_AVAILABLE(PLAYER0,ORC,1,0)


CREATE_PARTY(ONE)
ADD_TO_PARTY(ONE,DWARFA,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(ONE,THIEF,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(ONE,MONK,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(ONE,WITCH,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(ONE,SKELETON,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(ONE,GHOST,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(ONE,VAMPIRE,1,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(TWO)
ADD_TO_PARTY(TWO,BARBARIAN,2,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO,ARCHER,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO,MONK,2,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO,WITCH,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO,SKELETON,2,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO,GHOST,2,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO,VAMPIRE,1,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(THREE)
ADD_TO_PARTY(THREE,GIANT,3,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(THREE,SAMURAI,2,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(THREE,MONK,3,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(THREE,WITCH,2,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(THREE,SKELETON,3,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(THREE,GHOST,2,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(THREE,VAMPIRE,2,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(FOUR)
ADD_TO_PARTY(FOUR,DWARFA,4,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FOUR,BARBARIAN,4,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FOUR,MONK,5,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FOUR,WITCH,4,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FOUR,SKELETON,6,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FOUR,GHOST,4,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FOUR,VAMPIRE,3,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(FIVE)
ADD_TO_PARTY(FIVE,SAMURAI,4,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FIVE,GIANT,5,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FIVE,MONK,4,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FIVE,WITCH,5,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FIVE,SKELETON,7,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FIVE,GHOST,6,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FIVE,VAMPIRE,4,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(SIX)
ADD_TO_PARTY(SIX,KNIGHT,3,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SIX,BARBARIAN,7,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SIX,MONK,6,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SIX,WITCH,6,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SIX,SKELETON,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SIX,GHOST,8,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SIX,VAMPIRE,4,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(SEVEN)
ADD_TO_PARTY(SEVEN,KNIGHT,6,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SEVEN,SAMURAI,6,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SEVEN,MONK,8,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SEVEN,WITCH,7,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SEVEN,SKELETON,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SEVEN,GHOST,8,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(SEVEN,VAMPIRE,6,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(FIN)
ADD_TO_PARTY(FIN,HORNY,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FIN,VAMPIRE,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FIN,VAMPIRE,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FIN,MONK,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FIN,MONK,10,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(FIN2)
ADD_TO_PARTY(FIN2,AVATAR,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FIN2,WIZARD,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FIN2,WIZARD,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FIN2,WIZARD,10,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(FIN3)
ADD_TO_PARTY(FIN3,AVATAR,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FIN3,HORNY,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FIN3,HORNY,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FIN3,FAIRY,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FIN3,FAIRY,10,0,ATTACK_DUNGEON_HEART,0)

REM	QUICK_OBJECTIVE(1,"Looks like something fell from the blue opening a path to surface, enchanting the area with life and riches it shattered into. Could have the esoteric altars attracted the falling object?",-3)
DISPLAY_OBJECTIVE(151,-3)
REM	QUICK_INFORMATION(2,"Touch altar of elders (the red one) to grant you one boulder trap. Touch the altar of kings (blue) to grant you 25,000 gold. Touch the altar of the damned (green) and the gods take ten most powerful of all undeads creatures. Touch the altar of light (yellow) and the gods take ten most powerful of all monks and priestesses. Touching an altar makes you unable to worship altars for some time. It also causes some dismay to the heroes on the surface.",-1)
DISPLAY_INFORMATION(152,-1)

rem ***************** altar mechanism *****************
rem flag0 total times altars used, flag1 used recently
rem timer1 altar charge time
IF(PLAYER0,FLAG1<1)
	IF_ACTION_POINT(1,PLAYER0)
		NEXT_COMMAND_REUSABLE
		TRAP_AVAILABLE(PLAYER0,BOULDER,0,1)
		NEXT_COMMAND_REUSABLE
		SET_FLAG(PLAYER0,FLAG1,1)
		DISPLAY_INFORMATION(154,1)
	ENDIF
	IF_ACTION_POINT(2,PLAYER0)
		NEXT_COMMAND_REUSABLE
		ADD_GOLD_TO_PLAYER(PLAYER0,25000)
		DISPLAY_INFORMATION(155,2)
		NEXT_COMMAND_REUSABLE
		SET_FLAG(PLAYER0,FLAG1,1)
	ENDIF
	IF_ACTION_POINT(3,PLAYER0)
		REM	QUICK_OBJECTIVE(8,"Heroes have lost their most powerful undead party but are in no way defeated. Prepare well for they won't give up this much riches that easily!",ALL_PLAYERS)
		DISPLAY_OBJECTIVE(153,3)
		NEXT_COMMAND_REUSABLE
		KILL_CREATURE(ALL_PLAYERS,SKELETON,MOST_EXPERIENCED,10)
		NEXT_COMMAND_REUSABLE
		KILL_CREATURE(ALL_PLAYERS,VAMPIRE,MOST_EXPERIENCED,10)
		NEXT_COMMAND_REUSABLE
		KILL_CREATURE(ALL_PLAYERS,GHOST,MOST_EXPERIENCED,10)
		ADD_CREATURE_TO_LEVEL(PLAYER0,ORC,6,4,2,0)
		NEXT_COMMAND_REUSABLE
		SET_FLAG(PLAYER0,FLAG1,1)
	ENDIF
	IF_ACTION_POINT(4,PLAYER0)
		DISPLAY_OBJECTIVE(156,4)
		NEXT_COMMAND_REUSABLE
		KILL_CREATURE(ALL_PLAYERS,MONK,MOST_EXPERIENCED,10)
		NEXT_COMMAND_REUSABLE
		KILL_CREATURE(ALL_PLAYERS,WITCH,MOST_EXPERIENCED,10)
		NEXT_COMMAND_REUSABLE
		SET_FLAG(PLAYER0,FLAG1,1)
	ENDIF
ENDIF


IF(PLAYER0,FLAG1==1)
	NEXT_COMMAND_REUSABLE
	ADD_TO_FLAG(PLAYER0,FLAG0,1)
	NEXT_COMMAND_REUSABLE
	ADD_TO_FLAG(PLAYER0,FLAG2,3)
	NEXT_COMMAND_REUSABLE
	SET_TIMER(PLAYER0,TIMER1)
	NEXT_COMMAND_REUSABLE
	BONUS_LEVEL_TIME(4800)
	NEXT_COMMAND_REUSABLE
	SET_FLAG(PLAYER0,FLAG1,2)
ENDIF
IF(PLAYER0,TIMER1>4800)
	NEXT_COMMAND_REUSABLE
	RESET_ACTION_POINT(1)
	NEXT_COMMAND_REUSABLE
	RESET_ACTION_POINT(2)
	NEXT_COMMAND_REUSABLE
	RESET_ACTION_POINT(3)
	NEXT_COMMAND_REUSABLE
	RESET_ACTION_POINT(4)
	NEXT_COMMAND_REUSABLE
	SET_FLAG(PLAYER0,FLAG1,0)
	NEXT_COMMAND_REUSABLE
	SET_TIMER(PLAYER0,TIMER1)
ENDIF

rem ***************** waves *****************
rem timer0 every 15 seconds add to flag2, timer4 wave start delay
rem flag2 wave counter:spawn wave if reaches 10=2.5minutes, flag3 wave strength, flag4 last 2 waves decrementing counter,flag6 pauses
IF(PLAYER0,TIMER4>7200)
	SET_TIMER(PLAYER0,TIMER0)
ENDIF

IF(PLAYER0,FLAG5==0)
IF(PLAYER0,TIMER0>300)
	NEXT_COMMAND_REUSABLE
	ADD_TO_FLAG(PLAYER0,FLAG2,1)
	NEXT_COMMAND_REUSABLE
	SET_TIMER(PLAYER0,TIMER0)
	IF(PLAYER0,FLAG2>=10)
		NEXT_COMMAND_REUSABLE
		ADD_TO_FLAG(PLAYER0,FLAG6,1)
		IF(PLAYER0,FLAG6<8)
			NEXT_COMMAND_REUSABLE
			SET_FLAG(PLAYER0,FLAG4,2)
		ENDIF
		IF(PLAYER0,FLAG6>=10)
			NEXT_COMMAND_REUSABLE
			SET_FLAG(PLAYER0,FLAG6,0)
		ENDIF
		NEXT_COMMAND_REUSABLE
		ADD_TO_FLAG(PLAYER0,FLAG3,1)
		NEXT_COMMAND_REUSABLE
		SET_FLAG(PLAYER0,FLAG2,0)
	ENDIF
ENDIF
ENDIF

IF(PLAYER0,FLAG4>0)
	IF(PLAYER0,FLAG3>59)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SEVEN,-2,2)
		NEXT_COMMAND_REUSABLE
		ADD_TO_FLAG(PLAYER0,FLAG4,-1)
	ENDIF
	IF(PLAYER0,FLAG3>49)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SIX,-2,2)
		NEXT_COMMAND_REUSABLE
		ADD_TO_FLAG(PLAYER0,FLAG4,-1)
	ENDIF
	IF(PLAYER0,FLAG3>39)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FIVE,-2,2)
		NEXT_COMMAND_REUSABLE
		ADD_TO_FLAG(PLAYER0,FLAG4,-1)
	ENDIF
	IF(PLAYER0,FLAG3>29)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FOUR,-2,2)
		NEXT_COMMAND_REUSABLE
		ADD_TO_FLAG(PLAYER0,FLAG4,-1)
	ENDIF
	IF(PLAYER0,FLAG3>19)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,THREE,-1,2)
		NEXT_COMMAND_REUSABLE
		ADD_TO_FLAG(PLAYER0,FLAG4,-1)
		ADD_CREATURE_TO_LEVEL(PLAYER0,BARBARIAN,5,IMPORT(PLAYER0,CAMPAIGN_FLAG7),10,0)
	ENDIF
	IF(PLAYER0,FLAG3>9)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TWO,-1,2)
		NEXT_COMMAND_REUSABLE
		ADD_TO_FLAG(PLAYER0,FLAG4,-1)
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,AVATAR,-3,1,10,0)
		REM	QUICK_OBJECTIVE(9,"The lord of the land has arrived to explore the vital blooming area the impact has left behind. He is mobilising faries while he's walled in: the only entrance was carefully blocked by heroes! The wizards of this land are using phencyclidine so they withstand more hits and keep the spells they managed to drain from keepers around. Find the one who keeps the destroy walls spell, convert him or kill him!",-3)
		DISPLAY_OBJECTIVE(157,-3)
		CREATURE_AVAILABLE(PLAYER0,BILE_DEMON,1,0)
		CREATURE_AVAILABLE(PLAYER0,DEMONSPAWN,0,0)
	ENDIF
	NEXT_COMMAND_REUSABLE
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,ONE,-1,3)
	NEXT_COMMAND_REUSABLE
	SET_FLAG(PLAYER0,FLAG4,0)
ENDIF

REM ***************** misc *****************
rem flag5 outro=dont spawn anymore waves
rem timer2 fairy spawn, timer3 final spawns

REVEAL_MAP_LOCATION(PLAYER0,1,25)
REVEAL_MAP_LOCATION(PLAYER0,2,25)
REVEAL_MAP_LOCATION(PLAYER0,3,25)
REVEAL_MAP_LOCATION(PLAYER0,4,25)
REVEAL_MAP_LOCATION(PLAYER0,-3,25)


IF(PLAYER_GOOD,WIZARD<3)
	ADD_TO_FLAG(PLAYER0,FLAG3,7)
ENDIF

IF(PLAYER_GOOD,WIZARD<2)
	ADD_TO_FLAG(PLAYER0,FLAG3,7)
ENDIF

IF(PLAYER_GOOD,WIZARD<1)
	TUTORIAL_FLASH_BUTTON(32,111)
	MAGIC_AVAILABLE(PLAYER0,POWER_DESTROY_WALLS,1,1)
	ADD_TO_FLAG(PLAYER0,FLAG3,7)
ENDIF

IF(PLAYER0,IMP>0)
	REM	QUICK_OBJECTIVE(7,"Seems like the heroes managed to control the undead in this land! Quickly, possess your ghost and use the power of green altar before they get to you!",-1)
	DISPLAY_OBJECTIVE(158,-1)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,SKELETON,-1,8,10,0)
	REVEAL_MAP_LOCATION(PLAYER0,-1,25)
	ADD_CREATURE_TO_LEVEL(PLAYER0,GHOST,5,1,3,0)
	SET_TIMER(PLAYER0,TIMER4)
	SET_TIMER(PLAYER0,TIMER2)
	ADD_TO_FLAG(PLAYER0,FLAG3,7)
	CREATURE_AVAILABLE(PLAYER0,SPIDER,1,0)
ENDIF


IF_AVAILABLE(PLAYER0,POWER_DESTROY_WALLS<1)
	IF(PLAYER0,TIMER2>2400)
		IF(PLAYER_GOOD,FAIRY<55)
			NEXT_COMMAND_REUSABLE
			ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,FAIRY,-3,1,10,0)
		ENDIF
		NEXT_COMMAND_REUSABLE
		SET_TIMER(PLAYER0,TIMER2)
	ENDIF
ENDIF


IF_AVAILABLE(PLAYER0,POWER_DESTROY_WALLS>0)
	REM	QUICK_OBJECTIVE(3,"You've got the spell! Just as planned. You even squeezed torture chamber plans from him. Now pay the warden a little visit they won't survive.",ALL_PLAYERS)
	DISPLAY_OBJECTIVE(159,ALL_PLAYERS)
	ROOM_AVAILABLE(PLAYER0,TORTURE,1,1)
	IF_CONTROLS(PLAYER_GOOD,AVATAR<1)
		SET_FLAG(PLAYER0,FLAG5,1)
		SET_TIMER(PLAYER0,TIMER3)
		REM	QUICK_OBJECTIVE(13,"Is it not over yet? The altars begin to glow strangely... It's as if their glow is directed to the center of the impact, embodying the spirits glow into living beings! Eliminate every hero in this land to win!",-3)
		DISPLAY_OBJECTIVE(160,-3)
	ENDIF
ENDIF

REM spawn + consume total altar uses until zero, then win if no wizards
IF(PLAYER0,TIMER3>1200)
	IF(PLAYER0,FLAG0>0)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FIN,-3,1)
		NEXT_COMMAND_REUSABLE
		ADD_TO_FLAG(PLAYER0,FLAG0,-1)
		NEXT_COMMAND_REUSABLE
		SET_TIMER(PLAYER0,TIMER3)
	ENDIF
ENDIF

IF(PLAYER0,FLAG5>0)
IF(PLAYER0,FLAG0<1)
IF(PLAYER_GOOD,TOTAL_CREATURES==0)
	SET_TIMER(PLAYER0,TIMER5)
	REM	QUICK_OBJECTIVE(15,"Seems like they won't give up! Defeat them!",ALL_PLAYERS)
	DISPLAY_OBJECTIVE(161,ALL_PLAYERS)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FIN2,DRAWFROM(1,4),1)
ENDIF
ENDIF
ENDIF

IF(PLAYER0,TIMER5>2400)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FIN3,-3,1)
	REM	QUICK_OBJECTIVE(12,"Another party! Where are they coming from?!",-3)
	DISPLAY_OBJECTIVE(162,-3)
	IF(PLAYER_GOOD,TOTAL_CREATURES==0)
	REM	QUICK_OBJECTIVE(14,"I see dead people. And dead undead. Congratulations. The Assmist Isle is yours. You'll be surprised to hear that living here has actually improved. Thanks for playing.",ALL_PLAYERS)
		DISPLAY_OBJECTIVE(163,ALL_PLAYERS)
		WIN_GAME
	ENDIF
ENDIF
