REM Play Level Evergrin

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

SET_GENERATE_SPEED(375)

MAX_CREATURES(PLAYER0,19)
MAX_CREATURES(PLAYER1,20)
MAX_CREATURES(PLAYER2,12)

START_MONEY(PLAYER0,12000)
START_MONEY(PLAYER1,15000)
START_MONEY(PLAYER2,15000)
START_MONEY(PLAYER3,8000000)

COMPUTER_PLAYER(PLAYER1,0)
COMPUTER_PLAYER(PLAYER2,0)

ALLY_PLAYERS(PLAYER1,PLAYER_GOOD)
ALLY_PLAYERS(PLAYER1,PLAYER3)
ALLY_PLAYERS(PLAYER3,PLAYER_GOOD)

ADD_CREATURE_TO_POOL(FLY,13)
ADD_CREATURE_TO_POOL(BUG,13)
ADD_CREATURE_TO_POOL(SPIDER,5)
ADD_CREATURE_TO_POOL(DEMONSPAWN,4)
ADD_CREATURE_TO_POOL(SORCEROR,13)
ADD_CREATURE_TO_POOL(BILE_DEMON,13)
ADD_CREATURE_TO_POOL(DRAGON,7)
ADD_CREATURE_TO_POOL(TROLL,13)
ADD_CREATURE_TO_POOL(ORC,6)
ADD_CREATURE_TO_POOL(DARK_MISTRESS,13)
ADD_CREATURE_TO_POOL(GHOST,13)
ADD_CREATURE_TO_POOL(VAMPIRE,3)
ADD_CREATURE_TO_POOL(TENTACLE,13)
ADD_CREATURE_TO_POOL(HORNY,8)

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

CREATURE_AVAILABLE(PLAYER0,FLY,1,1)
CREATURE_AVAILABLE(PLAYER0,BUG,1,1)
CREATURE_AVAILABLE(PLAYER1,SPIDER,1,1)
CREATURE_AVAILABLE(PLAYER1,DEMONSPAWN,1,1)
CREATURE_AVAILABLE(PLAYER0,SORCEROR,1,1)
CREATURE_AVAILABLE(PLAYER0,BILE_DEMON,1,1)
CREATURE_AVAILABLE(PLAYER1,DRAGON,1,1)
CREATURE_AVAILABLE(PLAYER0,TROLL,1,1)
CREATURE_AVAILABLE(PLAYER2,TROLL,1,1)
CREATURE_AVAILABLE(PLAYER1,ORC,1,1)
CREATURE_AVAILABLE(PLAYER0,DARK_MISTRESS,1,1)
CREATURE_AVAILABLE(PLAYER0,GHOST,1,1)
CREATURE_AVAILABLE(PLAYER1,VAMPIRE,1,1)
CREATURE_AVAILABLE(PLAYER0,TENTACLE,1,1)
CREATURE_AVAILABLE(PLAYER1,HORNY,1,1)

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

ROOM_AVAILABLE(ALL_PLAYERS,LAIR,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,GARDEN,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,TRAINING,1,1)
ROOM_AVAILABLE(PLAYER0,RESEARCH,1,1)
ROOM_AVAILABLE(PLAYER1,RESEARCH,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,GUARD_POST,1,0)
ROOM_AVAILABLE(PLAYER0,WORKSHOP,1,0)
ROOM_AVAILABLE(PLAYER1,BARRACKS,1,0)
ROOM_AVAILABLE(PLAYER0,TORTURE,1,0)
ROOM_AVAILABLE(PLAYER0,TEMPLE,1,0)
ROOM_AVAILABLE(PLAYER1,TEMPLE,1,0)
ROOM_AVAILABLE(PLAYER1,GRAVEYARD,1,0)
ROOM_AVAILABLE(PLAYER2,SCAVENGER,1,1)

IF(PLAYER0,TREASURE < 49)
    NEXT_COMMAND_REUSABLE
    ROOM_AVAILABLE(PLAYER0,TREASURE,1,1)
ENDIF

IF(PLAYER0,TREASURE >= 49)
    NEXT_COMMAND_REUSABLE
    ROOM_AVAILABLE(PLAYER0,TREASURE,0,0)
ENDIF

IF(PLAYER1,TREASURE < 49)
    NEXT_COMMAND_REUSABLE
    ROOM_AVAILABLE(PLAYER1,TREASURE,1,1)
ENDIF

IF(PLAYER1,TREASURE >= 49)
    NEXT_COMMAND_REUSABLE
    ROOM_AVAILABLE(PLAYER1,TREASURE,0,0)
ENDIF

IF(PLAYER2,TREASURE < 49)
    NEXT_COMMAND_REUSABLE
    ROOM_AVAILABLE(PLAYER2,TREASURE,1,1)
ENDIF

IF(PLAYER2,TREASURE >= 49)
    NEXT_COMMAND_REUSABLE
    ROOM_AVAILABLE(PLAYER2,TREASURE,0,0)
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_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_CAVE_IN,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HEAL_CREATURE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_LIGHTNING,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_PROTECT,1,0)
MAGIC_AVAILABLE(PLAYER1,POWER_CHICKEN,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_DISEASE,1,0)

MAGIC_AVAILABLE(PLAYER1,POWER_IMP,1,1)
MAGIC_AVAILABLE(PLAYER2,POWER_IMP,1,1)

SET_TIMER(PLAYER0,TIMER0)

IF(PLAYER0,TIMER0 >= 500)
    IF(PLAYER0,TOTAL_IMPS < 16)
        NEXT_COMMAND_REUSABLE
        ADD_CREATURE_TO_LEVEL(PLAYER0,IMP,PLAYER0,1,1,0)
        NEXT_COMMAND_REUSABLE
        SET_TIMER(PLAYER0,TIMER0)
    ENDIF
ENDIF

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

IF(PLAYER0,DUNGEON_DESTROYED == 1)
    LOSE_GAME
ENDIF

SET_CREATURE_HEALTH(MONK,2000)

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

CREATE_PARTY(ONE)
    ADD_TO_PARTY(ONE,ARCHER,7,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,ARCHER,6,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,THIEF,8,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,THIEF,8,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,BARBARIAN,7,600,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,BARBARIAN,7,600,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,DWARFA,8,600,ATTACK_ENEMIES,0)

CREATE_PARTY(TWO)
    ADD_TO_PARTY(TWO,DWARFA,8,800,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TWO,DWARFA,8,800,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TWO,DWARFA,8,800,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TWO,DWARFA,8,800,ATTACK_ENEMIES,0)

CREATE_PARTY(THREE)
    ADD_TO_PARTY(THREE,ARCHER,7,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(THREE,BARBARIAN,7,0,DEFEND_PARTY,0)

CREATE_PARTY(FOUR)
    ADD_TO_PARTY(FOUR,SAMURAI,10,500,DEFEND_PARTY,0)
    ADD_TO_PARTY(FOUR,SAMURAI,10,500,DEFEND_PARTY,0)
    ADD_TO_PARTY(FOUR,WIZARD,10,500,ATTACK_ENEMIES,0)

CREATE_PARTY(FIVE)
    ADD_TO_PARTY(FIVE,GIANT,10,600,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FIVE,GIANT,10,600,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FIVE,GIANT,10,600,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FIVE,GIANT,10,600,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,ARCHER,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SIX,ARCHER,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SIX,DWARFA,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SIX,THIEF,10,0,ATTACK_ENEMIES,0)

CREATE_PARTY(SEVEN)
    ADD_TO_PARTY(SEVEN,AVATAR,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SEVEN,KNIGHT,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SEVEN,KNIGHT,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SEVEN,SAMURAI,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SEVEN,SAMURAI,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SEVEN,GIANT,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SEVEN,BARBARIAN,10,0,ATTACK_ENEMIES,0)

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

IF_ACTION_POINT(1,PLAYER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,TROLL,2,9,7,500)
ENDIF

IF_ACTION_POINT(3,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,ONE,-1,1)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,MONK,-1,1,10,5000)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,KNIGHT,-1,1,10,200)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,DWARFA,-1,5,2,200)
ENDIF

SET_FLAG(PLAYER_GOOD,FLAG0,0)
SET_FLAG(PLAYER_GOOD,FLAG1,0)
SET_FLAG(PLAYER_GOOD,FLAG2,0)

IF(PLAYER2,DUNGEON_DESTROYED == 1)
    ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TWO,4,DUNGEON_HEART,0,8,800)
    ADD_CREATURE_TO_LEVEL(PLAYER3,VAMPIRE,-2,1,10,300)
    SET_FLAG(PLAYER_GOOD,FLAG0,1)
    SET_TIMER(PLAYER_GOOD,TIMER0)
    IF(PLAYER3,VAMPIRE == 0)
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,MONK,-1,1,10,5000)
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,DWARFA,-1,5,2,200)
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,KNIGHT,-1,1,10,200)
        SET_FLAG(PLAYER_GOOD,FLAG0,2)
        IF(PLAYER_GOOD,MONK == 0)
            ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TWO,6,ACTION_POINT,2,8,800)
            ADD_CREATURE_TO_LEVEL(PLAYER3,VAMPIRE,-3,1,10,300)
            SET_FLAG(PLAYER_GOOD,FLAG1,1)
            ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,FLY,5,5,10,0)
            SET_TIMER(PLAYER_GOOD,TIMER1)
            IF(PLAYER_GOOD,FLAG0 == 2)
                IF(PLAYER3,VAMPIRE == 0)
                    SET_FLAG(PLAYER_GOOD,FLAG1,2)
                ENDIF
            ENDIF
        ENDIF
    ENDIF
ENDIF

IF(PLAYER_GOOD,TIMER0 >= 400)
    IF(PLAYER_GOOD,FLAG0 == 1)
        NEXT_COMMAND_REUSABLE
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,THREE,-2,1)
        NEXT_COMMAND_REUSABLE
        SET_TIMER(PLAYER_GOOD,TIMER0)
    ENDIF
ENDIF

IF(PLAYER_GOOD,TIMER1 >= 800)
    IF(PLAYER_GOOD,FLAG1 == 1)
        NEXT_COMMAND_REUSABLE
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,FLY,5,2,10,0)
        NEXT_COMMAND_REUSABLE
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,DEMONSPAWN,-3,2,9,0)
        NEXT_COMMAND_REUSABLE
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,DRAGON,-3,1,6,0)
        NEXT_COMMAND_REUSABLE
        SET_TIMER(PLAYER_GOOD,TIMER1)
    ENDIF
ENDIF

IF_ACTION_POINT(7,PLAYER0)
    IF_ACTION_POINT(8,PLAYER0)
        ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TWO,9,ACTION_POINT,7,8,800)
    ENDIF
ENDIF

IF_ACTION_POINT(10,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FOUR,-4,2)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,MONK,-4,1,10,5000)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,KNIGHT,-4,1,10,200)
ENDIF

IF_ACTION_POINT(11,PLAYER0)
    ADD_CREATURE_TO_LEVEL(PLAYER3,VAMPIRE,-5,1,10,300)
    SET_FLAG(PLAYER_GOOD,FLAG2,1)
    SET_TIMER(PLAYER_GOOD,TIMER2)
    IF(PLAYER3,VAMPIRE == 0)
        SET_FLAG(PLAYER_GOOD,FLAG2,2)
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,MONK,12,1,10,5000)
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,KNIGHT,12,1,10,200)
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,FAIRY,15,5,10,0)
    ENDIF
ENDIF

IF(PLAYER_GOOD,TIMER2 >= 900)
    IF(PLAYER_GOOD,FLAG2 == 1)
        NEXT_COMMAND_REUSABLE
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,FAIRY,15,2,10,0)
        NEXT_COMMAND_REUSABLE
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,GIANT,-5,1,10,0)
        NEXT_COMMAND_REUSABLE
        SET_TIMER(PLAYER_GOOD,TIMER2)
    ENDIF
ENDIF

IF(PLAYER1,DUNGEON_DESTROYED == 1)
    ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TWO,13,ACTION_POINT,12,8,800)
ENDIF

IF(PLAYER_GOOD,TEMPLE == 0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,MONK,14,1,10,5000)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,KNIGHT,14,2,10,200)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FIVE,14,1)
    IF(PLAYER_GOOD,MONK == 0)
        SET_TIMER(PLAYER_GOOD,TIMER3)
    ENDIF
ENDIF

IF(PLAYER_GOOD,TIMER3 >= 550)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FIVE,-5,1)
    IF(PLAYER_GOOD,TIMER3 >= 1050)
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,SAMURAI,-1,1,10,0)
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,SAMURAI,-2,1,10,0)
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,SAMURAI,-3,1,10,0)
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,SAMURAI,-4,1,10,0)
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,SAMURAI,-6,1,10,0)
        IF(PLAYER_GOOD,TIMER3 >= 1600)
            ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,WITCH,-6,5,10,0)
            IF(PLAYER_GOOD,TIMER3 >= 3000)
                ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SIX,-6,1)
                ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SEVEN,-6,1)
                ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,FAIRY,16,3,10,0)
                ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,MONK,-6,2,10,0)
                ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,WITCH,16,1,10,0)
                ADD_CREATURE_TO_LEVEL(PLAYER0,VAMPIRE,0,2,7,0)
                ADD_CREATURE_TO_LEVEL(PLAYER0,VAMPIRE,0,1,8,0)
                SET_TIMER(PLAYER_GOOD,TIMER4)
                IF(PLAYER_GOOD,AVATAR == 0)
                    WIN_GAME
                ENDIF
            ENDIF
        ENDIF
    ENDIF
ENDIF

IF(PLAYER_GOOD,TIMER4 >= 3500)
    NEXT_COMMAND_REUSABLE
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FIVE,-6,1)
    NEXT_COMMAND_REUSABLE
    SET_TIMER(PLAYER_GOOD,TIMER4)
ENDIF
