REM -------------------------------------------------------------------------------------------------------------------------------------------
REM Post Undead Keeper
REM Havoth Dir
REM Made by Duke Ragereaver
REM -------------------------------------------------------------------------------------------------------------------------------------------

START_MONEY(PLAYER0,50000)

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

SET_GENERATE_SPEED(450)
ADD_CREATURE_TO_POOL(SKELETON,60)
ADD_CREATURE_TO_POOL(SPIDER,20)
ADD_CREATURE_TO_POOL(GHOST,10)

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

MAX_CREATURES(PLAYER0,60)

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

CREATURE_AVAILABLE(PLAYER0,SPIDER,1,1)
CREATURE_AVAILABLE(PLAYER0,SKELETON,1,1)
CREATURE_AVAILABLE(PLAYER0,GHOST,1,1)

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

ROOM_AVAILABLE(ALL_PLAYERS,RESEARCH,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,WORKSHOP,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,GARDEN,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,LAIR,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,TORTURE,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,GRAVEYARD,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,TRAINING,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,TREASURE,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,TEMPLE,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,PRISON,1,1)

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

MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HAND,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SLAP,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_IMP,1,1)

MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SIGHT,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CALL_TO_ARMS,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HOLD_AUDIENCE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SPEED,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CONCEAL,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HEAL_CREATURE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_DISEASE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CHICKEN,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_LIGHTNING,1,0)

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

DOOR_AVAILABLE(ALL_PLAYERS,WOOD,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,BRACED,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,STEEL,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,MAGIC,1,0)

TRAP_AVAILABLE(ALL_PLAYERS,ALARM,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,POISON_GAS,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,LIGHTNING,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,WORD_OF_POWER,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,BOULDER,1,0)

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

CREATE_PARTY(FIRST)
    ADD_TO_PARTY(FIRST,ARCHER,4,750,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FIRST,BARBARIAN,5,1000,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(FIRST,ARCHER,4,750,DEFEND_PARTY,0)
    ADD_TO_PARTY(FIRST,THIEF,4,600,STEAL_GOLD,0)
    ADD_TO_PARTY(FIRST,ARCHER,4,750,DEFEND_PARTY,0)

CREATE_PARTY(SECOND)
    ADD_TO_PARTY(SECOND,THIEF,4,750,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SECOND,THIEF,5,1000,STEAL_GOLD,0)
    ADD_TO_PARTY(SECOND,DWARFA,4,800,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(SECOND,DWARFA,4,800,DEFEND_PARTY,0)
    ADD_TO_PARTY(SECOND,THIEF,4,750,ATTACK_ENEMIES,0)

CREATE_PARTY(THIRD)
    ADD_TO_PARTY(THIRD,MONK,4,750,STEAL_SPELLS,0)
    ADD_TO_PARTY(THIRD,WIZARD,5,1000,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(THIRD,MONK,4,750,STEAL_SPELLS,0)
    ADD_TO_PARTY(THIRD,SAMURAI,4,800,DEFEND_PARTY,0)
    ADD_TO_PARTY(THIRD,ARCHER,4,700,DEFEND_PARTY,0)

CREATE_PARTY(FOUR)
    ADD_TO_PARTY(FOUR,GIANT,3,800,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FOUR,GIANT,3,1000,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(FOUR,WITCH,5,800,STEAL_SPELLS,0)
    ADD_TO_PARTY(FOUR,WITCH,4,750,DEFEND_PARTY,0)

CREATE_PARTY(BRUTES_LIGHT)
    ADD_TO_PARTY(BRUTES_LIGHT,GIANT,6,1200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(BRUTES_LIGHT,GIANT,6,1200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(BRUTES_LIGHT,BARBARIAN,6,1200,DEFEND_PARTY,0)
    ADD_TO_PARTY(BRUTES_LIGHT,BARBARIAN,6,1200,STEAL_SPELLS,0)

CREATE_PARTY(SAMURAI_LIGHT)
    ADD_TO_PARTY(SAMURAI_LIGHT,SAMURAI,5,850,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SAMURAI_LIGHT,SAMURAI,6,1000,STEAL_SPELLS,0)
    ADD_TO_PARTY(SAMURAI_LIGHT,SAMURAI,4,850,DEFEND_PARTY,0)
    ADD_TO_PARTY(SAMURAI_LIGHT,SAMURAI,4,850,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SAMURAI_LIGHT,SAMURAI,5,950,DEFEND_PARTY,0)

CREATE_PARTY(MYSTIC_LIGHT)
    ADD_TO_PARTY(MYSTIC_LIGHT,SAMURAI,6,1000,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(MYSTIC_LIGHT,WIZARD,6,1200,STEAL_SPELLS,0)
    ADD_TO_PARTY(MYSTIC_LIGHT,MONK,6,900,DEFEND_PARTY,0)
    ADD_TO_PARTY(MYSTIC_LIGHT,ARCHER,6,800,DEFEND_PARTY,0)
    ADD_TO_PARTY(MYSTIC_LIGHT,GIANT,6,900,ATTACK_ROOMS,0)

CREATE_PARTY(BRUTES_HEAVY)
    ADD_TO_PARTY(BRUTES_HEAVY,GIANT,8,2500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(BRUTES_HEAVY,GIANT,8,2500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(BRUTES_HEAVY,BARBARIAN,8,2000,DEFEND_PARTY,0)
    ADD_TO_PARTY(BRUTES_HEAVY,BARBARIAN,8,2000,STEAL_SPELLS,0)

CREATE_PARTY(SAMURAI_HEAVY)
    ADD_TO_PARTY(SAMURAI_HEAVY,SAMURAI,7,1250,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SAMURAI_HEAVY,SAMURAI,8,1500,STEAL_SPELLS,0)
    ADD_TO_PARTY(SAMURAI_HEAVY,SAMURAI,6,1000,DEFEND_PARTY,0)
    ADD_TO_PARTY(SAMURAI_HEAVY,SAMURAI,6,1000,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SAMURAI_HEAVY,SAMURAI,7,1250,DEFEND_PARTY,0)

CREATE_PARTY(MYSTIC_HEAVY)
    ADD_TO_PARTY(MYSTIC_HEAVY,SAMURAI,8,1500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(MYSTIC_HEAVY,WIZARD,9,1500,STEAL_SPELLS,0)
    ADD_TO_PARTY(MYSTIC_HEAVY,MONK,8,1000,DEFEND_PARTY,0)
    ADD_TO_PARTY(MYSTIC_HEAVY,ARCHER,8,1000,DEFEND_PARTY,0)
    ADD_TO_PARTY(MYSTIC_HEAVY,GIANT,7,1000,ATTACK_ROOMS,0)

CREATE_PARTY(SUPPORT)
    ADD_TO_PARTY(SUPPORT,ARCHER,8,1000,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SUPPORT,BARBARIAN,8,1000,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SUPPORT,ARCHER,8,1000,DEFEND_PARTY,0)
    ADD_TO_PARTY(SUPPORT,ARCHER,8,1000,DEFEND_PARTY,0)
    ADD_TO_PARTY(SUPPORT,BARBARIAN,8,1000,ATTACK_ENEMIES,0)

CREATE_PARTY(BOSS)
    ADD_TO_PARTY(BOSS,WIZARD,9,1500,STEAL_SPELLS,0)
    ADD_TO_PARTY(BOSS,KNIGHT,10,5000,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(BOSS,SAMURAI,9,1500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(BOSS,GIANT,9,1500,DEFEND_PARTY,0)
    ADD_TO_PARTY(BOSS,ARCHER,9,1000,DEFEND_PARTY,0)
    ADD_TO_PARTY(BOSS,FAIRY,10,1000,STEAL_SPELLS,0)

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

QUICK_OBJECTIVE(0,"The Heroes are getting somewhat nervous and have send an army to attack you. Use the resources you have available to build an even bigger force and crush that so-called army.",PLAYER0)

SET_TIMER(PLAYER0,TIMER0)

IF(PLAYER0,TIMER0 >= 10750)
    ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,-1,DUNGEON_HEART,0,5,1000)
    ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,2,DUNGEON_HEART,0,4,1000)
ENDIF

IF(PLAYER0,TIMER0 >= 11750)
    ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,-2,DUNGEON_HEART,0,5,1000)
    ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,1,DUNGEON_HEART,0,4,1000)
ENDIF

IF(PLAYER0,TIMER0 >= 14000)
    ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,-3,DUNGEON_HEART,0,5,1000)
    ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,4,DUNGEON_HEART,0,4,1000)
ENDIF

IF(PLAYER0,TIMER0 >= 15250)
    ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,-4,DUNGEON_HEART,0,5,1000)
    ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,3,DUNGEON_HEART,0,4,1000)
    SET_FLAG(PLAYER0,FLAG0,1)
ENDIF

IF(PLAYER0,FLAG0 == 1)
    SET_TIMER(PLAYER_GOOD,TIMER0)
    SET_TIMER(PLAYER_GOOD,TIMER1)
    SET_TIMER(PLAYER_GOOD,TIMER2)
    SET_TIMER(PLAYER_GOOD,TIMER3)
    SET_TIMER(PLAYER_GOOD,TIMER4)
ENDIF

IF(PLAYER_GOOD,FLAG0 == 0)
    IF(PLAYER_GOOD,TIMER0 >= 1000)
        IF(PLAYER_GOOD,TIMER1 > 1750)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FIRST,-1,1)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER_GOOD,TIMER1)
        ENDIF
    ENDIF
ENDIF


IF(PLAYER_GOOD,FLAG0 == 0)
    IF(PLAYER_GOOD,TIMER0 >= 1750)
        IF(PLAYER_GOOD,TIMER2 > 2350)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SECOND,-2,1)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER_GOOD,TIMER2)
        ENDIF
    ENDIF
ENDIF


IF(PLAYER_GOOD,FLAG0 == 0)
    IF(PLAYER_GOOD,TIMER0 >= 2500)
        IF(PLAYER_GOOD,TIMER3 > 2950)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,THIRD,-3,1)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER_GOOD,TIMER3)
        ENDIF
    ENDIF
ENDIF


IF(PLAYER_GOOD,FLAG0 == 0)
    IF(PLAYER_GOOD,TIMER0 >= 3250)
        IF(PLAYER_GOOD,TIMER4 > 3800)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FOUR,-4,1)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER_GOOD,TIMER4)
        ENDIF
    ENDIF
ENDIF


IF(PLAYER_GOOD,TIMER0 >= 4200)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,BRUTES_LIGHT,3,1)
ENDIF

IF(PLAYER_GOOD,TIMER0 >= 7250)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,MYSTIC_LIGHT,4,1)
ENDIF

IF(PLAYER_GOOD,TIMER0 >= 12400)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SAMURAI_LIGHT,1,1)
    SET_FLAG(PLAYER_GOOD,FLAG0,1)
ENDIF

IF(PLAYER_GOOD,TIMER0 >= 12500)
    IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
        IF(PLAYER_GOOD,FLAG0 == 1)
            SET_FLAG(PLAYER_GOOD,FLAG0,2)
            SET_TIMER(PLAYER_GOOD,TIMER5)
QUICK_OBJECTIVE(1,"You have slaughtered the vast majority of the Heroes, now prepare yourself for their elite warriors. Maybe they can provide some some actual fight.",PLAYER0)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER_GOOD,FLAG0 == 2)
    IF(PLAYER_GOOD,TIMER5 >= 8000)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,BRUTES_HEAVY,2,1)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,BRUTES_HEAVY,4,1)
        QUICK_OBJECTIVE(2,"Here they come again.",PLAYER0)
    ENDIF
ENDIF

IF(PLAYER_GOOD,FLAG0 == 2)
    IF(PLAYER_GOOD,TIMER5 >= 10000)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SAMURAI_HEAVY,3,1)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,MYSTIC_HEAVY,4,1)
        SET_FLAG(PLAYER_GOOD,FLAG0,3)
    ENDIF
ENDIF

IF(PLAYER_GOOD,FLAG0 == 3)
    IF(PLAYER_GOOD,TIMER5 >= 13250)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,BOSS,1,1)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SUPPORT,1,1)
        SET_FLAG(PLAYER_GOOD,FLAG0,4)
    ENDIF
ENDIF

IF(PLAYER_GOOD,TIMER5 >= 13250)
    IF(PLAYER_GOOD,FLAG0 == 4)
        IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
QUICK_OBJECTIVE(3,"With so many deaths here on the field, I have good reason to believe this place will forever be haunted with wailing, vengeful revenants untill the end of time. Outstanding!",PLAYER0)
            WIN_GAME
        ENDIF
    ENDIF
ENDIF
