LEVEL_VERSION(1)
SET_GENERATE_SPEED(600)
START_MONEY(PLAYER0,22500)
START_MONEY(PLAYER1,2222500)
START_MONEY(PLAYER2,2222500)
START_MONEY(PLAYER3,2222500)
MAX_CREATURES(PLAYER0,20)
MAX_CREATURES(PLAYER1,18)
MAX_CREATURES(PLAYER2,18)
MAX_CREATURES(PLAYER3,18)
SET_GAME_RULE(MapCreatureLimit,1000)


QUICK_INFORMATION(1,"Be Sure to Check out all Communitymade Maps on: https://keeperfx.net/workshop/browse")
QUICK_OBJECTIVE(4,"Everything except Gold is limited in this Realm do to an old Curse, once you hit 40 Creatures every Creature above that will DIE.")



SET_GAME_RULE(BodiesForVampire,7)
SET_GAME_RULE(GemEffectiveness,25)
SET_GAME_RULE(ImpWorkExperience,300)
SET_GAME_RULE(AlliesShareCta,1)
SET_GAME_RULE(AlliesShareDrop,1)
SET_GAME_RULE(AlliesShareVision,1)
SET_CREATURE_PROPERTY(IMP,NO_IMPRISONMENT,1)

ALLY_PLAYERS(PLAYER1,PLAYER2,3)
ALLY_PLAYERS(PLAYER2,PLAYER1,3)
ALLY_PLAYERS(PLAYER2,PLAYER3,3)
ALLY_PLAYERS(PLAYER3,PLAYER2,3)
ALLY_PLAYERS(PLAYER1,PLAYER3,3)
ALLY_PLAYERS(PLAYER3,PLAYER1,3)



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

SET_COMPUTER_EVENT(PLAYER2,"EVENT MOANING PRISONER",100,2,8,30,0)
SET_COMPUTER_EVENT(PLAYER2,"EVENT SAVE TORTURED",15,0,0,0,0)
SET_COMPUTER_EVENT(PLAYER3,"EVENT MOANING PRISONER",100,2,8,30,0)
SET_COMPUTER_EVENT(PLAYER3,"EVENT SAVE TORTURED",15,0,0,0,0)



ADD_CREATURE_TO_POOL(TROLL,30)
ADD_CREATURE_TO_POOL(SPIDER,30)
ADD_CREATURE_TO_POOL(TENTACLE,30)
ADD_CREATURE_TO_POOL(SORCEROR,20)
ADD_CREATURE_TO_POOL(ORC,30)
ADD_CREATURE_TO_POOL(BILE_DEMON,30)
ADD_CREATURE_TO_POOL(DRAGON,30)
ADD_CREATURE_TO_POOL(DARK_MISTRESS,30)
ADD_CREATURE_TO_POOL(SKELETON,30)

CREATURE_AVAILABLE(ALL_PLAYERS,TROLL,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,SPIDER,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,TENTACLE,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,SORCEROR,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,ORC,1,0)
CREATURE_AVAILABLE(PLAYER1,BILE_DEMON,1,0)
CREATURE_AVAILABLE(PLAYER2,BILE_DEMON,1,0)
CREATURE_AVAILABLE(PLAYER3,SKELETON,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,DRAGON,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,DARK_MISTRESS,1,0)

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

MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HAND,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SLAP,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_POSSESS,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_IMP,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SIGHT,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SPEED,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_OBEY,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CALL_TO_ARMS,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HOLD_AUDIENCE,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_HEAL_CREATURE,1,0)
MAGIC_AVAILABLE(PLAYER1,POWER_HEAL_CREATURE,1,1)
MAGIC_AVAILABLE(PLAYER2,POWER_HEAL_CREATURE,1,1)
MAGIC_AVAILABLE(PLAYER3,POWER_HEAL_CREATURE,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_PROTECT,1,0)
MAGIC_AVAILABLE(PLAYER1,POWER_LIGHTNING,1,1)
MAGIC_AVAILABLE(PLAYER2,POWER_LIGHTNING,1,1)
MAGIC_AVAILABLE(PLAYER3,POWER_LIGHTNING,1,1)



TRAP_AVAILABLE(ALL_PLAYERS,POISON_GAS,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,LIGHTNING,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,WORD_OF_POWER,1,0)

DOOR_AVAILABLE(ALL_PLAYERS,STEEL,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,MAGIC,1,0)

REM PARTYS

CREATE_PARTY(TUNNELER1)
	ADD_TO_PARTY(TUNNELER1,ARCHER,3,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TUNNELER1,WIZARD,3,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TUNNELER1,BARBARIAN,3,250,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(TUNNELER2)
	ADD_TO_PARTY(TUNNELER2,WITCH,5,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TUNNELER2,ARCHER,5,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TUNNELER2,SAMURAI,5,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TUNNELER2,THIEF,5,250,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(TUNNELER3)
	ADD_TO_PARTY(TUNNELER3,WITCH,7,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TUNNELER3,SAMURAI,7,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TUNNELER3,ARCHER,7,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TUNNELER3,BILE_DEMON,7,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TUNNELER3,ARCHER,7,250,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(TUNNELER4)
	ADD_TO_PARTY(TUNNELER4,WITCH,9,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TUNNELER4,ARCHER,9,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TUNNELER4,FAIRY,9,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TUNNELER4,SAMURAI,9,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TUNNELER4,KNIGHT,9,250,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(TUNNELER5)
	ADD_TO_PARTY(TUNNELER5,WITCH,10,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TUNNELER5,ARCHER,10,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TUNNELER5,FAIRY,10,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TUNNELER5,SAMURAI,10,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TUNNELER5,KNIGHT,10,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(TUNNELER5,TIME_MAGE,10,250,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(LASTSTAND)
	ADD_TO_PARTY(LASTSTAND,BARBARIAN,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(LASTSTAND,BARBARIAN,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(LASTSTAND,DRUID,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(LASTSTAND,DRUID,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(LASTSTAND,WITCH,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(LASTSTAND,WITCH,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(LASTSTAND,HORNY,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(LASTSTAND,HORNY,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(LASTSTAND,FAIRY,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(LASTSTAND,FAIRY,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(LASTSTAND,TIME_MAGE,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(LASTSTAND,TIME_MAGE,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(LASTSTAND,SAMURAI,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(LASTSTAND,SAMURAI,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(LASTSTAND,KNIGHT,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(LASTSTAND,KNIGHT,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(LASTSTAND,AVATAR,10,250,DEFEND_HEART,0)



REM Waveboxes

SET_BOX_TOOLTIP(22,"STOP WAVES LEFT: Use this to stop the waves from the Left side. Once they're stopped theres no going back.")

REM # "Wavestopper, use to stop waves from spawning"
IF(PLAYER0,BOX22_ACTIVATED > 0)
	PLAY_MESSAGE(PLAYER0,SOUND,95)
ENDIF

IF(PLAYER0,BOX22_ACTIVATED >= 1)
	SET_FLAG(PLAYER_GOOD,FLAG0,1)
	ADD_TO_FLAG(PLAYER0,FLAG4,1)
ENDIF


SET_BOX_TOOLTIP(23,"STOP WAVES RIGHT: Use this to stop the waves from the Right side. Once they're stopped theres no going back.")

REM # "Wavestopper, use to stop waves from spawning"
IF(PLAYER0,BOX23_ACTIVATED > 0)
	PLAY_MESSAGE(PLAYER0,SOUND,94)
ENDIF

IF(PLAYER0,BOX23_ACTIVATED >= 1)
	SET_FLAG(PLAYER_GOOD,FLAG1,1)
	ADD_TO_FLAG(PLAYER0,FLAG4,1)
ENDIF

IF(PLAYER0,TOTAL_CREATURES >= 6)
	SET_TIMER(PLAYER_GOOD,TIMER0)
	SET_TIMER(PLAYER0,TIMER0)
ENDIF

REM LEFT SIDE



IF(PLAYER_GOOD,FLAG0 == 0)
IF(PLAYER_GOOD,TIMER0 >= 4000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER1,-4,DUNGEON_HEART,0,3,2500)	
	SET_TIMER(PLAYER_GOOD,TIMER1)
ENDIF

IF(PLAYER_GOOD,TIMER1 >= 6000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER2,-4,DUNGEON_HEART,0,5,2500)
	SET_TIMER(PLAYER_GOOD,TIMER2)
ENDIF

IF(PLAYER_GOOD,TIMER2 >= 6000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER2,-4,DUNGEON_HEART,0,5,2500)
	SET_TIMER(PLAYER_GOOD,TIMER3)
ENDIF

IF(PLAYER_GOOD,TIMER3 >= 6000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER3,-4,DUNGEON_HEART,0,7,2500)
	SET_TIMER(PLAYER_GOOD,TIMER4)
ENDIF

IF(PLAYER_GOOD,TIMER4 >= 6000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER4,-4,DUNGEON_HEART,0,7,2500)
	SET_TIMER(PLAYER_GOOD,TIMER5)
ENDIF

IF(PLAYER_GOOD,TIMER5 >= 5500)
	NEXT_COMMAND_REUSABLE
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER5,-4,DUNGEON_HEART,0,7,2500)
	NEXT_COMMAND_REUSABLE
	SET_TIMER(PLAYER_GOOD,TIMER5)
ENDIF
ENDIF


REM RIGHT SIDE



IF(PLAYER_GOOD,FLAG1 == 0)
IF(PLAYER0,TIMER0 >= 4000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER1,-5,DUNGEON_HEART,0,3,2500)
	SET_TIMER(PLAYER0,TIMER1)
ENDIF

IF(PLAYER0,TIMER1 >= 6000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER2,-5,DUNGEON_HEART,0,5,2500)
	SET_TIMER(PLAYER0,TIMER2)
ENDIF

IF(PLAYER0,TIMER2 >= 6000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER2,-5,DUNGEON_HEART,0,5,2500)
	SET_TIMER(PLAYER0,TIMER3)
ENDIF

IF(PLAYER0,TIMER3 >= 6000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER3,-5,DUNGEON_HEART,0,7,2500)
	SET_TIMER(PLAYER0,TIMER4)
ENDIF

IF(PLAYER0,TIMER4 >= 6000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER4,-5,DUNGEON_HEART,0,7,2500)
	SET_TIMER(PLAYER0,TIMER5)
ENDIF

IF(PLAYER0,TIMER5 >= 5500)
	NEXT_COMMAND_REUSABLE
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER5,-5,DUNGEON_HEART,0,7,2500)
	NEXT_COMMAND_REUSABLE
	SET_TIMER(PLAYER0,TIMER5)
ENDIF
ENDIF

REM WHITE HEART

IF_ACTION_POINT(2,PLAYER0)
	QUICK_INFORMATION(3,"You reached the Lords Dungeonheart, be careful he kept his strongest Fighters alongside him to defend their home at all Cost.")
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,LASTSTAND,3,1)
ENDIF

SET_CREATURE_PROPERTY(AVATAR,LORD,1)
SET_CREATURE_PROPERTY(KNIGHT,LORD,0)

REM IMPLIMIT

IF_CONTROLS(PLAYER2,IMP < 12)
  NEXT_COMMAND_REUSABLE
  MAGIC_AVAILABLE(PLAYER1,POWER_IMP,1,1)
 ENDIF

IF_CONTROLS(PLAYER2,IMP >= 12)
  NEXT_COMMAND_REUSABLE
  MAGIC_AVAILABLE(PLAYER1,POWER_IMP,0,0)
ENDIF

IF_CONTROLS(PLAYER3,IMP < 12)
  NEXT_COMMAND_REUSABLE
  MAGIC_AVAILABLE(PLAYER3,POWER_IMP,1,1)
 ENDIF

IF_CONTROLS(PLAYER3,IMP >= 12)
  NEXT_COMMAND_REUSABLE
  MAGIC_AVAILABLE(PLAYER3,POWER_IMP,0,0)
ENDIF

IF_CONTROLS(PLAYER1,IMP < 12)
  NEXT_COMMAND_REUSABLE
  MAGIC_AVAILABLE(PLAYER1,POWER_IMP,1,1)
 ENDIF

IF_CONTROLS(PLAYER1,IMP >= 12)
  NEXT_COMMAND_REUSABLE
  MAGIC_AVAILABLE(PLAYER1,POWER_IMP,0,0)
ENDIF

IF_CONTROLS(PLAYER0,IMP < 30)
	NEXT_COMMAND_REUSABLE
	MAGIC_AVAILABLE(PLAYER0,POWER_IMP,1,1)
	TUTORIAL_FLASH_BUTTON(21,-1)
 ENDIF

IF_CONTROLS(PLAYER0,IMP >= 30)
  QUICK_INFORMATION(2,"You reached the Limit for Imps in this Realm.")
  NEXT_COMMAND_REUSABLE
  MAGIC_AVAILABLE(PLAYER0,POWER_IMP,0,0)
ENDIF






REM AI MAX CREATURES

IF(PLAYER1,TOTAL_CREATURES >= 26)
	NEXT_COMMAND_REUSABLE
	KILL_CREATURE(PLAYER1,ANY_CREATURE,LEAST_EXPERIENCED,1)
ENDIF

IF(PLAYER2,TOTAL_CREATURES >= 26)
	NEXT_COMMAND_REUSABLE
	KILL_CREATURE(PLAYER2,ANY_CREATURE,LEAST_EXPERIENCED,1)
ENDIF

IF(PLAYER3,TOTAL_CREATURES >= 26)
	NEXT_COMMAND_REUSABLE
	KILL_CREATURE(PLAYER3,ANY_CREATURE,LEAST_EXPERIENCED,1)
ENDIF

IF(PLAYER0,TOTAL_CREATURES >= 41)
	NEXT_COMMAND_REUSABLE
	KILL_CREATURE(PLAYER0,ANY_CREATURE,LEAST_EXPERIENCED,1)
ENDIF


REM AI WAVES


IF(PLAYER1,TOTAL_CREATURES >= 8)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER1,-1,DUNGEON_HEART,1,3,100)
	SET_TIMER(PLAYER1,TIMER0)
ENDIF

IF(PLAYER1,TIMER0 >= 5500)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER2,-1,DUNGEON_HEART,1,5,100)
	SET_TIMER(PLAYER1,TIMER1)
ENDIF

IF(PLAYER1,TIMER1 >= 8000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER3,-1,DUNGEON_HEART,1,7,100)
	SET_TIMER(PLAYER1,TIMER2)
ENDIF

IF(PLAYER1,TIMER2 >= 8000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER4,-1,DUNGEON_HEART,1,9,100)
	SET_TIMER(PLAYER1,TIMER3)
ENDIF

IF(PLAYER1,TIMER3 >= 8000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER5,-1,DUNGEON_HEART,1,10,100)
	SET_TIMER(PLAYER1,TIMER4)
ENDIF

IF(PLAYER1,FLAG0 == 0)
IF(PLAYER1,TIMER4 >= 9500)
	NEXT_COMMAND_REUSABLE
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER5,-1,DUNGEON_HEART,1,10,100)
	NEXT_COMMAND_REUSABLE
	SET_TIMER(PLAYER1,TIMER4)
ENDIF
ENDIF




IF(PLAYER2,TOTAL_CREATURES >= 8)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER1,-2,DUNGEON_HEART,2,3,100)
	SET_TIMER(PLAYER2,TIMER0)
ENDIF

IF(PLAYER2,TIMER0 >= 5500)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER2,-2,DUNGEON_HEART,2,5,100)
	SET_TIMER(PLAYER2,TIMER1)
ENDIF

IF(PLAYER2,TIMER1 >= 8000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER3,-2,DUNGEON_HEART,2,7,100)
	SET_TIMER(PLAYER2,TIMER2)
ENDIF

IF(PLAYER2,TIMER2 >= 8000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER4,-2,DUNGEON_HEART,2,9,100)
	SET_TIMER(PLAYER2,TIMER3)
ENDIF

IF(PLAYER2,TIMER3 >= 8000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER5,-2,DUNGEON_HEART,2,10,100)
	SET_TIMER(PLAYER2,TIMER4)
ENDIF

IF(PLAYER2,FLAG0 == 0)
	IF(PLAYER2,TIMER4 >= 9500)
		NEXT_COMMAND_REUSABLE
		ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER5,-2,DUNGEON_HEART,2,10,100)
		NEXT_COMMAND_REUSABLE
		SET_TIMER(PLAYER2,TIMER4)
	ENDIF
ENDIF





IF(PLAYER3,TOTAL_CREATURES >= 8)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER1,-3,DUNGEON_HEART,3,3,100)
	SET_TIMER(PLAYER3,TIMER0)
ENDIF


IF(PLAYER3,TIMER0 >= 5500)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER2,-3,DUNGEON_HEART,3,5,100)
	SET_TIMER(PLAYER3,TIMER1)
ENDIF

IF(PLAYER3,TIMER1 >= 8000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER3,-3,DUNGEON_HEART,3,7,100)
	SET_TIMER(PLAYER3,TIMER2)
ENDIF

IF(PLAYER3,TIMER2 >= 8000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER4,-3,DUNGEON_HEART,3,9,100)
	SET_TIMER(PLAYER3,TIMER3)
ENDIF

IF(PLAYER3,TIMER3 >= 8000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER5,-3,DUNGEON_HEART,3,10,100)
	SET_TIMER(PLAYER3,TIMER4)
ENDIF

IF(PLAYER3,FLAG0 == 0)
	IF(PLAYER3,TIMER4 >= 9500)
		NEXT_COMMAND_REUSABLE
		ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TUNNELER5,-3,DUNGEON_HEART,3,10,100)
		NEXT_COMMAND_REUSABLE
		SET_TIMER(PLAYER3,TIMER4)
	ENDIF
ENDIF

REM AI WAVES STOP

IF(PLAYER1,TOTAL_CREATURES >= 25)
	SET_FLAG(PLAYER1,FLAG0,1)
ENDIF

IF(PLAYER2,TOTAL_CREATURES >= 25)
	SET_FLAG(PLAYER2,FLAG0,1)
ENDIF

IF(PLAYER3,TOTAL_CREATURES >= 25)
	SET_FLAG(PLAYER3,FLAG0,1)
ENDIF

REM NO DUNGEONS DESTROYED

IF(PLAYER1,DUNGEON_DESTROYED == 0)
	ADD_TO_FLAG(PLAYER0,FLAG1,1)
ENDIF

IF(PLAYER2,DUNGEON_DESTROYED == 0)
	ADD_TO_FLAG(PLAYER0,FLAG1,1)
ENDIF

IF(PLAYER3,DUNGEON_DESTROYED == 0)
	ADD_TO_FLAG(PLAYER0,FLAG1,1)
ENDIF

IF(PLAYER1,DUNGEON_DESTROYED == 1)
	ADD_TO_FLAG(PLAYER0,FLAG1,-1)
ENDIF

IF(PLAYER2,DUNGEON_DESTROYED == 1)
	ADD_TO_FLAG(PLAYER0,FLAG1,-1)
ENDIF

IF(PLAYER3,DUNGEON_DESTROYED == 1)
	ADD_TO_FLAG(PLAYER0,FLAG1,-1)
ENDIF


IF(PLAYER0,FLAG1 >= 3)
	IF(PLAYER0,FLAG4 >= 2)
		IF(PLAYER0,TOTAL_CREATURES <= 40)
		QUICK_INFORMATION(5,"You disabled both waves before taking on One of the Enemy Keepers... now you dont have a chance to get more before you fight one. Good Luck.")
		ENDIF
	ENDIF
ENDIF

IF(PLAYER0,ALL_DUNGEONS_DESTROYED == 1)
	WIN_GAME
ENDIF



