REM KDK Level 2

START_MONEY(PLAYER0,6000)
SET_GENERATE_SPEED(350)
MAX_CREATURES(PLAYER0,18)

REM Don't allow demonspawn to become dragon
SET_CREATURE_MAX_LEVEL(PLAYER0,DEMONSPAWN,10)

ADD_CREATURE_TO_POOL(BUG,5)
ADD_CREATURE_TO_POOL(TROLL,7)
ADD_CREATURE_TO_POOL(FLY,8)
ADD_CREATURE_TO_POOL(DEMONSPAWN,2)

CREATURE_AVAILABLE(PLAYER0,BUG,1,1)
CREATURE_AVAILABLE(PLAYER0,TROLL,1,1)
CREATURE_AVAILABLE(PLAYER0,FLY,1,1)
CREATURE_AVAILABLE(PLAYER0,DEMONSPAWN,1,1)
CREATURE_AVAILABLE(PLAYER0,DRAGON,1,1)

MAGIC_AVAILABLE(PLAYER0,POWER_SPEED,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_PROTECT,1,0)
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_IMP,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_SIGHT,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_HEAL_CREATURE,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)
DOOR_AVAILABLE(PLAYER0,BRACED,1,0)
DOOR_AVAILABLE(PLAYER0,WOOD,1,0)

SET_TIMER(PLAYER0,TIMER0)

IF(PLAYER0,TIMER0 >= 1000)
    REM CREATE_TEXT(21,22"WHEN YOUR IMPS HAVE NO ACTIVE TASKS, THEY WILL RUN AROUND REINFORCING YOUR DUNGEON.  ROOMS WITH REINFORCED WALLS ARE MORE EFFICIENT.")
    DISPLAY_INFORMATION(22,PLAYER0)
ENDIF

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

CREATE_PARTY(DWARVES)
    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(DEL_TEL)
    ADD_TO_PARTY(DEL_TEL,BARBARIAN,2,1100,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DEL_TEL,WIZARD,2,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DEL_TEL,WIZARD,3,150,ATTACK_ENEMIES,0)

CREATE_PARTY(KNIGHTS)
    ADD_TO_PARTY(KNIGHTS,KNIGHT,1,2000,ATTACK_ENEMIES,0)

CREATE_PARTY(ENOUGH)
    ADD_TO_PARTY(ENOUGH,MONK,2,800,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ENOUGH,MONK,2,800,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ENOUGH,DWARFA,3,400,ATTACK_ROOMS,0)
    ADD_TO_PARTY(ENOUGH,THIEF,1,1700,STEAL_GOLD,0)
    ADD_TO_PARTY(ENOUGH,DWARFA,2,300,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(ENOUGH,DWARFA,3,400,ATTACK_ROOMS,0)

CREATE_PARTY(ARCHYBOYZ)
    ADD_TO_PARTY(ARCHYBOYZ,ARCHER,1,250,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(ARCHYBOYZ,ARCHER,1,250,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(ARCHYBOYZ,ARCHER,1,300,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(ARCHYBOYZ,ARCHER,1,300,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ARCHYBOYZ,ARCHER,2,400,DEFEND_PARTY,0)
    ADD_TO_PARTY(ARCHYBOYZ,ARCHER,3,400,DEFEND_PARTY,0)
    ADD_TO_PARTY(ARCHYBOYZ,ARCHER,2,400,DEFEND_PARTY,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_STRENGTH(KNIGHT,40)
SET_CREATURE_ARMOUR(KNIGHT,50)


REM CREATE_TEXT(15,23"POSSESS CREATURES BY CHOOSING THE POSSESS SPELL FROM THE SPELLS MENU AND LEFT-CLICK ON THE CREATURE YOU WANT TO CONTROL.  RIGHT-CLICK TO GET BACK TO NORMAL VIEW.")
DISPLAY_INFORMATION(23,PLAYER0)
REM CREATE_TEXT(2,24"FIRST OF ALL, ESTABLISH A BASIC DUNGEON.  REMEMBER, YOU WILL NEED TO BUILD A TREASURE ROOM, A LAIR AND A HATCHERY AND YOU WILL ALSO NEED TO CLAIM A CREATURE ENTRANCE.")
DISPLAY_OBJECTIVE(24,PLAYER0)


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

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

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

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

IF(PLAYER0,FLAG0 == 1)
    IF(PLAYER0,FLAG5 == 1)
        IF(PLAYER0,FLAG6 == 1)
            IF(PLAYER0,FLAG2 == 1)
                TUTORIAL_FLASH_BUTTON(10,-1)
                REM CREATE_TEXT(30,25"YOU WILL NEED STRONGER CREATURES.  BUILD A 3X3 TRAINING ROOM TO MAKE YOUR CREATURES STRONGER, AND TO GIVE THEM NEW SPELLS AND ABILITIES.")
                DISPLAY_OBJECTIVE(25,PLAYER0)
                SET_FLAG(PLAYER0,FLAG0,2)
                SET_TIMER(PLAYER0,TIMER2)
            ENDIF
        ENDIF
    ENDIF
ENDIF

IF(PLAYER0,FLAG0 != 2)
    IF(PLAYER0,GAME_TURN > 10000)
        IF(PLAYER0,LAIR > 0)
            IF(PLAYER0,TREASURE > 0)
                IF(PLAYER0,GARDEN > 0)
                    IF(PLAYER0,ENTRANCE > 0)
                        TUTORIAL_FLASH_BUTTON(10,-1)
                        REM CREATE_TEXT(30,25"YOU WILL NEED STRONGER CREATURES.  BUILD A 3X3 TRAINING ROOM TO MAKE YOUR CREATURES STRONGER, AND TO GIVE THEM NEW SPELLS AND ABILITIES.")
                        DISPLAY_OBJECTIVE(25,PLAYER0)
                        SET_TIMER(PLAYER0,TIMER2)
                        SET_FLAG(PLAYER0,FLAG0,2)
                    ENDIF
                ENDIF
            ENDIF
        ENDIF
    ENDIF
ENDIF


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

IF(PLAYER0,TIMER2 > 7000)
    IF(PLAYER0,TRAINING > 0)
        SET_FLAG(PLAYER0,FLAG3,1)
    ENDIF
ENDIF


IF(PLAYER0,FLAG3 == 1)
    REM CREATE_TEXT(25,26"GOOD.  NOW GET YOUR IMPS TO FORTIFY THE WALLS IN YOUR ROOMS.  THIS WILL INCREASE THE EFFICIENCY OF THE ROOMS AND REPEL INVADERS.")
    DISPLAY_OBJECTIVE(26,PLAYER0)
    REM CREATE_TEXT(32,27"A TRAINING ROOM WILL ATTRACT FIGHTERS, ESPECIALLY DEMON SPAWN.  FIGHTERS ARE GOOD FOR TRAINING.")
    DISPLAY_INFORMATION(27,PLAYER0)
    IF(PLAYER0,DEMONSPAWN > 0)
        REM CREATE_TEXT(31,28"TO TRAIN CREATURES, PUT THEM IN THE TRAINING ROOM.  THE NUMBER THAT YOU WILL SEE COMING OUT IS THE AMOUNT IT COSTS A CREATURE TO TRAIN.")
        DISPLAY_INFORMATION(28,PLAYER0)
    ENDIF
ENDIF

REM info to tell player to slap creatures
IF(PLAYER0,DEMONSPAWN > 0)
    REM CREATE_TEXT(35,29"REMEMBER, YOU CAN SPEED UP THE CREATURES TRAINING BY SLAPPING THEM WHILE THEY'RE IN THE TRAINING ROOM.")
    DISPLAY_INFORMATION(29,PLAYER0)
ENDIF


IF(PLAYER0,DEMONSPAWN >= 2)
    ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,THIEVES,1,DUNGEON,0,1,500)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DWARVES,1,1)
    REM CREATE_TEXT(33,30"THE HEROES ARE ON THEIR WAY.  MAKE SURE YOUR CREATURES ARE WELL TRAINED AND READY FOR THE ATTACK.")
    DISPLAY_OBJECTIVE(30,PLAYER0)
    IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
        IF(PLAYER0,TOTAL_CREATURES >= 8)
            ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,ELITE,-1,DUNGEON,0,1,500)
            IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
                IF(PLAYER0,TOTAL_CREATURES >= 8)
                    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,KNIGHTS,-1,1)
                    IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
                        REM CREATE_TEXT(34,31"CONGRATULATIONS.  YOU HAVE CONQUERED THE ENEMY HORDES.")
                        DISPLAY_OBJECTIVE(31,PLAYER0)
                        WIN_GAME
                    ENDIF
                ENDIF
            ENDIF
        ENDIF
    ENDIF
ENDIF

IF_ACTION_POINT(2,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DEL_TEL,2,1)
    ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,THIEVES,1,DUNGEON,0,1,500)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DWARVES,1,1)
    REM CREATE_TEXT(33,32"THE HEROES ARE ON THEIR WAY.  MAKE SURE YOUR CREATURES ARE WELL TRAINED AND READY FOR THE ATTACK.")
    DISPLAY_OBJECTIVE(32,PLAYER0)
    IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,ENOUGH,1,1)
        IF(PLAYER0,TOTAL_CREATURES >= 8)
            ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,ELITE,-1,DUNGEON,0,1,500)
            IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
                ADD_PARTY_TO_LEVEL(PLAYER_GOOD,ARCHYBOYZ,1,1)
                IF(PLAYER0,TOTAL_CREATURES >= 8)
                    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,KNIGHTS,-1,1)
                    IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
                        REM CREATE_TEXT(34,33"CONGRATULATIONS.  YOU HAVE CONQUERED THE ENEMY HORDES.")
                        DISPLAY_OBJECTIVE(33,PLAYER0)
                        WIN_GAME
                    ENDIF
                ENDIF
            ENDIF
        ENDIF
    ENDIF
ENDIF
