REM ********************************************
REM  Hero campaign by Alexsa
REM  Map 1239, Knights' Castle
REM  Script for the map
REM  Version 0.00
REM Update 1.00, august 2018: lowered difficulty. Reduced amount of AI players troops.
REM v2.0 by dayokay Dec2020 to use pot file
REM ********************************************
REM Knight-production map. You must gather 5 knights and then you'll be given Destroy Walls.
REM Obviously, with how *weak* are the thiefs themselves you're effectively handicapped at 12 creatures
REM But, there are no Vampires here like previous level... Just Mistresses ;)
REM With plentiful gold, Disease seems like a good idea.
REM ********************************************

REM ********************************************
LEVEL_VERSION(1)

SET_PLAYER_COLOR(PLAYER0,WHITE)
SET_PLAYER_COLOR(PLAYER_GOOD,RED)

SET_GENERATE_SPEED(400)

COMPUTER_PLAYER(PLAYER2,5)
COMPUTER_PLAYER(PLAYER3,5)
MAX_CREATURES(PLAYER0,20)
REM To weaken the AI players, they only get 8 creatures early on.
MAX_CREATURES(PLAYER2,8)
MAX_CREATURES(PLAYER3,8)

ALLY_PLAYERS(PLAYER2,PLAYER_GOOD,1)
ALLY_PLAYERS(PLAYER3,PLAYER_GOOD,1)
REM The AI players are allied, so that you don't abuse the shit of them.
ALLY_PLAYERS(PLAYER2,PLAYER3,1)

START_MONEY(PLAYER0,5000)
START_MONEY(PLAYER2,500)
START_MONEY(PLAYER3,500)

REM The primary goal is to convert 8 Thiefs to Knights; everything else is merely side entertainment.
REM All other heroes are available (with +2 fairies/dwarves/monks/samurai, +4 archers); wizards come from 3rd portal.
REM For me the Knights are still are the go-to unit if I can't get Samurai, which frankly isn't surprising.
REM I did win by hearts sniping keepers via Knight, which shouldn't be the case. Will try again.
ADD_CREATURE_TO_POOL(THIEF,9)
ADD_CREATURE_TO_POOL(DWARFA,6)
ADD_CREATURE_TO_POOL(MONK,6)
ADD_CREATURE_TO_POOL(FAIRY,6)
ADD_CREATURE_TO_POOL(BARBARIAN,6)
ADD_CREATURE_TO_POOL(GIANT,6)
ADD_CREATURE_TO_POOL(ARCHER,6)
ADD_CREATURE_TO_POOL(WITCH,6)
ADD_CREATURE_TO_POOL(WIZARD,6)
ADD_CREATURE_TO_POOL(SAMURAI,6)
ADD_CREATURE_TO_POOL(KNIGHT,1)
REM AI keepers get lots of orcs/warlocks.. but FEW MISTRESSES. It's too much of a pain to kill them.
ADD_CREATURE_TO_POOL(ORC,30)
ADD_CREATURE_TO_POOL(SORCEROR,6)
ADD_CREATURE_TO_POOL(TROLL,6)
ADD_CREATURE_TO_POOL(DARK_MISTRESS,4)
ADD_CREATURE_TO_POOL(DRAGON,3)
CREATURE_AVAILABLE(PLAYER0,THIEF,1,1)
CREATURE_AVAILABLE(PLAYER0,DWARFA,1,0)
CREATURE_AVAILABLE(PLAYER0,ARCHER,1,0)
CREATURE_AVAILABLE(PLAYER0,FAIRY,1,0)
CREATURE_AVAILABLE(PLAYER0,BARBARIAN,1,0)
CREATURE_AVAILABLE(PLAYER0,GIANT,1,0)
CREATURE_AVAILABLE(PLAYER0,MONK,1,0)
CREATURE_AVAILABLE(PLAYER0,SAMURAI,1,0)
CREATURE_AVAILABLE(PLAYER0,WITCH,1,0)
CREATURE_AVAILABLE(PLAYER2,DRAGON,1,0)
CREATURE_AVAILABLE(PLAYER2,ORC,1,0)
CREATURE_AVAILABLE(PLAYER2,DARK_MISTRESS,1,0)
CREATURE_AVAILABLE(PLAYER2,SORCEROR,1,0)
CREATURE_AVAILABLE(PLAYER2,TROLL,1,0)
CREATURE_AVAILABLE(PLAYER3,DRAGON,1,0)
CREATURE_AVAILABLE(PLAYER3,ORC,1,0)
CREATURE_AVAILABLE(PLAYER3,DARK_MISTRESS,1,0)
CREATURE_AVAILABLE(PLAYER3,SORCEROR,1,0)
CREATURE_AVAILABLE(PLAYER3,TROLL,1,0)
REM Building Temple/Guard Post is not allowed to player, to prevent water abuse. Workshop is not allowed to AI.
	ROOM_AVAILABLE(PLAYER2,TREASURE,1,1)
	ROOM_AVAILABLE(PLAYER3,TREASURE,1,1)
	ROOM_AVAILABLE(ALL_PLAYERS,LAIR,1,1)
	ROOM_AVAILABLE(PLAYER2,GARDEN,1,1)
	ROOM_AVAILABLE(PLAYER3,GARDEN,1,1)
	ROOM_AVAILABLE(ALL_PLAYERS,TRAINING,1,1)
	ROOM_AVAILABLE(ALL_PLAYERS,RESEARCH,1,1)
	ROOM_AVAILABLE(ALL_PLAYERS,BRIDGE,1,0)
REM	ROOM_AVAILABLE(ALL_PLAYERS,GUARD_POST,1,0)
	ROOM_AVAILABLE(PLAYER0,WORKSHOP,1,0)
	ROOM_AVAILABLE(ALL_PLAYERS,BARRACKS,1,0)
	ROOM_AVAILABLE(PLAYER2,TEMPLE,1,0)
	ROOM_AVAILABLE(PLAYER3,TEMPLE,1,0)
	ROOM_AVAILABLE(ALL_PLAYERS,SCAVENGER,1,0)

REM AI has a few magical powers and very small library.
	MAGIC_AVAILABLE(PLAYER0,POWER_SLAP,0,0)
	MAGIC_AVAILABLE(PLAYER2,POWER_SLAP,1,1)
	MAGIC_AVAILABLE(PLAYER3,POWER_SLAP,1,1)
	MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HAND,1,1)
	MAGIC_AVAILABLE(ALL_PLAYERS,POWER_POSSESS,1,1)
	MAGIC_AVAILABLE(ALL_PLAYERS,POWER_IMP,1,1)
	MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SPEED,1,0)
	MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HEAL_CREATURE,1,0)
	MAGIC_AVAILABLE(PLAYER0,POWER_CALL_TO_ARMS,1,0)
	MAGIC_AVAILABLE(PLAYER0,POWER_SIGHT,1,0)
	MAGIC_AVAILABLE(PLAYER0,POWER_CONCEAL,1,0)
	MAGIC_AVAILABLE(PLAYER0,POWER_PROTECT,1,0)
	MAGIC_AVAILABLE(PLAYER0,POWER_HOLD_AUDIENCE,1,0)
	MAGIC_AVAILABLE(PLAYER2,POWER_OBEY,1,1)
	MAGIC_AVAILABLE(PLAYER2,POWER_CALL_TO_ARMS,1,1)
	MAGIC_AVAILABLE(PLAYER3,POWER_OBEY,1,1)
	MAGIC_AVAILABLE(PLAYER3,POWER_CALL_TO_ARMS,1,1)
	MAGIC_AVAILABLE(PLAYER2,POWER_DISEASE,1,0)
	MAGIC_AVAILABLE(PLAYER3,POWER_CHICKEN,1,0)
REM Alarm, gas, and steel door; AI uses lightning and braced.
TRAP_AVAILABLE(PLAYER0,ALARM,1,0)
TRAP_AVAILABLE(PLAYER0,POISON_GAS,1,0)
DOOR_AVAILABLE(PLAYER0,STEEL,1,0)

TRAP_AVAILABLE(PLAYER2,LIGHTNING,1,0)
DOOR_AVAILABLE(PLAYER2,BRACED,1,0)
TRAP_AVAILABLE(PLAYER3,LIGHTNING,1,0)
DOOR_AVAILABLE(PLAYER3,BRACED,1,0)

REM Only braced doors, alarm and gas for you - reduced sustainability of workshop economy
REM On the other hand, there's over 250k gold on the map.

REM Endless attacks are strong, but only small groups attack until one of keepers is gone.
REM On the other hand, 10ish-strong Keepers are both serious threat, especially the yellow one with Mistresses.
REM And your Barbarians/Giants don't hold a candle to Orcs; dispose of them and get more Monks/Samurai instead.

CREATE_PARTY(WAVE_WARLOCKS)
CREATE_PARTY(WAVE_TROLLS)
CREATE_PARTY(WAVE_BILE)
CREATE_PARTY(WAVE_VAMPIRE)
CREATE_PARTY(WAVE_ORC)
CREATE_PARTY(WAVE_DARK)
CREATE_PARTY(WAVE_DEMONSPAWN)

ADD_TO_PARTY(WAVE_WARLOCKS,SORCEROR,5,200,STEAL_SPELLS,200)
ADD_TO_PARTY(WAVE_WARLOCKS,SORCEROR,5,0,STEAL_SPELLS,200)

ADD_TO_PARTY(WAVE_TROLLS,TROLL,4,200,ATTACK_ROOMS,200)
ADD_TO_PARTY(WAVE_TROLLS,TROLL,4,0,ATTACK_ROOMS,200)

ADD_TO_PARTY(WAVE_BILE,TROLL,6,0,ATTACK_ROOMS,200)
ADD_TO_PARTY(WAVE_BILE,BILE_DEMON,8,200,ATTACK_DUNGEON_HEART,200)
ADD_TO_PARTY(WAVE_BILE,TROLL,7,0,ATTACK_ROOMS,200)

ADD_TO_PARTY(WAVE_VAMPIRE,VAMPIRE,8,200,STEAL_GOLD,200)
ADD_TO_PARTY(WAVE_VAMPIRE,SORCEROR,7,0,STEAL_GOLD,200)
ADD_TO_PARTY(WAVE_VAMPIRE,SORCEROR,6,0,STEAL_GOLD,200)

ADD_TO_PARTY(WAVE_ORC,TROLL,5,0,ATTACK_ENEMIES,200)
ADD_TO_PARTY(WAVE_ORC,SORCEROR,7,0,ATTACK_ENEMIES,200)
ADD_TO_PARTY(WAVE_ORC,ORC,6,200,ATTACK_ENEMIES,200)

ADD_TO_PARTY(WAVE_DARK,TROLL,7,0,ATTACK_DUNGEON_HEART,200)
ADD_TO_PARTY(WAVE_DARK,SORCEROR,5,0,ATTACK_DUNGEON_HEART,200)
ADD_TO_PARTY(WAVE_DARK,DARK_MISTRESS,6,200,ATTACK_DUNGEON_HEART,200)

ADD_TO_PARTY(WAVE_DEMONSPAWN,DEMONSPAWN,10,0,ATTACK_DUNGEON_HEART,200)
ADD_TO_PARTY(WAVE_DEMONSPAWN,DEMONSPAWN,7,0,ATTACK_DUNGEON_HEART,200)
ADD_TO_PARTY(WAVE_DEMONSPAWN,DEMONSPAWN,7,0,ATTACK_DUNGEON_HEART,200)
ADD_TO_PARTY(WAVE_DEMONSPAWN,DEMONSPAWN,4,0,ATTACK_DUNGEON_HEART,200)
ADD_TO_PARTY(WAVE_DEMONSPAWN,DEMONSPAWN,4,0,ATTACK_DUNGEON_HEART,200)
ADD_TO_PARTY(WAVE_DEMONSPAWN,DARK_MISTRESS,7,200,ATTACK_DUNGEON_HEART,200)
ADD_TO_PARTY(WAVE_DEMONSPAWN,ORC,7,200,ATTACK_DUNGEON_HEART,200)

REM ACtion points:
REM 1 - green heart
REM 2 - yellow heart
REM 3 - hero heart
REM 4 - green gems
REM 5 - green gems
REM Hero gates:
REM 1 - green heart
REM 2 - library
REM 3 - workshop
REM 4 - yellow heart
REM 5 - white heart

REM Startup
	SET_TIMER(PLAYER0,TIMER0)
	SET_TIMER(PLAYER_GOOD,TIMER0)
REM QUICK_OBJECTIVE(1,"While your masons rebuild the foundation, you must restore the lost glory of Knights' Castle. It'll be fitting if you create a new Knightly Order comprised of at least five knights, or deliver a valiant victory against forces of evil nested in this underground realm.", PLAYER0)
	DISPLAY_OBJECTIVE(60)

REM First informatio
IF(PLAYER0,TIMER0 >= 200)
	REM	QUICK_INFORMATION(2,"My liege, the cellars of Knight's Castle are mostly empty of gold and grain. It will be necessary to expand outwards very soon, and this will expose you to attack from two enemy keepers controlling the region. It might be wise to focus on a single opponent at a time.", PLAYER0)
	DISPLAY_INFORMATION(61)
ENDIF
REM Once-off attack; you should've trained up your troops by this time. If you didn't properly fortify the outer rooms taken over, you'll get more breaches.
IF(PLAYER0,TIMER0 >= 15000)
	REM	QUICK_INFORMATION(3,"My liege, the monsters are attacking! They seem to be gathering at the libraries and workshops, as well as dungeons of enemy keepers.", PLAYER0)
	DISPLAY_INFORMATION(62)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_WARLOCKS,-2,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_TROLLS,-3,1)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,IMP,-1,1,1,0)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,IMP,-2,1,1,0)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,IMP,-3,1,1,0)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,IMP,-4,1,1,0)
ENDIF

REM Start endless attacks from workshop/library and add a few more attackers.
IF(PLAYER0,TIMER0 >= 35000)
REM	QUICK_INFORMATION(6,"The enemy keepers have constructed infernal gates which are connected to the dungeons of Wickedridge, and are now staging more attacks upon your castle's cellar. If you do not capture or destroy the libraries and workshops soon, they will bring in even more reinforcements.", PLAYER0)
	DISPLAY_INFORMATION(63)
	SET_FLAG(PLAYER_GOOD,FLAG1,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_ORC,-1,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_DARK,-4,1)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,IMP,-1,2,2,0)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,IMP,-4,2,2,0)
ENDIF

REM Start all endless attacks. If you haven't yet cleared workshop/library, and AI keepers, you're in trouble.
IF(PLAYER0,TIMER0 >= 50000)
REM	QUICK_INFORMATION(7,"Infernal heat scours the tunnels; forces of Wickedridge have arrived to drive you out. Rally your troops, and defeat the invaders.", PLAYER0)
	DISPLAY_INFORMATION(64)
	SET_FLAG(PLAYER_GOOD,FLAG2,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_VAMPIRE,-2,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_BILE,-3,1)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,IMP,-2,3,3,0)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,IMP,-3,3,3,0)
ENDIF

IF(PLAYER_GOOD,FLAG1==1)
	SET_TIMER(PLAYER0,TIMER1)
ENDIF
IF(PLAYER_GOOD,FLAG2==1)
	SET_TIMER(PLAYER0,TIMER2)
ENDIF
IF(PLAYER_GOOD,FLAG3==1)
REM	QUICK_INFORMATION(4,"My liege, after your last offensive the vile monsters are staging a counterattack!", PLAYER0)
	DISPLAY_INFORMATION(65)
	SET_TIMER(PLAYER0,TIMER3)
ENDIF

REM First timer; runs weaker creatures 1,33 per payday; starts halfway throuh payday and first attack comes after first payday.
REM Attacks are often and fairly annoying.

IF(PLAYER0,TIMER1 >=7500)
	NEXT_COMMAND_REUSABLE
	SET_TIMER(PLAYER0,TIMER1)
	IF(PLAYER_GOOD,RESEARCH >= 10)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_WARLOCKS,-2,1)
	ENDIF
	IF(PLAYER_GOOD,WORKSHOP >= 10)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_TROLLS,-3,1)
	ENDIF
ENDIF

REM Second timer, runs stonger creatures. Starts on third payday, works until all bosses are down
REM Fires once per payday
IF(PLAYER0,TIMER2 >= 10000)
		NEXT_COMMAND_REUSABLE
		SET_TIMER(PLAYER0,TIMER2)
	IF(PLAYER_GOOD,RESEARCH >= 10)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_VAMPIRE,-2,1)
	ENDIF
	IF(PLAYER_GOOD,WORKSHOP >= 10)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_BILE,-3,1)
	ENDIF
	IF(PLAYER2,DUNGEON_DESTROYED == 0)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_ORC,-1,1)
	ENDIF
	IF(PLAYER3,DUNGEON_DESTROYED == 0)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_DARK,-4,1)
	ENDIF
ENDIF

REM Counterattacks timer, starts once either of hostile dungeon hearts is attacked. Once dungeon is destroyed triggers Demonspawn parties instead.
IF(PLAYER0,TIMER3 >= 15000)
		NEXT_COMMAND_REUSABLE
		SET_TIMER(PLAYER0,TIMER3)
	IF(PLAYER2,DUNGEON_DESTROYED == 0)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_ORC,-1,2)
	ENDIF
	IF(PLAYER3,DUNGEON_DESTROYED == 0)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_DARK,-4,2)
	ENDIF
	IF(PLAYER2,DUNGEON_DESTROYED == 1)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_DEMONSPAWN,-6,1)
	ENDIF
	IF(PLAYER3,DUNGEON_DESTROYED == 1)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_DEMONSPAWN,-6,1)
	ENDIF
ENDIF

REM Restore defenders every 250 seconds if there are too few creatures on the map
REM If you didn't kill off other keepers, some orcs/mistresses spawn as well.
IF(PLAYER0,TIMER4 >= 5000)
	IF(PLAYER_GOOD,TOTAL_CREATURES >= 16)
		NEXT_COMMAND_REUSABLE
		SET_TIMER(PLAYER0,TIMER4)
	ENDIF
	IF(PLAYER_GOOD,DUNGEON_DESTROYED == 0)
		NEXT_COMMAND_REUSABLE
		ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,DRAGON,-5,4,10,200)
	ENDIF
	IF(PLAYER2,DUNGEON_DESTROYED == 0)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_ORC,-5,1)
	ENDIF
	IF(PLAYER3,DUNGEON_DESTROYED == 0)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_DARK,-5,1)
	ENDIF
ENDIF
REM Heart welcome party. Starts the counterattacks timer and adds several creatures to deal with the possessing player.
IF_ACTION_POINT(1,PLAYER0)
REM	QUICK_INFORMATION(5,"My liege, an alarm can be heard within the enemy dungeon - undoubtedly, more monsters will arrive as reinforcements!", PLAYER0)
	DISPLAY_INFORMATION(66,1)
	SET_FLAG(PLAYER_GOOD,FLAG3,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_ORC,-1,2)
ENDIF
IF_ACTION_POINT(2,PLAYER0)
REM	QUICK_INFORMATION(5,"My liege, an alarm can be heard within the enemy dungeon - undoubtedly, more monsters will arrive as reinforcements!", PLAYER0)
	DISPLAY_INFORMATION(66,2)
	SET_FLAG(PLAYER_GOOD,FLAG3,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_DARK,-4,2)
ENDIF
IF_ACTION_POINT(3,PLAYER0)
	SET_TIMER(PLAYER0,TIMER4)
	SET_FLAG(PLAYER_GOOD,FLAG3,1)
	IF(PLAYER2,DUNGEON_DESTROYED == 0)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_ORC,-5,2)
	ENDIF
	IF(PLAYER3,DUNGEON_DESTROYED == 0)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_DARK,-5,2)
	ENDIF
ENDIF
REM If you gained access to either gems, immediately start all of endless attacks, and send Demonspawn wave.
IF_ACTION_POINT(4,PLAYER0)
	SET_FLAG(PLAYER_GOOD,FLAG1,1)
	SET_FLAG(PLAYER_GOOD,FLAG2,1)
	SET_FLAG(PLAYER_GOOD,FLAG3,1)
REM	QUICK_INFORMATION(5,"My liege, an alarm can be heard within the enemy dungeon - undoubtedly, more monsters will arrive as reinforcements!", PLAYER0)
	DISPLAY_INFORMATION(66,4)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_DEMONSPAWN,-6,1)
ENDIF
IF_ACTION_POINT(5,PLAYER0)
	SET_FLAG(PLAYER_GOOD,FLAG1,1)
	SET_FLAG(PLAYER_GOOD,FLAG2,1)
	SET_FLAG(PLAYER_GOOD,FLAG3,1)
REM	QUICK_INFORMATION(5,"My liege, an alarm can be heard within the enemy dungeon - undoubtedly, more monsters will arrive as reinforcements!", PLAYER0)
	DISPLAY_INFORMATION(66,5)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_DEMONSPAWN,-6,1)
ENDIF

REM Get five knights; Destruction of both hearts qualifies for Destroy Walls... but those 8 dragons, room chock full of WOP and defending parties? Take your time.
IF_CONTROLS(PLAYER0, KNIGHT >= 5)
	SET_FLAG(PLAYER0,FLAG7,1)
ENDIF
IF(PLAYER2, DUNGEON_DESTROYED>=1)
IF(PLAYER3, DUNGEON_DESTROYED>=1)
	SET_FLAG(PLAYER0,FLAG7,1)
ENDIF
ENDIF

IF(PLAYER0,FLAG7>=1)
	SET_FLAG(PLAYER_GOOD,FLAG1,1)
	SET_FLAG(PLAYER_GOOD,FLAG2,1)
	SET_FLAG(PLAYER_GOOD,FLAG3,1)
	ADD_CREATURE_TO_LEVEL(PLAYER0,WIZARD,PLAYER0,1,10,0)
REM	QUICK_OBJECTIVE(14,"You have established a new Knightly Order, and a wise and powerful wizard has joined your cause, bringing a spellbook of Destroy Walls. It is now possible to finally eradicate the evil presence in these lands by destroying its very heart.", PLAYER0)
	DISPLAY_OBJECTIVE(67)
	MAGIC_AVAILABLE(PLAYER0,POWER_DESTROY_WALLS,1,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WAVE_DEMONSPAWN,-5,2)
ENDIF
REM Destruction of hero heart ends the game.
IF(PLAYER_GOOD, DUNGEON_DESTROYED>=1)
REM	QUICK_OBJECTIVE(16,"The evil polluting this land is no more, and the walls of Knights' Castle once again stand proud at the dawn. It is time to move upon the Wickedridge itself.", PLAYER0)
	DISPLAY_OBJECTIVE(68)
	WIN_GAME
ENDIF

REM Capture of entrances increases the max creatures count.
REM Here, AI keepers have lower creature count than you do.

IF(PLAYER0,ENTRANCE <= 9)
	NEXT_COMMAND_REUSABLE
	MAX_CREATURES(PLAYER0,20)
ENDIF

IF(PLAYER0,TIMER0>=20000)
	IF(PLAYER2,ENTRANCE <= 9)
		NEXT_COMMAND_REUSABLE
		MAX_CREATURES(PLAYER1,10)
	ENDIF
	IF(PLAYER3,ENTRANCE <= 9)
		NEXT_COMMAND_REUSABLE
		MAX_CREATURES(PLAYER1,10)
	ENDIF
ENDIF
IF(PLAYER0,ENTRANCE >= 10)
REM	QUICK_OBJECTIVE(13,"By capturing this portal, you have established a firm foothold which allows you to build more Hatcheries and Treasure Rooms.", PLAYER0)
	DISPLAY_OBJECTIVE(69)
	ROOM_AVAILABLE(PLAYER0,TREASURE,1,1)
	ROOM_AVAILABLE(PLAYER0,GARDEN,1,1)
	NEXT_COMMAND_REUSABLE
	MAX_CREATURES(PLAYER0,25)
	IF(PLAYER0,ENTRANCE >= 20)
		CREATURE_AVAILABLE(PLAYER0,WIZARD,1,0)
		NEXT_COMMAND_REUSABLE
		MAX_CREATURES(PLAYER0,30)
		IF(PLAYER0,ENTRANCE >= 30)
			CREATURE_AVAILABLE(PLAYER0,KNIGHT,1,0)
			NEXT_COMMAND_REUSABLE
			MAX_CREATURES(PLAYER0,35)
		ENDIF
	ENDIF
ENDIF

IF(PLAYER2,ENTRANCE >= 10)
	NEXT_COMMAND_REUSABLE
	MAX_CREATURES(PLAYER2,18)
ENDIF
IF(PLAYER3,ENTRANCE >= 10)
	NEXT_COMMAND_REUSABLE
	MAX_CREATURES(PLAYER3,18)
ENDIF

IF(PLAYER0,BRIDGE >= 1)
REM	QUICK_INFORMATION(15,"The inhabitants of Dominus do not approve of building too many bridges. Make do with shorter ones!", PLAYER0)
	DISPLAY_INFORMATION(27)
	NEXT_COMMAND_REUSABLE
	ROOM_AVAILABLE(PLAYER0,BRIDGE,0,0)
ENDIF

IF(PLAYER0,BRIDGE < 1)
	NEXT_COMMAND_REUSABLE
	ROOM_AVAILABLE(PLAYER0,BRIDGE,1,1)
ENDIF
