REM KDK Level 3

SET_GENERATE_SPEED(400)
MAX_CREATURES(PLAYER0,16)
START_MONEY(PLAYER0,5500)

ADD_CREATURE_TO_POOL(BUG,13)
ADD_CREATURE_TO_POOL(SPIDER,8)
ADD_CREATURE_TO_POOL(BILE_DEMON,14)
ADD_CREATURE_TO_POOL(TROLL,10)
ADD_CREATURE_TO_POOL(FLY,13)
ADD_CREATURE_TO_POOL(DEMONSPAWN,14)
ADD_CREATURE_TO_POOL(SORCEROR,11)

SET_CREATURE_MAX_LEVEL(PLAYER0,DEMONSPAWN,10)

CREATURE_AVAILABLE(PLAYER0,TROLL,1,1)
CREATURE_AVAILABLE(PLAYER0,SPIDER,1,1)
CREATURE_AVAILABLE(PLAYER0,BUG,1,1)
CREATURE_AVAILABLE(PLAYER0,BILE_DEMON,1,1)
CREATURE_AVAILABLE(PLAYER0,SORCEROR,1,1)
CREATURE_AVAILABLE(PLAYER0,FLY,1,1)
CREATURE_AVAILABLE(PLAYER0,DEMONSPAWN,1,1)
CREATURE_AVAILABLE(PLAYER0,DRAGON,1,1)

MAGIC_AVAILABLE(PLAYER0,POWER_HAND,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_SLAP,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_POSSESS,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_SPEED,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_HOLD_AUDIENCE,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_PROTECT,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_LIGHTNING,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_IMP,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_SIGHT,1,0)

ROOM_AVAILABLE(PLAYER0,TRAINING,1,1)
ROOM_AVAILABLE(PLAYER0,TREASURE,1,1)
ROOM_AVAILABLE(PLAYER0,GARDEN,1,1)
ROOM_AVAILABLE(PLAYER0,RESEARCH,1,1)
ROOM_AVAILABLE(PLAYER0,LAIR,1,1)
ROOM_AVAILABLE(PLAYER0,BRIDGE,1,0)
ROOM_AVAILABLE(PLAYER0,WORKSHOP,1,0)

TRAP_AVAILABLE(PLAYER0,ALARM,1,0)
TRAP_AVAILABLE(PLAYER0,POISON_GAS,1,0)
TRAP_AVAILABLE(PLAYER0,LIGHTNING,1,0)
DOOR_AVAILABLE(PLAYER0,BRACED,1,0)
DOOR_AVAILABLE(PLAYER0,MAGIC,1,0)
DOOR_AVAILABLE(PLAYER0,WOOD,1,0)

SET_CREATURE_MAX_LEVEL(PLAYER_GOOD,KNIGHT,2)
SET_CREATURE_MAX_LEVEL(PLAYER_GOOD,THIEF,2)
SET_CREATURE_MAX_LEVEL(PLAYER_GOOD,DWARFA,2)
SET_CREATURE_MAX_LEVEL(PLAYER_GOOD,TUNNELLER,2)
SET_CREATURE_MAX_LEVEL(PLAYER_GOOD,ARCHER,2)
SET_CREATURE_STRENGTH(KNIGHT,70)
SET_CREATURE_ARMOUR(KNIGHT,80)

CREATE_PARTY(THIEVES)
    ADD_TO_PARTY(THIEVES,THIEF,1,200,STEAL_GOLD,0)
    ADD_TO_PARTY(THIEVES,ARCHER,1,200,ATTACK_ENEMIES,0)

CREATE_PARTY(DWARVES)
    ADD_TO_PARTY(DWARVES,DWARFA,1,200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DWARVES,DWARFA,1,200,ATTACK_ENEMIES,0)

CREATE_PARTY(ELITE)
    ADD_TO_PARTY(ELITE,DWARFA,1,200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ELITE,THIEF,1,200,ATTACK_ENEMIES,0)

CREATE_PARTY(KNIGHT)
    ADD_TO_PARTY(KNIGHT,ARCHER,1,200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(KNIGHT,KNIGHT,1,2000,ATTACK_ENEMIES,0)

CREATE_PARTY(DOOM1)
    ADD_TO_PARTY(DOOM1,DWARFA,1,480,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM1,DWARFA,2,530,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM1,DWARFA,2,550,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM1,DWARFA,3,600,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM1,DWARFA,3,710,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM1,DWARFA,2,670,ATTACK_ENEMIES,0)

CREATE_PARTY(DOOM4)
    ADD_TO_PARTY(DOOM4,MONK,2,300,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(DOOM4,THIEF,5,800,STEAL_GOLD,0)
    ADD_TO_PARTY(DOOM4,THIEF,3,600,STEAL_SPELLS,0)
    ADD_TO_PARTY(DOOM4,SAMURAI,2,670,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM4,MONK,3,750,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM4,WIZARD,4,100,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM4,ARCHER,3,400,ATTACK_ENEMIES,0)

CREATE_PARTY(DOOM6)
    ADD_TO_PARTY(DOOM6,MONK,3,150,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM6,MONK,5,300,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM6,WIZARD,1,650,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM6,WITCH,4,1750,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(DOOM6,BARBARIAN,4,600,ATTACK_ROOMS,0)
    ADD_TO_PARTY(DOOM6,ARCHER,3,440,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM6,BARBARIAN,5,1050,ATTACK_ROOMS,0)

CREATE_PARTY(DOOM8)
    ADD_TO_PARTY(DOOM8,WIZARD,1,50,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM8,SAMURAI,3,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM8,WIZARD,2,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM8,WIZARD,4,700,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM8,WIZARD,4,700,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM8,WIZARD,4,700,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM8,TUNNELLER,2,90,ATTACK_ENEMIES,0)

CREATE_PARTY(DOOM10)
    ADD_TO_PARTY(DOOM10,THIEF,4,1600,STEAL_GOLD,0)
    ADD_TO_PARTY(DOOM10,THIEF,1,883,STEAL_GOLD,0)
    ADD_TO_PARTY(DOOM10,BARBARIAN,2,230,DEFEND_PARTY,0)
    ADD_TO_PARTY(DOOM10,ARCHER,3,80,DEFEND_PARTY,0)
    ADD_TO_PARTY(DOOM10,MONK,4,360,DEFEND_PARTY,0)
    ADD_TO_PARTY(DOOM10,MONK,4,110,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM10,MONK,6,0,ATTACK_ENEMIES,0)

CREATE_PARTY(DOOM12)
    ADD_TO_PARTY(DOOM12,WIZARD,4,260,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM12,BARBARIAN,2,300,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM12,BARBARIAN,4,300,ATTACK_ROOMS,0)
    ADD_TO_PARTY(DOOM12,THIEF,6,3200,STEAL_GOLD,0)
    ADD_TO_PARTY(DOOM12,WITCH,4,800,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM12,ARCHER,7,750,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM12,ARCHER,2,600,ATTACK_ENEMIES,0)

CREATE_PARTY(DOOM14)
    ADD_TO_PARTY(DOOM14,THIEF,5,1000,STEAL_GOLD,0)
    ADD_TO_PARTY(DOOM14,THIEF,2,1000,STEAL_SPELLS,0)
    ADD_TO_PARTY(DOOM14,ARCHER,6,1120,DEFEND_PARTY,0)
    ADD_TO_PARTY(DOOM14,WIZARD,4,350,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM14,TUNNELLER,1,30,DEFEND_PARTY,0)
    ADD_TO_PARTY(DOOM14,WITCH,2,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM14,DWARFA,2,240,ATTACK_ENEMIES,0)

CREATE_PARTY(DOOM16)
    ADD_TO_PARTY(DOOM16,BARBARIAN,4,800,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM16,ARCHER,6,1444,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM16,ARCHER,6,1918,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM16,ARCHER,2,320,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM16,MONK,3,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM16,MONK,5,200,ATTACK_ENEMIES,0)

CREATE_PARTY(DOOM17)
    ADD_TO_PARTY(DOOM17,WIZARD,4,330,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM17,BARBARIAN,5,743,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM17,ARCHER,1,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM17,MONK,4,160,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM17,WITCH,2,590,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DOOM17,THIEF,1,117,STEAL_GOLD,0)
    ADD_TO_PARTY(DOOM17,SAMURAI,4,610,ATTACK_ENEMIES,0)


REM CREATE_TEXT(1,34"BUILD A DUNGEON WITH A TREASURE ROOM, A LAIR, A HATCHERY AND A TRAINING ROOM.  MAKE SURE ALL ROOMS ARE AT LEAST 9 BLOCKS IN SIZE.")
DISPLAY_OBJECTIVE(34,PLAYER0)

IF(PLAYER0,TREASURE >= 9)
    SET_FLAG(PLAYER0,FLAG0,1)
ENDIF

IF(PLAYER0,LAIR >= 9)
    SET_FLAG(PLAYER0,FLAG1,1)
ENDIF

IF(PLAYER0,GARDEN >= 9)
    SET_FLAG(PLAYER0,FLAG2,1)
ENDIF

IF(PLAYER0,TRAINING >= 9)
    SET_FLAG(PLAYER0,FLAG3,1)
ENDIF

IF(PLAYER0,ENTRANCE > 0)
    SET_FLAG(PLAYER0,FLAG4,1)
ENDIF


IF(PLAYER0,FLAG0 == 1)
    IF(PLAYER0,FLAG1 == 1)
        IF(PLAYER0,FLAG2 == 1)
            IF(PLAYER0,FLAG3 == 1)
                IF(PLAYER0,FLAG4 == 1)
                    REM CREATE_TEXT(11,35"YOU CAN NOW BUILD A RESEARCH ROOM.  LAY ONE DOWN, MAKING SURE THAT IT IS ALSO AT LEAST 9 BLOCKS IN SIZE.")
                    DISPLAY_OBJECTIVE(35,PLAYER0)
                    TUTORIAL_FLASH_BUTTON(9,-1)
                    SET_FLAG(PLAYER0,FLAG6,1)
                ENDIF
            ENDIF
        ENDIF
    ENDIF
ENDIF


IF(PLAYER0,FLAG6 == 0)
    IF(PLAYER0,GAME_TURN > 12000)
        IF(PLAYER0,TREASURE > 0)
            IF(PLAYER0,LAIR > 0)
                IF(PLAYER0,GARDEN > 0)
                    IF(PLAYER0,TRAINING > 0)
                        IF(PLAYER0,ENTRANCE > 0)
                            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DOOM1,1,1)
                        ENDIF
                    ENDIF
                ENDIF
            ENDIF
        ENDIF
    ENDIF
ENDIF

IF(PLAYER0,RESEARCH > 0)
    REM CREATE_TEXT(31,36"THE NEW RESEARCH ROOM WILL ATTRACT CREATURES THAT LIKE TO RESEARCH SPELLS AND NEW ROOMS, LIKE SORCERORS.")
    DISPLAY_INFORMATION(36,PLAYER0)
    SET_TIMER(PLAYER0,TIMER6)
ENDIF

IF(PLAYER0,RESEARCH >= 9)
    IF(PLAYER0,FLAG7 == 0)
        SET_FLAG(PLAYER0,FLAG7,1)
    ENDIF
ENDIF

IF(PLAYER0,TIMER6 > 6000)
    IF(PLAYER0,FLAG7 == 0)
        SET_FLAG(PLAYER0,FLAG7,1)
    ENDIF
ENDIF

IF(PLAYER0,FLAG7 == 1)
    SET_FLAG(PLAYER0,FLAG5,1)
    REM CREATE_TEXT(32,37"WELL DONE.  YOU CAN NOW DROP MOST CREATURES IN HERE TO RESEARCH.  HOWEVER, SORCERORS MAKE THE BEST RESEARCHERS".)
    DISPLAY_OBJECTIVE(37,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DOOM4,1,1)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DOOM6,1,1)
    MAX_CREATURES(PLAYER0,34)
ENDIF

IF(PLAYER0,TOTAL_CREATURES >= 16)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DOOM8,1,1)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DOOM10,1,1)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DOOM12,1,1)
ENDIF

IF(PLAYER0,SORCEROR > 0)
    REM CREATE_TEXT(12,38"A SORCEROR HAS JOINED YOU, ATTRACTED TO YOUR DUNGEON BY THE RESEARCH ROOM.  THEY MAKE EXCELLENT RESEARCHERS AND ONCE TRAINED, SUPERB LONG RANGE FIGHTERS.")
    DISPLAY_OBJECTIVE(38,PLAYER0)
    SET_TIMER(PLAYER0,TIMER2)
ENDIF

IF(PLAYER0,TIMER2 >= 3750)
    REM CREATE_TEXT(33,43"BE PATIENT, HEROES ARE SOON TO COME. MAKE SURE YOUR CREATURES ARE TRAINED. (MAYBE TRY TRAINING A SORCEROR!).")
    DISPLAY_OBJECTIVE(43,PLAYER0)
ENDIF

IF(PLAYER0,TIMER2 >= 5000)
    IF(PLAYER_GOOD,FLAG0 == 0)
        SET_FLAG(PLAYER_GOOD,FLAG1,1)
        ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,THIEVES,-1,DUNGEON,0,1,500)
        ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,DWARVES,-1,DUNGEON,0,1,2000)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DOOM14,1,1)
        IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
            REM CREATE_TEXT(14,39"THE FIRST WAVE OF ATTACKERS LIE DEAD.  PREPARE FOR THE NEXT ASSAULT.")
            DISPLAY_OBJECTIVE(39,PLAYER0)
            SET_TIMER(PLAYER0,TIMER3)
            IF(PLAYER0,TIMER3 > 2000)
                IF(PLAYER0,TOTAL_CREATURES >= 10)
                    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DOOM16,1,1)
                    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DOOM17,1,1)
                    ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,ELITE,-1,DUNGEON,0,1,500)
                    ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,KNIGHT,-1,DUNGEON,0,1,500)
                    IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
REM CREATE_TEXT(15,40"CONGRATULATIONS, THE BLOODY CARCASSES OF THE FALLEN HEROES LIE WITH EXPRESSIONS OF WRITHING AGONY AT YOUR CREATURES' FEET.  PRESS SPACE TO GO ON TO THE NEXT LAND.")
                        DISPLAY_OBJECTIVE(40,PLAYER0)
                        WIN_GAME
                    ENDIF
                ENDIF
            ENDIF
        ENDIF
    ENDIF
ENDIF

IF_ACTION_POINT(1,PLAYER0)
    IF(PLAYER_GOOD,FLAG1 == 0)
        SET_FLAG(PLAYER_GOOD,FLAG0,1)
        IF(PLAYER0,TOTAL_CREATURES >= 10)
            ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,THIEVES,-1,DUNGEON,0,1,500)
            ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,DWARVES,-1,DUNGEON,0,1,500)
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DOOM14,1,1)
            IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
                REM CREATE_TEXT(14,41"THE FIRST WAVE OF ATTACKERS LIE DEAD.  PREPARE FOR THE NEXT ASSAULT.")
                DISPLAY_OBJECTIVE(41,PLAYER0)
                SET_TIMER(PLAYER0,TIMER3)
                IF(PLAYER0,TIMER3 > 2000)
                    IF(PLAYER0,TOTAL_CREATURES >= 10)
                        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DOOM16,1,1)
                        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DOOM17,1,1)
                        ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,ELITE,-1,DUNGEON,0,1,500)
                        ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,KNIGHT,-1,DUNGEON,0,1,500)
                        IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
REM CREATE_TEXT(15,42"CONGRATULATIONS, THE BLOODY CARCASSES OF THE FALLEN HEROES LIE WITH EXPRESSIONS OF WRITHING AGONY AT YOUR CREATURES' FEET.  PRESS SPACE TO GO ON TO THE NEXT LAND.")
                            DISPLAY_OBJECTIVE(42,PLAYER0)
                            WIN_GAME
                        ENDIF
                    ENDIF
                ENDIF
            ENDIF
        ENDIF
    ENDIF
ENDIF
