REM Play Level Pile of its own good.

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

SET_GENERATE_SPEED(500)

MAX_CREATURES(PLAYER0,14)

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

START_MONEY(PLAYER0,50)
START_MONEY(PLAYER2,0)
START_MONEY(PLAYER3,0)

ADD_CREATURE_TO_POOL(FLY,30)
ADD_CREATURE_TO_POOL(BUG,20)
ADD_CREATURE_TO_POOL(SORCEROR,5)
ADD_CREATURE_TO_POOL(TROLL,20)
ADD_CREATURE_TO_POOL(DEMONSPAWN,10)


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

CREATURE_AVAILABLE(ALL_PLAYERS,FLY,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,BUG,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,DEMONSPAWN,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,SORCEROR,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,TROLL,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(PLAYER0,TRAINING,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,RESEARCH,1,1)

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

MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HAND,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SLAP,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(PLAYER0,POWER_IMP,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_CALL_TO_ARMS,1,0)

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

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

CREATE_PARTY(ONE)
    ADD_TO_PARTY(ONE,THIEF,2,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,DWARFA,1,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,BARBARIAN,1,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,ARCHER,1,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,THIEF,2,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,THIEF,3,0,ATTACK_ENEMIES,0)

CREATE_PARTY(TWO)
    ADD_TO_PARTY(TWO,BARBARIAN,6,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TWO,BARBARIAN,6,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TWO,MONK,4,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TWO,AVATAR,3,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TWO,MONK,4,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TWO,BARBARIAN,6,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TWO,BARBARIAN,6,0,ATTACK_ENEMIES,0)

IF(PLAYER0,TOTAL_CREATURES >= 10)
    SET_TIMER(PLAYER_GOOD,TIMER0)
ENDIF

IF(PLAYER_GOOD,TIMER0 >= 5500)
    NEXT_COMMAND_REUSABLE
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,TENTACLE,1,1,5,100)
    NEXT_COMMAND_REUSABLE
    SET_TIMER(PLAYER_GOOD,TIMER0)
ENDIF

IF_ACTION_POINT(2,PLAYER0)
    SET_FLAG(PLAYER_GOOD,FLAG0,1)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,1,4,2,100)
    ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,ONE,3,DUNGEON_HEART,0,1,0)
    ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,ONE,4,DUNGEON_HEART,0,1,0)
ENDIF

SET_TIMER(PLAYER2,TIMER0)
SET_TIMER(PLAYER2,TIMER1)
SET_TIMER(PLAYER2,TIMER2)
SET_TIMER(PLAYER2,TIMER3)
SET_TIMER(PLAYER2,TIMER4)
SET_TIMER(PLAYER2,TIMER5)
SET_TIMER(PLAYER3,TIMER0)
SET_TIMER(PLAYER3,TIMER1)
SET_TIMER(PLAYER3,TIMER2)
SET_TIMER(PLAYER3,TIMER3)
SET_TIMER(PLAYER3,TIMER4)
SET_TIMER(PLAYER3,TIMER5)

IF(PLAYER2,TIMER0 >= 350)
    IF(PLAYER2,TOTAL_CREATURES < 25)
        IF(PLAYER2,TOTAL_CREATURES >= 1)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER2,TROLL,-1,2,1,0)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER2,TIMER0)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER2,TIMER1 >= 475)
    IF(PLAYER2,TOTAL_CREATURES < 25)
        IF(PLAYER2,TOTAL_CREATURES >= 1)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER2,BUG,-1,1,1,0)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER2,TIMER1)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER2,TIMER2 >= 550)
    IF(PLAYER2,TOTAL_CREATURES < 25)
        IF(PLAYER2,TOTAL_CREATURES >= 1)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER2,ORC,-1,1,1,0)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER2,TIMER2)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER2,TIMER3 >= 650)
    IF(PLAYER2,TOTAL_CREATURES < 25)
        IF(PLAYER2,TOTAL_CREATURES >= 1)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER2,GHOST,5,1,1,0)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER2,TIMER3)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER2,TIMER4 >= 750)
    IF(PLAYER2,TOTAL_CREATURES < 25)
        IF(PLAYER2,TOTAL_CREATURES >= 1)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER2,HELL_HOUND,-1,1,1,0)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER2,TIMER4)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER2,TIMER5 >= 1100)
    IF(PLAYER2,TOTAL_CREATURES < 26)
        IF(PLAYER2,TOTAL_CREATURES >= 1)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER2,DRAGON,-1,1,1,0)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER2,TIMER5)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER3,TIMER0 >= 350)
    IF(PLAYER3,TOTAL_CREATURES < 25)
        IF(PLAYER3,TOTAL_CREATURES >= 1)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,THIEF,-2,2,1,0)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER3,TIMER0)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER3,TIMER1 >= 475)
    IF(PLAYER3,TOTAL_CREATURES < 25)
        IF(PLAYER3,TOTAL_CREATURES >= 1)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,ARCHER,-2,1,1,0)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER3,TIMER1)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER3,TIMER2 >= 550)
    IF(PLAYER3,TOTAL_CREATURES < 25)
        IF(PLAYER3,TOTAL_CREATURES >= 1)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,BARBARIAN,-2,1,1,0)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER3,TIMER2)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER3,TIMER3 >= 650)
    IF(PLAYER3,TOTAL_CREATURES < 25)
        IF(PLAYER3,TOTAL_CREATURES >= 1)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,WIZARD,-2,1,1,0)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER3,TIMER3)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER3,TIMER4 >= 750)
    IF(PLAYER3,TOTAL_CREATURES < 25)
        IF(PLAYER3,TOTAL_CREATURES >= 1)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,GIANT,-2,1,1,0)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER3,TIMER4)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER3,TIMER5 >= 1400)
    IF(PLAYER2,TOTAL_CREATURES < 26)
        IF(PLAYER2,TOTAL_CREATURES >= 1)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,SAMURAI,-2,1,1,0)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER3,TIMER5)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER_GOOD,KNIGHT == 0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,TENTACLE,-3,3,5,0)
ENDIF

IF(PLAYER_GOOD,BARBARIAN == 0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TWO,-3,1)
    IF(PLAYER_GOOD,AVATAR == 0)
        WIN_GAME
    ENDIF
ENDIF
