REM KDK Level 11

SET_GENERATE_SPEED(400)

MAX_CREATURES(PLAYER0,43)
START_MONEY(PLAYER0,26540)

ADD_CREATURE_TO_POOL(DEMONSPAWN,24)
ADD_CREATURE_TO_POOL(DARK_MISTRESS,14)
ADD_CREATURE_TO_POOL(SORCEROR,36)
ADD_CREATURE_TO_POOL(TROLL,32)
ADD_CREATURE_TO_POOL(BILE_DEMON,13)
ADD_CREATURE_TO_POOL(HELL_HOUND,10)
ADD_CREATURE_TO_POOL(DRAGON,12)
ADD_CREATURE_TO_POOL(ORC,13)

REM Creature_Availability

CREATURE_AVAILABLE(PLAYER0,TROLL,1,1)
CREATURE_AVAILABLE(PLAYER0,DEMONSPAWN,1,1)
CREATURE_AVAILABLE(PLAYER0,DARK_MISTRESS,1,1)
CREATURE_AVAILABLE(PLAYER0,SORCEROR,1,1)
CREATURE_AVAILABLE(PLAYER0,BILE_DEMON,1,1)
CREATURE_AVAILABLE(PLAYER0,HELL_HOUND,1,1)
CREATURE_AVAILABLE(PLAYER0,DRAGON,1,1)
CREATURE_AVAILABLE(PLAYER0,ORC,1,1)

REM Room_Availability

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,WORKSHOP,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,BARRACKS,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,GUARD_POST,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,BRIDGE,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,PRISON,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,SCAVENGER,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,TORTURE,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,PRISON,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,TEMPLE,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,GRAVEYARD,1,0)

REM Spells

MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HAND,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_IMP,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SLAP,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SIGHT,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CALL_TO_ARMS,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HEAL_CREATURE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SPEED,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_LIGHTNING,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_PROTECT,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CONCEAL,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_DISEASE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CAVE_IN,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CHICKEN,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HOLD_AUDIENCE,1,0)

REM doors & traps

DOOR_AVAILABLE(ALL_PLAYERS,BRACED,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,POISON_GAS,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,LAVA,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,BOULDER,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,WORD_OF_POWER,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,LIGHTNING,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,STEEL,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,MAGIC,1,0)

REM ---------------------------------------------------------

CREATE_PARTY(FIRST)
    ADD_TO_PARTY(FIRST,DWARFA,4,370,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FIRST,THIEF,4,1450,STEAL_GOLD,0)
    ADD_TO_PARTY(FIRST,THIEF,4,2280,STEAL_GOLD,0)
    ADD_TO_PARTY(FIRST,THIEF,4,1967,STEAL_GOLD,0)
    ADD_TO_PARTY(FIRST,SAMURAI,3,1013,ATTACK_ENEMIES,0)

CREATE_PARTY(SECOND)
    ADD_TO_PARTY(SECOND,ARCHER,5,727,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SECOND,GIANT,5,1329,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SECOND,WIZARD,6,1231,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SECOND,MONK,6,455,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SECOND,FAIRY,4,831,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SECOND,BARBARIAN,5,1210,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SECOND,THIEF,7,3545,STEAL_GOLD,0)

CREATE_PARTY(THIRD)
    ADD_TO_PARTY(THIRD,TUNNELLER,4,666,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(THIRD,TUNNELLER,6,809,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(THIRD,SAMURAI,5,1478,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(THIRD,SAMURAI,7,2119,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(THIRD,SAMURAI,7,3039,ATTACK_ENEMIES,0)

CREATE_PARTY(FOURTH)
    ADD_TO_PARTY(FOURTH,WIZARD,6,1875,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FOURTH,WITCH,6,1313,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FOURTH,FAIRY,7,2224,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FOURTH,MONK,1,626,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FOURTH,MONK,4,876,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FOURTH,GIANT,7,8953,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FOURTH,SAMURAI,5,4873,ATTACK_ENEMIES,0)

CREATE_PARTY(FIFTH)
    ADD_TO_PARTY(FIFTH,TUNNELLER,5,755,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FIFTH,BARBARIAN,7,2554,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FIFTH,WIZARD,7,2339,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FIFTH,DWARFA,4,1268,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FIFTH,THIEF,2,3750,STEAL_GOLD,0)
    ADD_TO_PARTY(FIFTH,THIEF,2,2888,STEAL_GOLD,0)
    ADD_TO_PARTY(FIFTH,THIEF,1,2654,STEAL_GOLD,0)

CREATE_PARTY(SIXTH)
    ADD_TO_PARTY(SIXTH,BARBARIAN,8,4241,ATTACK_ROOMS,0)
    ADD_TO_PARTY(SIXTH,BARBARIAN,8,3117,ATTACK_ROOMS,0)
    ADD_TO_PARTY(SIXTH,BARBARIAN,9,5322,ATTACK_ROOMS,0)
    ADD_TO_PARTY(SIXTH,WIZARD,7,2022,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SIXTH,WITCH,8,5342,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SIXTH,WITCH,6,1732,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SIXTH,WITCH,6,877,ATTACK_ENEMIES,0)

CREATE_PARTY(SEVENTH)
    ADD_TO_PARTY(SEVENTH,THIEF,8,4624,STEAL_GOLD,0)
    ADD_TO_PARTY(SEVENTH,SAMURAI,7,4525,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SEVENTH,WIZARD,6,2511,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SEVENTH,ARCHER,7,2542,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SEVENTH,MONK,7,2398,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SEVENTH,WITCH,6,2400,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SEVENTH,FAIRY,9,7878,ATTACK_ENEMIES,0)

CREATE_PARTY(EIGHTH)
    ADD_TO_PARTY(EIGHTH,ARCHER,8,3555,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(EIGHTH,ARCHER,8,5987,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(EIGHTH,WIZARD,4,1320,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(EIGHTH,WIZARD,7,4874,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(EIGHTH,GIANT,6,10012,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(EIGHTH,SAMURAI,5,854,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(EIGHTH,THIEF,6,1494,STEAL_GOLD,0)

CREATE_PARTY(KNIGHT)
    ADD_TO_PARTY(KNIGHT,KNIGHT,7,10000,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(KNIGHT,ARCHER,7,900,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(KNIGHT,BARBARIAN,9,900,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(KNIGHT,MONK,6,900,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(KNIGHT,FAIRY,8,900,ATTACK_ENEMIES,0)

SET_TIMER(PLAYER_GOOD,TIMER0)
SET_FLAG(PLAYER_GOOD,FLAG0,0)

IF(PLAYER_GOOD,FLAG0 < 10)
    IF(PLAYER_GOOD,GAME_TURN >= 17000)

        REM First set of the looping timer
        SET_TIMER(PLAYER_GOOD,TIMER1)
        SET_FLAG(PLAYER_GOOD,FLAG1,0)

        REM Checking the looping timer
        IF(PLAYER_GOOD,TIMER1 > 2000)
            IF(PLAYER_GOOD,FLAG1 == 0)
                NEXT_COMMAND_REUSABLE
                ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FIRST,3,1)
                NEXT_COMMAND_REUSABLE
                SET_FLAG(PLAYER_GOOD,FLAG1,1)
            ENDIF
            IF(PLAYER_GOOD,FLAG1 == 1)
                NEXT_COMMAND_REUSABLE
                ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SECOND,1,1)
                NEXT_COMMAND_REUSABLE
                SET_FLAG(PLAYER_GOOD,FLAG1,2)
            ENDIF
            IF(PLAYER_GOOD,FLAG1 == 2)
                NEXT_COMMAND_REUSABLE
                ADD_PARTY_TO_LEVEL(PLAYER_GOOD,THIRD,2,1)
                NEXT_COMMAND_REUSABLE
                SET_FLAG(PLAYER_GOOD,FLAG1,3)
            ENDIF
            IF(PLAYER_GOOD,FLAG1 == 3)
                NEXT_COMMAND_REUSABLE
                ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FOURTH,4,1)
                REM Loop the timer
                NEXT_COMMAND_REUSABLE
                SET_FLAG(PLAYER_GOOD,FLAG1,0)
            ENDIF
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER_GOOD,TIMER1)
        ENDIF

    ENDIF
ENDIF


IF(PLAYER_GOOD,GAME_TURN >= 29000)
    SET_FLAG(PLAYER_GOOD,FLAG0,100)
    IF(PLAYER_GOOD,TOTAL_CREATURES == 0)

        REM CREATE_TEXT(1,102"YOU HAVE DECIMATED THE FIRST WAVE.  THE FINAL WAVE IS ON ITS WAY, AND THEY'RE PISSED OFF.  TRAIN UP YOUR CREATURES AND PREPARE YOURSELF.")
        DISPLAY_OBJECTIVE(102,PLAYER0)
        SET_TIMER(PLAYER0,TIMER1)

        IF(PLAYER0,TIMER1 >= 4000)
            REM CREATE_TEXT(2,103"HERE THEY COME...")
            DISPLAY_OBJECTIVE(103,PLAYER0)
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FIFTH,1,1)
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SIXTH,2,1)
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SEVENTH,3,1)
        ENDIF

        IF(PLAYER0,TIMER1 >= 5500)
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,EIGHTH,4,1)
            IF(PLAYER_GOOD,TOTAL_CREATURES < 3)
                ADD_PARTY_TO_LEVEL(PLAYER_GOOD,KNIGHT,1,1)
                SET_FLAG(PLAYER_GOOD,FLAG0,101)
            ENDIF
        ENDIF

    ENDIF
ENDIF

IF(PLAYER_GOOD,FLAG0 == 101)
    IF(PLAYER_GOOD,KNIGHT == 0)
        REM CREATE_TEXT(3,104"THE HEROES ARE DECIMATED.  THIS LAND, AND ITS SPOILS, ARE YOURS.")
        DISPLAY_OBJECTIVE(104,PLAYER0)
        WIN_GAME
    ENDIF
ENDIF

REM CHAZ,MATT,LOUISE,NICK,MUM AND VARIOUS OTHERS - HELLO

REM CREATE_TEXT(4,105"THIS LAND IS ON ITS KNEES AND AS A LAST DITCH DEFENCE OF THEIR REALM, HAS PREPARED A FULL SCALE ATTACK ON YOU DUNGEON.  WIPE OUT THIS FORCE TO CONTROL THI LAND.")
DISPLAY_OBJECTIVE(105,PLAYER0)

IF_AVAILABLE(PLAYER0,POWER_CHICKEN == 1)
REM CREATE_TEXT(2,97"YOUR RESEARCHERS HAVE COME UP WITH A DEVASTATING SPELL, THE SPELL OF CHICKEN.  CAST IT ON A CREATURE TO TRANSFORM THEM FROM A FIERY BEAST INTO A CLUCKING CHICKEN.  MARVELLOUS.")
    DISPLAY_INFORMATION(97,PLAYER0)
ENDIF

IF_AVAILABLE(PLAYER0,MAGIC == 1)
    REM CREATE_TEXT(6,99"A MAGIC DOOR IS AVAILABLE TO YOU.  THIS DOOR IS IMPREGNABLE TO ALL BUT MAGICAL ATTACKS.")
    DISPLAY_INFORMATION(99,PLAYER0)
ENDIF
