REM Play Level Frozen plains

REM ******* Basic settings *******

SET_GENERATE_SPEED(300)

MAX_CREATURES(PLAYER0,20)

START_MONEY(PLAYER0,20000)
START_MONEY(PLAYER2,9000000)
START_MONEY(PLAYER3,9000000)

ALLY_PLAYERS(PLAYER2,PLAYER_GOOD)
ALLY_PLAYERS(PLAYER3,PLAYER_GOOD)

ADD_CREATURE_TO_POOL(FLY,40)
ADD_CREATURE_TO_POOL(BUG,40)
ADD_CREATURE_TO_POOL(SPIDER,40)
ADD_CREATURE_TO_POOL(DEMONSPAWN,12)
ADD_CREATURE_TO_POOL(SORCEROR,6)
ADD_CREATURE_TO_POOL(ORC,16)
ADD_CREATURE_TO_POOL(HELL_HOUND,16)

REM ********** Available creatures **********

CREATURE_AVAILABLE(ALL_PLAYERS,FLY,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,BUG,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,SPIDER,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,DEMONSPAWN,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,SORCEROR,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,DRAGON,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,TROLL,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,ORC,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,HELL_HOUND,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,TENTACLE,1,1)

REM ********** Available rooms **********

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

SET_TIMER(PLAYER_GOOD,TIMER0)

IF(PLAYER_GOOD,TIMER0 >= 4000)
    IF(PLAYER0,TOTAL_CREATURES >= 60)
        NEXT_COMMAND_REUSABLE
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,WIZARD,PLAYER_GOOD,20,10,0)
        NEXT_COMMAND_REUSABLE
        SET_TIMER(PLAYER_GOOD,TIMER0)
    ENDIF
ENDIF

SET_TIMER(PLAYER_GOOD,TIMER1)

IF(PLAYER_GOOD,TIMER1 >= 4000)
    IF(PLAYER0,TOTAL_IMPS >= 50)
        NEXT_COMMAND_REUSABLE
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,BUG,PLAYER_GOOD,20,9,0)
        NEXT_COMMAND_REUSABLE
        SET_TIMER(PLAYER_GOOD,TIMER1)
    ENDIF
ENDIF

REM ********** Available spells **********

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_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_HEAL_CREATURE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_PROTECT,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CHICKEN,1,0)

REM ********** Available doors & traps **********

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,BOULDER,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,WORD_OF_POWER,1,0)

REM ********** Game settings **********

IF(PLAYER0,DUNGEON_DESTROYED == 1)
    LOSE_GAME
ENDIF

REM ********** Parties **********

CREATE_PARTY(ONE)
    ADD_TO_PARTY(ONE,TROLL,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,TROLL,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,TROLL,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,TROLL,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,TROLL,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,TROLL,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,TROLL,10,0,ATTACK_ENEMIES,0)

CREATE_PARTY(TWO)
    ADD_TO_PARTY(TWO,GIANT,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TWO,GIANT,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TWO,GIANT,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TWO,GIANT,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TWO,GIANT,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TWO,GIANT,10,0,ATTACK_ENEMIES,0)

CREATE_PARTY(THREE)
    ADD_TO_PARTY(THREE,WIZARD,7,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(THREE,WIZARD,7,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(THREE,WIZARD,7,0,ATTACK_ENEMIES,0)

CREATE_PARTY(FOUR)
    ADD_TO_PARTY(FOUR,WIZARD,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FOUR,WIZARD,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FOUR,WIZARD,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FOUR,WIZARD,10,0,ATTACK_ENEMIES,0)

CREATE_PARTY(FIVE)
    ADD_TO_PARTY(FIVE,DWARFA,8,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FIVE,DWARFA,8,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FIVE,DWARFA,8,0,ATTACK_ENEMIES,0)

CREATE_PARTY(SIX)
    ADD_TO_PARTY(SIX,WIZARD,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SIX,WIZARD,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SIX,KNIGHT,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SIX,MONK,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SIX,MONK,10,0,ATTACK_ENEMIES,0)

REM ********** Triggers & End game **********

SET_TIMER(PLAYER_GOOD,TIMER2)
SET_TIMER(PLAYER_GOOD,TIMER3)

IF(PLAYER_GOOD,TIMER2 >= 18000)
    ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,PLAYER_GOOD,DUNGEON_HEART,0,8,0)
    SET_TIMER(PLAYER2,TIMER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,TROLL,7,6,5,0)
ENDIF

IF(PLAYER_GOOD,TIMER2 >= 24000)
    SET_TIMER(PLAYER3,TIMER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,GIANT,8,5,4,0)
ENDIF

IF(PLAYER2,TIMER0 >= 8000)
    IF(PLAYER2,TOTAL_CREATURES > 0)
        NEXT_COMMAND_REUSABLE
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,ONE,7,1)
        NEXT_COMMAND_REUSABLE
        SET_TIMER(PLAYER2,TIMER0)
    ENDIF
ENDIF

IF(PLAYER3,TIMER0 >= 8000)
    IF(PLAYER3,TOTAL_CREATURES > 0)
        NEXT_COMMAND_REUSABLE
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TWO,8,1)
        NEXT_COMMAND_REUSABLE
        SET_TIMER(PLAYER3,TIMER0)
    ENDIF
ENDIF

SET_TIMER(PLAYER2,TIMER1)
SET_TIMER(PLAYER3,TIMER1)

IF(PLAYER2,TIMER1 >= 400)
    IF(PLAYER2,TOTAL_CREATURES > 0)
        IF(PLAYER2,TOTAL_CREATURES < 19)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER2,TROLL,7,1,9,0)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER2,TIMER1)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER3,TIMER1 >= 400)
    IF(PLAYER3,TOTAL_CREATURES > 0)
        IF(PLAYER3,TOTAL_CREATURES < 12)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,GIANT,8,1,10,0)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER3,TIMER1)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER2,TOTAL_CREATURES == 0)
    IF(PLAYER3,TOTAL_CREATURES > 0)
        SET_FLAG(PLAYER_GOOD,FLAG0,1)
    ENDIF
ENDIF

IF(PLAYER3,TOTAL_CREATURES == 0)
    IF(PLAYER2,TOTAL_CREATURES > 0)
        SET_FLAG(PLAYER_GOOD,FLAG0,1)
    ENDIF
ENDIF

IF(PLAYER2,TOTAL_CREATURES == 0)
    IF(PLAYER3,TOTAL_CREATURES == 0)
        SET_FLAG(PLAYER_GOOD,FLAG0,2)
    ENDIF
ENDIF

IF(PLAYER_GOOD,TIMER3 >= 8000)
    IF(PLAYER_GOOD,FLAG0 == 1)
        IF(PLAYER_GOOD,DUNGEON_DESTROYED == 0)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,THREE,5,1)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FOUR,6,1)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER_GOOD,TIMER3)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER_GOOD,TIMER3 >= 8000)
    IF(PLAYER_GOOD,FLAG0 == 2)
        IF(PLAYER_GOOD,DUNGEON_DESTROYED == 0)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FOUR,5,1)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FOUR,6,1)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER_GOOD,TIMER3)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER_GOOD,DUNGEON_DESTROYED == 1)
    ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,FIVE,1,ACTION_POINT,3,8,0)
    ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,FIVE,2,ACTION_POINT,4,8,0)
    SET_TIMER(PLAYER_GOOD,TIMER5)
    IF(PLAYER_GOOD,TIMER5 >= 100)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SIX,1,1)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SIX,2,1)
        IF(PLAYER_GOOD,WIZARD == 0)
            IF(PLAYER_GOOD,MONK == 0)
                IF(PLAYER_GOOD,KNIGHT == 0)
                    WIN_GAME
                ENDIF
            ENDIF
        ENDIF
    ENDIF
ENDIF
