REM	Temple Deal
REM	Author: Kix, Created on 26 May 2018
REM	updated by dayokay to use a pot file Dec2020

LEVEL_VERSION(1)

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

START_MONEY(PLAYER0,0)
START_MONEY(PLAYER1,1200000)

DOOR_AVAILABLE(PLAYER1,WOOD,1,0)
DOOR_AVAILABLE(PLAYER0,WOOD,1,10)

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

MAGIC_AVAILABLE(PLAYER0,POWER_HAND,1,1)
MAGIC_AVAILABLE(PLAYER1,POWER_HAND,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_SLAP,1,1)
MAGIC_AVAILABLE(PLAYER1,POWER_SLAP,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_IMP,1,1)
MAGIC_AVAILABLE(PLAYER1,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_PROTECT,1,0)


ADD_CREATURE_TO_POOL(HELL_HOUND,15)
CREATURE_AVAILABLE(PLAYER1,HELL_HOUND,1,5)


MAX_CREATURES(PLAYER0,20)
MAX_CREATURES(PLAYER1,6)

CREATE_PARTY(ONE_THAR)
CREATE_PARTY(ONE_DWIZ)
CREATE_PARTY(ONE_BUFFD)
CREATE_PARTY(ONE_SAM)
CREATE_PARTY(TWO_MONKS)
CREATE_PARTY(TWO_PWIZ)
CREATE_PARTY(TWO_MIX)
CREATE_PARTY(TWO_DOGGOS)
CREATE_PARTY(FINAL)

rem *** objective count now: 14

REM afterinit ******************************************************************************************************************

REM "After you find a way to fight the tunnellers off you will soon notice this land has been drained from most of gold. It is now in hands of heroes in control of the land and also a rival keeper to the south-east. Withstand heroes trying to finish you off and defeat the lord of land to win the scenario."
DISPLAY_OBJECTIVE(9,ALL_PLAYERS)


REM waves

IF(PLAYER0,GAME_TURN>100)
	ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,4,DUNGEON_HEART,0,1,0)
	ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,5,DUNGEON_HEART,0,1,0)
	ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,6,DUNGEON_HEART,0,1,0)
	ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,7,DUNGEON_HEART,0,1,0)
	ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,8,DUNGEON_HEART,0,1,0)
	ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,9,DUNGEON_HEART,0,1,0)
	ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,10,DUNGEON_HEART,0,1,0)
	ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,11,DUNGEON_HEART,0,1,0)
ENDIF

IF(PLAYER0,GAME_TURN>10000)
	REM "Hint: you won't be able to claim portal in this land."
	DISPLAY_INFORMATION(10,ALL_PLAYERS)
ENDIF

IF(PLAYER1,TIMER1>177)
	REM "Do I hear bones moving nearby? Think it's coming from north... Go have a look; one skeleton won't be able to fight off the tunnellers!"
	DISPLAY_INFORMATION(11,ALL_PLAYERS)
	IF(PLAYER0,GAME_TURN>6500)
		SET_TIMER(PLAYER0,TIMER0)
		REM "Hint: the rival keeper is very wealthy. Do not expect him to run out of gold. Heroes are gathering their troops to the nort-east. Careful not to encounter them too early."
		DISPLAY_INFORMATION(12,ALL_PLAYERS)
	ENDIF
ENDIF

REM p1 spawn
SET_TIMER(PLAYER1,TIMER1)
REVEAL_MAP_RECT(PLAYER0,91,158,16,4)


REM timers ******************************************************************************************************************

IF(PLAYER0,TIMER0>2700)
	IF(PLAYER0,HORNY<1)
		REM "Skeletons won't stand a chance against the hero troops. Find a way to get stronger units."
		DISPLAY_OBJECTIVE(13,ALL_PLAYERS)
	ENDIF
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DRAWFROM(ONE_DWIZ,ONE_THAR),DRAWFROM(-1,-2,-3,-4),1)
ENDIF
IF(PLAYER0,TIMER0>5400)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DRAWFROM(ONE_DWIZ,ONE_BUFFD),DRAWFROM(-1,-2,-3,-4),2)
ENDIF
IF(PLAYER0,TIMER0>7700)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DRAWFROM(ONE_THAR,ONE_BUFFD),DRAWFROM(-1,-2,-3,-4),2)
ENDIF
IF(PLAYER0,TIMER0>22300)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,ONE_BUFFD,DRAWFROM(-1,-2,-3,-4),3)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,ONE_DWIZ,DRAWFROM(-1,-2,-3,-4),3)
ENDIF
IF(PLAYER0,TIMER0>28500)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,ONE_SAM,DRAWFROM(-1,-2,-3,-4),1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,ONE_SAM,DRAWFROM(-1,-2,-3,-4),1)
ENDIF
IF(PLAYER0,TIMER0>36000)
	IF(PLAYER0,SKELETON>12)
		REM "Seeing how most of their troops end up in your army, they decided to change the strategy."
		DISPLAY_INFORMATION(14,ALL_PLAYERS)
	ENDIF
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TWO_MONKS,DRAWFROM(-1,-2,-3,-4),1)
	ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,2,DUNGEON_HEART,0,10,10000)
	REM "Look! Your imprisoned vampire's got company!"
	DISPLAY_INFORMATION(15,ALL_PLAYERS)
ENDIF
IF(PLAYER0,TIMER0>41000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TWO_MONKS,DRAWFROM(-1,-2,-3,-4),1)
ENDIF
IF(PLAYER0,TIMER0>50000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TWO_MONKS,DRAWFROM(-1,-2,-3,-4),1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TWO_MONKS,DRAWFROM(-1,-2,-3,-4),1)
ENDIF
IF(PLAYER0,TIMER0>56000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TWO_PWIZ,DRAWFROM(-1,-2,-3,-4),1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TWO_PWIZ,DRAWFROM(-1,-2,-3,-4),1)
ENDIF
IF(PLAYER0,TIMER0>64000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TWO_MIX,DRAWFROM(-1,-2,-3,-4),1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TWO_MIX,DRAWFROM(-1,-2,-3,-4),1)
ENDIF
IF(PLAYER0,TIMER0>66000)
	REM "You hear keeper from the neighbouring dungeon trying to breach into heroes dungeon heart."
	DISPLAY_OBJECTIVE(16, ALL_PLAYERS)
	BONUS_LEVEL_TIME(10000)
ENDIF

IF(PLAYER0,TIMER0>70000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TWO_DOGGOS,-5,4)
ENDIF

IF(PLAYER0,TIMER0>76000)
	ADD_CREATURE_TO_LEVEL(PLAYER2,GIANT,3,1,10,0)
ENDIF
IF(PLAYER_GOOD,DUNGEON_DESTROYED==1)
	REM "Seems like the heroes are losing. Dungeon heart is destroyed, you are still alive... Luckily, lord of the land is on his way to change this..."
	DISPLAY_OBJECTIVE(17, ALL_PLAYERS)
	BONUS_LEVEL_TIME(5000)
	SET_TIMER(PLAYER0,TIMER3)
ENDIF

IF(PLAYER0,TIMER3>5000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FINAL,DRAWFROM(-1,-2,-3,-4),1)
	REM "Here they come, defeat the lord of land and his company and the land is yours forever."
	DISPLAY_OBJECTIVE(18,ALL_PLAYERS)
	IF(PLAYER_GOOD,KNIGHT==0)
	IF(PLAYER_GOOD,AVATAR==0)
		REM "The lord of land lies dead, congratulations."
		DISPLAY_OBJECTIVE(19, ALL_PLAYERS)
		WIN_GAME
	ENDIF
	ENDIF
ENDIF



IF(PLAYER1,TIMER1>500)
IF(PLAYER1,DUNGEON_DESTROYED==0)
IF(PLAYER1,TOTAL_CREATURES<15)
	IF(PLAYER0,HORNY<7)
		IF(PLAYER1,FLAG6==2)
			NEXT_COMMAND_REUSABLE
			ADD_CREATURE_TO_LEVEL(PLAYER1,TROLL,1,1,1,0)
			NEXT_COMMAND_REUSABLE
			SET_FLAG(PLAYER1,FLAG6,0)
		ENDIF
		IF(PLAYER1,FLAG6==1)
			NEXT_COMMAND_REUSABLE
			ADD_CREATURE_TO_LEVEL(PLAYER1,BILE_DEMON,1,1,1,0)
			NEXT_COMMAND_REUSABLE
			SET_FLAG(PLAYER1,FLAG6,2)
		ENDIF
		IF(PLAYER1,FLAG6==0)
			NEXT_COMMAND_REUSABLE
			ADD_CREATURE_TO_LEVEL(PLAYER1,DARK_MISTRESS,1,1,1,0)
			NEXT_COMMAND_REUSABLE
			SET_FLAG(PLAYER1,FLAG6,1)
		ENDIF
	ENDIF
	NEXT_COMMAND_REUSABLE
	SET_TIMER(PLAYER1,TIMER1)
	IF(PLAYER1,MONEY<50000)
		NEXT_COMMAND_REUSABLE
		ADD_GOLD_TO_PLAYER(PLAYER1,500000)
	ENDIF
ENDIF
ENDIF
ENDIF

REM misc ******************************************************************************************************************

IF(PLAYER0,PRISON>0)
	ROOM_AVAILABLE(PLAYER0,PRISON,1,1)
	TUTORIAL_FLASH_BUTTON(​11,​250)
ENDIF

IF(PLAYER0,TEMPLE>0)
	ROOM_AVAILABLE(PLAYER0,TEMPLE,1,1)
	TUTORIAL_FLASH_BUTTON(​12,​250)
ENDIF

IF(PLAYER0,RESEARCH>0)
	ROOM_AVAILABLE(PLAYER0,RESEARCH,1,1)
	TUTORIAL_FLASH_BUTTON(​9,​250)
	rem Great job."
ENDIF

IF(PLAYER0,BRIDGE>0)
	SET_FLAG(PLAYER0,FLAG7,1)
	REM "Gold is not the only resource scarce in this land. You're limited to build only one tile of bridge at a time."
	DISPLAY_INFORMATION(20, ALL_PLAYERS)
ENDIF

IF(PLAYER0,HORNY>0)
	REM "Smart move. But are you wealthy enough to afford them?"
	DISPLAY_INFORMATION(21, ALL_PLAYERS)
ENDIF

IF(PLAYER0,GRAVEYARD>0)
	ROOM_AVAILABLE(PLAYER0,GRAVEYARD,1,1)
	TUTORIAL_FLASH_BUTTON(15,​250)
ENDIF

IF(PLAYER0,FLAG7>0)
	IF(PLAYER0,BRIDGE>0)
		NEXT_COMMAND_REUSABLE
		ROOM_AVAILABLE(PLAYER0,BRIDGE,0,0)
	ENDIF
	IF(PLAYER0,BRIDGE==0)
		NEXT_COMMAND_REUSABLE
		ROOM_AVAILABLE(PLAYER0,BRIDGE,1,1)
	ENDIF
ENDIF

REM groups ******************************************************************************************************************



ADD_TO_PARTY(ONE_THAR,THIEF,1,0,STEAL_GOLD,0)
ADD_TO_PARTY(ONE_THAR,THIEF,1,1000,STEAL_GOLD,0)
ADD_TO_PARTY(ONE_THAR,THIEF,1,0,STEAL_GOLD,0)
ADD_TO_PARTY(ONE_THAR,ARCHER,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(ONE_THAR,ARCHER,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(ONE_THAR,ARCHER,1,0,ATTACK_DUNGEON_HEART,0)

ADD_TO_PARTY(ONE_DWIZ,WIZARD,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(ONE_DWIZ,WIZARD,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(ONE_DWIZ,WIZARD,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(ONE_DWIZ,WIZARD,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(ONE_DWIZ,DWARFA,1,2000,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(ONE_DWIZ,DWARFA,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(ONE_DWIZ,DWARFA,1,0,ATTACK_DUNGEON_HEART,0)

ADD_TO_PARTY(ONE_BUFFD,BARBARIAN,1,0,ATTACK_ROOMS,0)
ADD_TO_PARTY(ONE_BUFFD,BARBARIAN,1,0,ATTACK_ROOMS,0)
ADD_TO_PARTY(ONE_BUFFD,GIANT,1,0,ATTACK_ROOMS,0)

ADD_TO_PARTY(ONE_SAM,SAMURAI,1,3000,ATTACK_ROOMS,0)
ADD_TO_PARTY(ONE_SAM,SAMURAI,1,0,ATTACK_ROOMS,0)
ADD_TO_PARTY(ONE_SAM,SAMURAI,1,1000,ATTACK_ROOMS,0)
ADD_TO_PARTY(ONE_SAM,SAMURAI,1,0,ATTACK_ROOMS,0)
ADD_TO_PARTY(ONE_SAM,SAMURAI,1,0,ATTACK_ROOMS,0)

ADD_TO_PARTY(TWO_MONKS,MONK,8,5000,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO_MONKS,MONK,7,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO_MONKS,MONK,7,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO_MONKS,MONK,7,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO_MONKS,MONK,7,0,ATTACK_DUNGEON_HEART,0)

ADD_TO_PARTY(TWO_PWIZ,WITCH,10,5000,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO_PWIZ,WIZARD,7,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO_PWIZ,WIZARD,7,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO_PWIZ,WIZARD,7,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO_PWIZ,WIZARD,7,0,ATTACK_DUNGEON_HEART,0)

ADD_TO_PARTY(TWO_MIX,WIZARD,7,5000,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO_MIX,WIZARD,7,5000,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO_MIX,FAIRY,7,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO_MIX,FAIRY,7,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO_MIX,MONK,7,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO_MIX,MONK,7,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO_MIX,WITCH,10,0,ATTACK_DUNGEON_HEART,0)

ADD_TO_PARTY(TWO_DOGGOS,HELL_HOUND,6,3000,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO_DOGGOS,HELL_HOUND,5,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO_DOGGOS,HELL_HOUND,5,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(TWO_DOGGOS,HELL_HOUND,5,0,ATTACK_DUNGEON_HEART,0)


ADD_TO_PARTY(FINAL,AVATAR,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FINAL,KNIGHT,9,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FINAL,KNIGHT,9,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FINAL,WITCH,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(FINAL,WITCH,10,0,ATTACK_DUNGEON_HEART,0)
