LEVEL_VERSION(1)
SET_GENERATE_SPEED(400)
START_MONEY(PLAYER5,22500)
START_MONEY(PLAYER0,2222500)
START_MONEY(PLAYER1,2222500)
MAX_CREATURES(PLAYER5,25)
MAX_CREATURES(PLAYER1,20)
MAX_CREATURES(PLAYER0,20)

COMPUTER_PLAYER(PLAYER1,0)
COMPUTER_PLAYER(PLAYER0,0)

SET_GAME_RULE(AlliesShareCta,1)
SET_GAME_RULE(AlliesShareDrop,1)
SET_GAME_RULE(AlliesShareVision,1)
SET_GAME_RULE(MapCreatureLimit,1000)

ALLY_PLAYERS(PLAYER0,PLAYER1,3)
ALLY_PLAYERS(PLAYER1,PLAYER0,3)


SET_CREATURE_HEALTH(AVATAR,12000)
SET_CREATURE_ARMOUR(AVATAR,250)
SET_CREATURE_PROPERTY(KNIGHT,LORD,0)
SET_CREATURE_PROPERTY(AVATAR,NO_IMPRISONMENT,1)

QUICK_OBJECTIVE(1,"Now it is all or Nothing.Build up, kill the Twin Avatars and the Twin Keepers to Domninate the World!")


ADD_CREATURE_TO_POOL(TROLL,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(VAMPIRE,20)
ADD_CREATURE_TO_POOL(WIZARD,20)
ADD_CREATURE_TO_POOL(KNIGHT,20)

CREATURE_AVAILABLE(PLAYER0,TROLL,1,0)
CREATURE_AVAILABLE(PLAYER0,ORC,1,0)
CREATURE_AVAILABLE(PLAYER0,BILE_DEMON,1,0)
CREATURE_AVAILABLE(PLAYER0,DRAGON,1,0)
CREATURE_AVAILABLE(PLAYER0,DARK_MISTRESS,1,0)
CREATURE_AVAILABLE(PLAYER0,VAMPIRE,1,0)
CREATURE_AVAILABLE(PLAYER0,WIZARD,1,0)
CREATURE_AVAILABLE(PLAYER0,KNIGHT,1,0)

CREATURE_AVAILABLE(PLAYER1,TROLL,1,0)
CREATURE_AVAILABLE(PLAYER1,ORC,1,0)
CREATURE_AVAILABLE(PLAYER1,BILE_DEMON,1,0)
CREATURE_AVAILABLE(PLAYER1,DRAGON,1,0)
CREATURE_AVAILABLE(PLAYER1,DARK_MISTRESS,1,0)
CREATURE_AVAILABLE(PLAYER1,VAMPIRE,1,0)
CREATURE_AVAILABLE(PLAYER1,WIZARD,1,0)
CREATURE_AVAILABLE(PLAYER1,KNIGHT,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)
ADD_CREATURE_TO_POOL(DBBLACKKNIGHT,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)
CREATURE_AVAILABLE(PLAYER5,DBBLACKKNIGHT,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(PLAYER0,TRAINING,1,1)
ROOM_AVAILABLE(PLAYER1,TRAINING,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,RESEARCH,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,WORKSHOP,1,0)
ROOM_AVAILABLE(PLAYER0,PRISON,1,0)
ROOM_AVAILABLE(PLAYER1,PRISON,1,0)
ROOM_AVAILABLE(PLAYER0,TORTURE,1,0)
ROOM_AVAILABLE(PLAYER1,TORTURE,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,BARRACKS,1,0)
ROOM_AVAILABLE(PLAYER0,GRAVEYARD,1,0)
ROOM_AVAILABLE(PLAYER1,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_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_HOLD_AUDIENCE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CAVE_IN,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HEAL_CREATURE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_LIGHTNING,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_PROTECT,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CHICKEN,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_DISEASE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_ARMAGEDDON,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_SIGHT,1,1)
MAGIC_AVAILABLE(PLAYER1,POWER_SIGHT,1,1)

TRAP_AVAILABLE(PLAYER5,POISON_GAS,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,LIGHTNING,1,0)
TRAP_AVAILABLE(PLAYER0,BOULDER,1,0)
TRAP_AVAILABLE(PLAYER5,BOULDER,1,0)
TRAP_AVAILABLE(PLAYER0,WORD_OF_POWER,1,0)
TRAP_AVAILABLE(PLAYER1,WORD_OF_POWER,1,0)

DOOR_AVAILABLE(ALL_PLAYERS,MAGIC,1,0)

CREATE_PARTY(p1)
	ADD_TO_PARTY(p1,ARCHER,1,300,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p1,BARBARIAN,1,300,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p1,MONK,1,300,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p1,WIZARD,1,300,ATTACK_DUNGEON_HEART,0)


CREATE_PARTY(p2)
	ADD_TO_PARTY(p2,WITCH,3,300,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p2,WITCH,3,300,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p2,SAMURAI,3,300,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p2,GIANT,3,300,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p2,DWARFA,3,300,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(p3)
	ADD_TO_PARTY(p3,KNIGHT,5,500,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p3,ARCHER,5,500,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p3,FAIRY,5,500,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p3,FAIRY,5,500,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p3,THIEF,5,500,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p3,THIEF,5,500,ATTACK_DUNGEON_HEART,0)
	
CREATE_PARTY(p4)
	ADD_TO_PARTY(p4,KNIGHT,8,800,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p4,WIZARD,8,800,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p4,WIZARD,8,800,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p4,SAMURAI,8,800,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p4,SAMURAI,8,800,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p4,MONK,8,800,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p4,MONK,8,800,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p4,TIME_MAGE,8,800,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(p5)
	ADD_TO_PARTY(p5,KNIGHT,10,800,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p5,FAIRY,10,800,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p5,FAIRY,10,800,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p5,BARBARIAN,10,800,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p5,BARBARIAN,10,800,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p5,GIANT,10,800,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p5,GIANT,10,800,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p5,DWARFA,10,800,ATTACK_DUNGEON_HEART,0)
	ADD_TO_PARTY(p5,DWARFA,10,800,ATTACK_DUNGEON_HEART,0)

REM ROOM CONDITIONS HUMAN PLAYER


IF_ACTION_POINT(2,PLAYER5)
	QUICK_OBJECTIVE(2,"You Managed to Safely get some Gems, maybe if you look around you can find a Bridge to get into the Heroes outpost...")
ENDIF


IF(PLAYER5,TRAINING >= 1)
	ROOM_AVAILABLE(PLAYER5,TRAINING,1,1)
	SET_TIMER(PLAYER0,TIMER0)
ENDIF

IF(PLAYER5,PRISON >= 1)
	ROOM_AVAILABLE(PLAYER5,PRISON,1,1)
ENDIF

IF(PLAYER5,TORTURE >= 1)
	ROOM_AVAILABLE(PLAYER5,TORTURE,1,1)
ENDIF

IF(PLAYER5,TEMPLE >= 1)
	ROOM_AVAILABLE(PLAYER5,TEMPLE,1,1)
ENDIF

IF(PLAYER5,BRIDGE >= 1)
	ROOM_AVAILABLE(PLAYER5,BRIDGE,1,1)
ENDIF


REM Imp Limitation


IF_CONTROLS(PLAYER5,ASLAVE < 25)
  NEXT_COMMAND_REUSABLE
  MAGIC_AVAILABLE(PLAYER5,POWER_IMP,1,1)
 ENDIF

IF_CONTROLS(PLAYER5,ASLAVE >= 25)
  NEXT_COMMAND_REUSABLE
  MAGIC_AVAILABLE(PLAYER5,POWER_IMP,0,0)
ENDIF

IF_CONTROLS(PLAYER0,ASLAVE < 16)
  NEXT_COMMAND_REUSABLE
  MAGIC_AVAILABLE(PLAYER0,POWER_IMP,1,1)
 ENDIF

IF_CONTROLS(PLAYER0,ASLAVE >= 16)
  NEXT_COMMAND_REUSABLE
  MAGIC_AVAILABLE(PLAYER0,POWER_IMP,0,0)
ENDIF

IF_CONTROLS(PLAYER1,ASLAVE < 16)
  NEXT_COMMAND_REUSABLE
  MAGIC_AVAILABLE(PLAYER1,POWER_IMP,1,1)
 ENDIF

IF_CONTROLS(PLAYER1,ASLAVE >= 16)
  NEXT_COMMAND_REUSABLE
  MAGIC_AVAILABLE(PLAYER1,POWER_IMP,0,0)
ENDIF


IF(PLAYER0,TIMER0 >= 10000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,p1,-2,DUNGEON_HEART,5,1,2500)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,p1,-3,DUNGEON_HEART,5,1,2500)
	SET_TIMER(PLAYER0,TIMER1)
ENDIF

IF(PLAYER0,TIMER1 >= 5000)
	ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,p2,-4,DUNGEON_HEART,5,3,2500)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,p2,-1,1)
	SET_TIMER(PLAYER0,TIMER2)
ENDIF

IF(PLAYER0,TIMER2 >= 6500)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,p3,-2,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,p3,-4,1)
	SET_TIMER(PLAYER0,TIMER3)
ENDIF

IF(PLAYER0,TIMER3 >= 8000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,p4,-1,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,p4,-3,1)
	QUICK_INFORMATION(3,"Looks like its their Last offense for now... but for how long?",LAST_EVENT)
	SET_DOOR(UNLOCKED,61,42)
	SET_DOOR(UNLOCKED,64,42)
ENDIF

IF_CONTROLS(PLAYER_GOOD,AVATAR == 0)
	QUICK_INFORMATION(4,"The Twins got defeated but no Corpse where found... Suspicious...")
	PLAY_MESSAGE(PLAYER5,SPEECH,108)
ENDIF

IF(PLAYER0,DUNGEON_DESTROYED == 1)
	ADD_TO_FLAG(PLAYER0,FLAG0,1)
ENDIF

IF(PLAYER1,DUNGEON_DESTROYED == 1)
	ADD_TO_FLAG(PLAYER0,FLAG0,1)
ENDIF

IF(PLAYER_GOOD,DUNGEON_DESTROYED == 1)
	ADD_TO_FLAG(PLAYER0,FLAG0,1)
ENDIF

IF(PLAYER0,FLAG0 >= 3)
	QUICK_INFORMATION(5,"All Hearts are destroyed... but still no win... maybe it has something to do with the Twin-Avatars")
	SET_TIMER(PLAYER_GOOD,TIMER0)
	SET_MUSIC("8")
ENDIF

IF(PLAYER_GOOD,TIMER0 >= 3500)
	QUICK_INFORMATION(6,"Watch out my Lord! They Attempt one last BIG offense to take you down!")
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,p5,1,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,p5,-1,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,p5,-2,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,p5,-3,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,p5,-4,1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,p5,-5,1)
	ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,AVATAR,1,2,10,5000)
	PLAY_MESSAGE(PLAYER5,SPEECH,92)
ENDIF

IF(PLAYER5,ALL_DUNGEONS_DESTROYED == 1)
	IF(PLAYER_GOOD,BATTLES_LOST == 224)
		WIN_GAME
	ENDIF
ENDIF




