LEVEL_VERSION(1)
SET_GENERATE_SPEED(400)
START_MONEY(ALL_PLAYERS,2500)
MAX_CREATURES(PLAYER5,35)
MAX_CREATURES(PLAYER0,20)
MAX_CREATURES(PLAYER1,20)
MAX_CREATURES(PLAYER2,20)

SET_GAME_RULE(MapCreatureLimit,1000)

COMPUTER_PLAYER(PLAYER0,7)
COMPUTER_PLAYER(PLAYER1,7)
COMPUTER_PLAYER(PLAYER2,7)

QUICK_OBJECTIVE(1,"Since you are connected to the Heroes Dungeon, your goal is to survive its onslaughts and destroy it to conquer further! But be aware since a big War can tear open some unwanted paths to unwanted guests...",PLAYER5)

SET_GAME_RULE(AlliesShareVision,1)
SET_GAME_RULE(AlliesShareCta,1)
SET_GAME_RULE(AlliesShareDrop,1)
ALLY_PLAYERS(PLAYER0,PLAYER1,3)
ALLY_PLAYERS(PLAYER0,PLAYER2,3)
ALLY_PLAYERS(PLAYER1,PLAYER0,3)
ALLY_PLAYERS(PLAYER1,PLAYER2,3)
ALLY_PLAYERS(PLAYER2,PLAYER1,3)
ALLY_PLAYERS(PLAYER2,PLAYER0,3)

ADD_CREATURE_TO_POOL(FLY,20)
ADD_CREATURE_TO_POOL(BUG,20)
ADD_CREATURE_TO_POOL(DEMONSPAWN,20)
ADD_CREATURE_TO_POOL(TROLL,20)
ADD_CREATURE_TO_POOL(SPIDER,20)
ADD_CREATURE_TO_POOL(HELL_HOUND,20)
ADD_CREATURE_TO_POOL(TENTACLE,20)
ADD_CREATURE_TO_POOL(SORCEROR,20)
ADD_CREATURE_TO_POOL(ORC,20)
ADD_CREATURE_TO_POOL(BILE_DEMON,20)
ADD_CREATURE_TO_POOL(DRAGON,20)
ADD_CREATURE_TO_POOL(DARK_MISTRESS,20)
ADD_CREATURE_TO_POOL(THIEF,20)
ADD_CREATURE_TO_POOL(DWARFA,20)
ADD_CREATURE_TO_POOL(ARCHER,20)
ADD_CREATURE_TO_POOL(BARBARIAN,20)
ADD_CREATURE_TO_POOL(MONK,20)
ADD_CREATURE_TO_POOL(FAIRY,20)
ADD_CREATURE_TO_POOL(WIZARD,20)
ADD_CREATURE_TO_POOL(GIANT,20)
ADD_CREATURE_TO_POOL(SAMURAI,20)

CREATURE_AVAILABLE(PLAYER0,AACOLYTE,1,0)
CREATURE_AVAILABLE(PLAYER0,AASSASSIN,1,0)
CREATURE_AVAILABLE(PLAYER0,AEXECUTIONER,1,0)
CREATURE_AVAILABLE(PLAYER0,AMERCENARY,1,0)
CREATURE_AVAILABLE(PLAYER0,ANECROMANCER,1,0)
CREATURE_AVAILABLE(PLAYER0,ANECROMANCERZOMBIE,1,0)
CREATURE_AVAILABLE(PLAYER0,APLAGUEDOCTOR,1,0)
CREATURE_AVAILABLE(PLAYER0,ASERVANT,1,0)
CREATURE_AVAILABLE(PLAYER0,AWARLOCK,1,0)
CREATURE_AVAILABLE(PLAYER0,AWITCH,1,0)
CREATURE_AVAILABLE(PLAYER0,ATYRANT,1,0)
CREATURE_AVAILABLE(PLAYER0,AVIXEN,1,0)
CREATURE_AVAILABLE(PLAYER2,TROLL,1,0)
CREATURE_AVAILABLE(PLAYER2,SPIDER,1,0)
CREATURE_AVAILABLE(PLAYER2,TENTACLE,1,0)
CREATURE_AVAILABLE(PLAYER2,SORCEROR,1,0)
CREATURE_AVAILABLE(PLAYER2,ORC,1,0)
CREATURE_AVAILABLE(PLAYER2,BILE_DEMON,1,0)
CREATURE_AVAILABLE(PLAYER2,DRAGON,1,0)
CREATURE_AVAILABLE(PLAYER2,DARK_MISTRESS,1,0)
CREATURE_AVAILABLE(PLAYER1,THIEF,1,0)
CREATURE_AVAILABLE(PLAYER1,DWARFA,1,0)
CREATURE_AVAILABLE(PLAYER1,ARCHER,1,0)
CREATURE_AVAILABLE(PLAYER1,BARBARIAN,1,0)
CREATURE_AVAILABLE(PLAYER1,MONK,1,0)
CREATURE_AVAILABLE(PLAYER1,FAIRY,1,0)
CREATURE_AVAILABLE(PLAYER1,WITCH,1,0)
CREATURE_AVAILABLE(PLAYER1,WIZARD,1,0)
CREATURE_AVAILABLE(PLAYER1,GIANT,1,0)
CREATURE_AVAILABLE(PLAYER1,SAMURAI,1,0)

ADD_CREATURE_TO_POOL(AACOLYTE,40)
ADD_CREATURE_TO_POOL(AASSASSIN,40)
ADD_CREATURE_TO_POOL(AEXECUTIONER,40)
ADD_CREATURE_TO_POOL(AMERCENARY,40)
ADD_CREATURE_TO_POOL(ANECROMANCER,40)
ADD_CREATURE_TO_POOL(ANECROMANCERZOMBIE,40)
ADD_CREATURE_TO_POOL(APLAGUEDOCTOR,40)
ADD_CREATURE_TO_POOL(ASERVANT,40)
ADD_CREATURE_TO_POOL(AWARLOCK,40)
ADD_CREATURE_TO_POOL(AWITCH,40)
ADD_CREATURE_TO_POOL(ATYRANT,40)
ADD_CREATURE_TO_POOL(AVIXEN,40)

CREATURE_AVAILABLE(PLAYER5,AACOLYTE,1,0)
CREATURE_AVAILABLE(PLAYER5,AASSASSIN,1,0)
CREATURE_AVAILABLE(PLAYER5,AEXECUTIONER,1,0)
CREATURE_AVAILABLE(PLAYER5,AMERCENARY,1,0)
CREATURE_AVAILABLE(PLAYER5,ANECROMANCER,1,0)
CREATURE_AVAILABLE(PLAYER5,ANECROMANCERZOMBIE,1,0)
CREATURE_AVAILABLE(PLAYER5,APLAGUEDOCTOR,1,0)
CREATURE_AVAILABLE(PLAYER5,ASERVANT,1,0)
CREATURE_AVAILABLE(PLAYER5,AWARLOCK,1,0)
CREATURE_AVAILABLE(PLAYER5,AWITCH,1,0)
CREATURE_AVAILABLE(PLAYER5,ATYRANT,1,0)
CREATURE_AVAILABLE(PLAYER5,AVIXEN,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(ALL_PLAYERS,GUARD_POST,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,WORKSHOP,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,PRISON,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(ALL_PLAYERS,SCAVENGER,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,GRAVEYARD,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_CONCEAL,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CAVE_IN,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HEAL_CREATURE,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_LIGHTNING,1,0)
MAGIC_AVAILABLE(PLAYER1,POWER_LIGHTNING,1,0)
MAGIC_AVAILABLE(PLAYER2,POWER_LIGHTNING,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_PROTECT,1,0)

TRAP_AVAILABLE(ALL_PLAYERS,POISON_GAS,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,LIGHTNING,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,BOULDER,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 PARTYTIIIIME

CREATE_PARTY(weak)
	ADD_TO_PARTY(weak,DWARFA,1,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(weak,THIEF,1,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(weak,DWARFA,1,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(weak,THIEF,1,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(weak,ARCHER,1,250,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(weak1)
	ADD_TO_PARTY(weak1,BARBARIAN,1,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(weak1,WIZARD,1,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(weak1,BARBARIAN,1,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(weak1,WIZARD,1,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(weak1,SAMURAI,1,250,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(weak2)
	ADD_TO_PARTY(weak2,DRUID,3,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(weak2,GIANT,3,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(weak2,DRUID,3,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(weak2,GIANT,3,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(weak2,FAIRY,3,250,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(weak3)
	ADD_TO_PARTY(weak3,WITCH,3,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(weak3,MONK,3,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(weak3,WITCH,3,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(weak3,MONK,3,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(weak3,TIME_MAGE,3,250,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(diebe)
	ADD_TO_PARTY(diebe,THIEF,5,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(diebe,THIEF,5,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(diebe,THIEF,5,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(diebe,THIEF,5,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(diebe,THIEF,5,250,ATTACK_DUNGEON_HEART,0)


CREATE_PARTY(bogen)
	ADD_TO_PARTY(bogen,ARCHER,5,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(bogen,ARCHER,5,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(bogen,ARCHER,5,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(bogen,ARCHER,5,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(bogen,ARCHER,5,250,ATTACK_DUNGEON_HEART,0)


CREATE_PARTY(medium)
	ADD_TO_PARTY(medium,BARBARIAN,7,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(medium,WITCH,7,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(medium,BARBARIAN,7,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(medium,WITCH,7,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(medium,SAMURAI,7,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(medium,SAMURAI,7,250,ATTACK_DUNGEON_HEART,0)


CREATE_PARTY(medium1)
	ADD_TO_PARTY(medium1,GIANT,7,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(medium1,GIANT,7,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(medium1,WIZARD,7,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(medium1,WIZARD,7,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(medium1,DWARFA,7,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(medium1,DWARFA,7,250,ATTACK_DUNGEON_HEART,0)


CREATE_PARTY(Medium2)
	ADD_TO_PARTY(Medium2,KNIGHT,8,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(Medium2,FAIRY,8,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(Medium2,FAIRY,8,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(Medium2,ARCHER,8,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(Medium2,ARCHER,8,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(Medium2,SAMURAI,8,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(Medium2,SAMURAI,8,250,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(hard)
	ADD_TO_PARTY(hard,KNIGHT,9,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(hard,FAIRY,9,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(hard,FAIRY,9,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(hard,ARCHER,9,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(hard,ARCHER,9,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(hard,SAMURAI,9,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(hard,SAMURAI,9,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(hard,TIME_MAGE,9,250,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(hard1)
	ADD_TO_PARTY(hard1,KNIGHT,10,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(hard1,FAIRY,10,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(hard1,FAIRY,10,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(hard1,ARCHER,10,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(hard1,ARCHER,10,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(hard1,SAMURAI,10,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(hard1,SAMURAI,10,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(hard1,BARBARIAN,10,250,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(hard1,BARBARIAN,10,250,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(defense)
	ADD_TO_PARTY(defense,AVATAR,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(defense,KNIGHT,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(defense,KNIGHT,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(defense,ARCHER,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(defense,ARCHER,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(defense,SAMURAI,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(defense,SAMURAI,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(defense,FAIRY,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(defense,WITCH,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(defense,WITCH,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(defense,FAIRY,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(defense,HORNY,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(defense,HORNY,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(defense,GIANT,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(defense,GIANT,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(defense,WIZARD,10,250,DEFEND_HEART,0)
	ADD_TO_PARTY(defense,WIZARD,10,250,DEFEND_HEART,0)


REM Timers
IF(PLAYER_GOOD,DUNGEON_DESTROYED == 0)
	IF(PLAYER5,ENTRANCE >= 1)
		SET_TIMER(PLAYER5,TIMER0)
	ENDIF

	IF(PLAYER5,TIMER0 >= 6000)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,weak,-1,1)
		SET_TIMER(PLAYER5,TIMER1)
	ENDIF

	IF(PLAYER5,TIMER1 >= 5000)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,weak1,-2,1)
		SET_TIMER(PLAYER5,TIMER2)
	ENDIF

	IF(PLAYER5,TIMER2 >= 5500)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,weak,-1,1)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,weak1,-2,1)
		SET_TIMER(PLAYER5,TIMER3)
		SET_TIMER(PLAYER5,TIMER4)
	ENDIF

	IF(PLAYER5,TIMER3 >= 4000)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,weak2,-1,1)
		SET_TIMER(PLAYER5,TIMER5)
	ENDIF

	IF(PLAYER5,TIMER4 >= 5500)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,weak3,-2,1)
		SET_TIMER(PLAYER5,TIMER6)
	ENDIF

	IF(PLAYER5,TIMER5 >= 4000)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,weak3,-2,1)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,weak2,-1,1)
	ENDIF

	IF(PLAYER5,TIMER6 >= 7500)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,diebe,-2,1)
		SET_TIMER(PLAYER5,TIMER7)
	ENDIF

	IF(PLAYER5,TIMER7 >= 4500)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,bogen,-3,1)
		SET_TIMER(PLAYER0,TIMER0)
	ENDIF

	IF(PLAYER0,TIMER0 >= 4000)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,diebe,-1,1)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,bogen,-2,1)
		SET_TIMER(PLAYER0,TIMER1)
		SET_TIMER(PLAYER0,TIMER2)
	ENDIF

	IF(PLAYER0,TIMER1 >= 5500)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,medium,-1,1)
	ENDIF

	IF(PLAYER0,TIMER2 >= 7500)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,medium1,-2,1)
		SET_TIMER(PLAYER0,TIMER3)
	ENDIF

	IF(PLAYER0,TIMER3 >= 4500)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Medium2,-2,1)
		SET_TIMER(PLAYER0,TIMER4)
	ENDIF

	IF(PLAYER0,TIMER4 >= 5000)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,hard,-3,1)
		SET_TIMER(PLAYER0,TIMER5)
	ENDIF

	IF(PLAYER0,TIMER5 >= 5500)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,hard1,-3,1)
		SET_TIMER(PLAYER0,TIMER6)
	ENDIF

	IF(PLAYER0,TIMER6 >= 5500)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,hard1,-3,1)
	SET_TIMER(PLAYER0,TIMER7)
	ENDIF

	IF(PLAYER0,TIMER7 >= 6500)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,hard1,-2,1)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,hard1,-1,1)
		NEXT_COMMAND_REUSABLE
		SET_TIMER(PLAYER0,TIMER7)
	ENDIF
ENDIF

IF_ACTION_POINT(2,PLAYER5)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,hard1,-3,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,defense,1,1)
ENDIF


REM Imp limitation
IF_CONTROLS(PLAYER0,IMP < 20)
  NEXT_COMMAND_REUSABLE
  MAGIC_AVAILABLE(PLAYER0,POWER_IMP,1,1)
 ENDIF

IF_CONTROLS(PLAYER0,IMP >= 20)
  NEXT_COMMAND_REUSABLE
  MAGIC_AVAILABLE(PLAYER0,POWER_IMP,0,0)
ENDIF

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

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

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

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

IF_CONTROLS(PLAYER5,IMP < 30)
  NEXT_COMMAND_REUSABLE
  MAGIC_AVAILABLE(PLAYER5,POWER_IMP,1,1)
 ENDIF

IF_CONTROLS(PLAYER5,IMP >= 30)
  NEXT_COMMAND_REUSABLE
  MAGIC_AVAILABLE(PLAYER5,POWER_IMP,0,0)
ENDIF


IF(PLAYER_GOOD,DUNGEON_DESTROYED == 1)
	CHANGE_SLAB_TYPE(45,42,DIRT,MATCH)
	CHANGE_SLAB_TYPE(57,41,DIRT,MATCH)
	COMPUTER_PLAYER(PLAYER0,0)
	COMPUTER_PLAYER(PLAYER1,0)
	COMPUTER_PLAYER(PLAYER2,0)
	QUICK_INFORMATION(2,"The Earth is shook,the Ceiling collapsed. It Looks like all the Lava got shutdown and Opened up new Enemies!",LAST_EVENT)
ENDIF

IF(PLAYER5,ALL_DUNGEONS_DESTROYED == 1)
	WIN_GAME
ENDIF
