REM ****************************************************************************
REM  Campaigns Consolidation Project for KeeperFX strategy game.
REM ****************************************************************************
REM  Script for Level Embattled formation (四面楚歌)
REM  Campaign: Twin Keepers
REM  Authors:  Original author unknown
REM            KeeperFX CCP Team
REM  Date:     31 Jul 2005 - 20 Jan 2011
REM  Copying and copyrights:
REM    This program is free software; you can redistribute it and/or modify
REM    it under the terms of the GNU General Public License as published by
REM    the Free Software Foundation; either version 2 of the License, or
REM    (at your option) any later version.
REM ****************************************************************************

START_MONEY(PLAYER0,10000)
START_MONEY(PLAYER1,10000)
START_MONEY(PLAYER2,10000)
START_MONEY(PLAYER3,10000)

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

ALLY_PLAYERS(PLAYER1,PLAYER2)
ALLY_PLAYERS(PLAYER2,PLAYER3)
ALLY_PLAYERS(PLAYER1,PLAYER3)

SET_GENERATE_SPEED(300)
SET_FLAG(PLAYER0,FLAG0,0)

MAX_CREATURES(PLAYER0,30)
MAX_CREATURES(PLAYER1,30)
MAX_CREATURES(PLAYER2,30)
MAX_CREATURES(PLAYER3,30)

ADD_CREATURE_TO_POOL(BUG,20)
ADD_CREATURE_TO_POOL(TROLL,20)
ADD_CREATURE_TO_POOL(DEMONSPAWN,20)
ADD_CREATURE_TO_POOL(SORCEROR,20)
ADD_CREATURE_TO_POOL(BILE_DEMON,20)
ADD_CREATURE_TO_POOL(SPIDER,20)
ADD_CREATURE_TO_POOL(ORC,20)
ADD_CREATURE_TO_POOL(TENTACLE,20)
ADD_CREATURE_TO_POOL(HELL_HOUND,20)
ADD_CREATURE_TO_POOL(SKELETON,20)
ADD_CREATURE_TO_POOL(FLY,20)
ADD_CREATURE_TO_POOL(DARK_MISTRESS,20)
ADD_CREATURE_TO_POOL(VAMPIRE,20)

CREATURE_AVAILABLE(ALL_PLAYERS,BUG,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,TROLL,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,DEMONSPAWN,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,SORCEROR,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,BILE_DEMON,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,SPIDER,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,ORC,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,TENTACLE,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,HELL_HOUND,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,SKELETON,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,FLY,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,DARK_MISTRESS,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,VAMPIRE,1,1)

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

MAGIC_AVAILABLE(ALL_PLAYERS,POWER_IMP,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_OBEY,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_SPEED,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_PROTECT,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CONCEAL,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CALL_TO_ARMS,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CHICKEN,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_DISEASE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_LIGHTNING,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CAVE_IN,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_ARMAGEDDON,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)
TRAP_AVAILABLE(ALL_PLAYERS,LAVA,1,0)

IF(PLAYER0,TOTAL_CREATURES > 0)
    IF(PLAYER0,GAME_TURN <= 10)
        LOSE_GAME
    ENDIF
ENDIF

IF(PLAYER0,GAME_TURN > 10000)
    SET_FLAG(PLAYER0,FLAG0,1)
ENDIF

IF(PLAYER0,GAME_TURN > 20000)
    SET_FLAG(PLAYER0,FLAG0,2)
ENDIF

IF(PLAYER0,GAME_TURN > 30000)
    SET_FLAG(PLAYER0,FLAG0,3)
ENDIF

IF(PLAYER0,GAME_TURN > 40000)
    SET_FLAG(PLAYER0,FLAG0,4)
ENDIF

IF(PLAYER0,GAME_TURN > 50000)
    SET_FLAG(PLAYER0,FLAG0,5)
ENDIF

IF(PLAYER1,DUNGEON_DESTROYED == 1)
    IF(PLAYER0,FLAG0 == 1)
        ADD_CREATURE_TO_LEVEL(PLAYER2,BILE_DEMON,2,5,4,500)
        ADD_CREATURE_TO_LEVEL(PLAYER3,BILE_DEMON,3,5,4,500)
    ENDIF
    IF(PLAYER0,FLAG0 == 2)
        ADD_CREATURE_TO_LEVEL(PLAYER2,HELL_HOUND,2,5,6,500)
        ADD_CREATURE_TO_LEVEL(PLAYER3,HELL_HOUND,3,5,6,500)
    ENDIF
    IF(PLAYER0,FLAG0 == 3)
        ADD_CREATURE_TO_LEVEL(PLAYER2,DRAGON,2,5,8,500)
        ADD_CREATURE_TO_LEVEL(PLAYER3,DRAGON,3,5,8,500)
    ENDIF
    IF(PLAYER0,FLAG0 == 4)
        ADD_CREATURE_TO_LEVEL(PLAYER2,ORC,2,5,9,500)
        ADD_CREATURE_TO_LEVEL(PLAYER3,ORC,3,5,9,500)
    ENDIF
    IF(PLAYER0,FLAG0 == 5)
        ADD_CREATURE_TO_LEVEL(PLAYER2,DARK_MISTRESS,2,5,9,500)
        ADD_CREATURE_TO_LEVEL(PLAYER3,DARK_MISTRESS,3,5,9,500)
    ENDIF
ENDIF
IF(PLAYER1,DUNGEON_DESTROYED == 1)
    IF(PLAYER2,DUNGEON_DESTROYED == 1)
        IF(PLAYER0,FLAG0 == 1)
            ADD_CREATURE_TO_LEVEL(PLAYER3,DRAGON,3,5,5,500)
        ENDIF
        IF(PLAYER0,FLAG0 == 2)
            ADD_CREATURE_TO_LEVEL(PLAYER3,SKELETON,3,10,6,500)
        ENDIF
        IF(PLAYER0,FLAG0 == 3)
            ADD_CREATURE_TO_LEVEL(PLAYER3,DARK_MISTRESS,3,5,8,500)
        ENDIF
        IF(PLAYER0,FLAG0 == 4)
            ADD_CREATURE_TO_LEVEL(PLAYER3,VAMPIRE,3,5,10,500)
        ENDIF
        IF(PLAYER0,FLAG0 == 5)
            ADD_CREATURE_TO_LEVEL(PLAYER3,HORNY,3,5,9,500)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER2,DUNGEON_DESTROYED == 1)
    IF(PLAYER0,FLAG0 == 1)
        ADD_CREATURE_TO_LEVEL(PLAYER3,BILE_DEMON,3,5,4,500)
        ADD_CREATURE_TO_LEVEL(PLAYER1,BILE_DEMON,1,5,4,500)
    ENDIF
    IF(PLAYER0,FLAG0 == 2)
        ADD_CREATURE_TO_LEVEL(PLAYER3,HELL_HOUND,3,5,6,500)
        ADD_CREATURE_TO_LEVEL(PLAYER1,HELL_HOUND,1,5,6,500)
    ENDIF
    IF(PLAYER0,FLAG0 == 3)
        ADD_CREATURE_TO_LEVEL(PLAYER3,DRAGON,3,5,8,500)
        ADD_CREATURE_TO_LEVEL(PLAYER1,DRAGON,1,5,8,500)
    ENDIF
    IF(PLAYER0,FLAG0 == 4)
        ADD_CREATURE_TO_LEVEL(PLAYER3,ORC,3,5,9,500)
        ADD_CREATURE_TO_LEVEL(PLAYER1,ORC,1,5,9,500)
    ENDIF
    IF(PLAYER0,FLAG0 == 5)
        ADD_CREATURE_TO_LEVEL(PLAYER3,DARK_MISTRESS,3,5,9,500)
        ADD_CREATURE_TO_LEVEL(PLAYER1,DARK_MISTRESS,1,5,9,500)
    ENDIF
ENDIF
IF(PLAYER2,DUNGEON_DESTROYED == 1)
    IF(PLAYER3,DUNGEON_DESTROYED == 1)
        IF(PLAYER0,FLAG0 == 1)
            ADD_CREATURE_TO_LEVEL(PLAYER1,DRAGON,1,5,5,500)
        ENDIF
        IF(PLAYER0,FLAG0 == 2)
            ADD_CREATURE_TO_LEVEL(PLAYER1,SKELETON,1,10,6,500)
        ENDIF
        IF(PLAYER0,FLAG0 == 3)
            ADD_CREATURE_TO_LEVEL(PLAYER1,DARK_MISTRESS,1,5,8,500)
        ENDIF
        IF(PLAYER0,FLAG0 == 4)
            ADD_CREATURE_TO_LEVEL(PLAYER1,VAMPIRE,1,5,10,500)
        ENDIF
        IF(PLAYER0,FLAG0 == 5)
            ADD_CREATURE_TO_LEVEL(PLAYER1,HORNY,1,5,9,500)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER3,DUNGEON_DESTROYED == 1)
    IF(PLAYER0,FLAG0 == 1)
        ADD_CREATURE_TO_LEVEL(PLAYER1,BILE_DEMON,1,5,4,500)
        ADD_CREATURE_TO_LEVEL(PLAYER2,BILE_DEMON,2,5,4,500)
    ENDIF
    IF(PLAYER0,FLAG0 == 2)
        ADD_CREATURE_TO_LEVEL(PLAYER1,HELL_HOUND,1,5,6,500)
        ADD_CREATURE_TO_LEVEL(PLAYER2,HELL_HOUND,2,5,6,500)
    ENDIF
    IF(PLAYER0,FLAG0 == 3)
        ADD_CREATURE_TO_LEVEL(PLAYER1,DRAGON,1,5,8,500)
        ADD_CREATURE_TO_LEVEL(PLAYER2,DRAGON,2,5,8,500)
    ENDIF
    IF(PLAYER0,FLAG0 == 4)
        ADD_CREATURE_TO_LEVEL(PLAYER1,ORC,1,5,9,500)
        ADD_CREATURE_TO_LEVEL(PLAYER2,ORC,2,5,9,500)
    ENDIF
    IF(PLAYER0,FLAG0 == 5)
        ADD_CREATURE_TO_LEVEL(PLAYER1,DARK_MISTRESS,1,5,9,500)
        ADD_CREATURE_TO_LEVEL(PLAYER2,DARK_MISTRESS,2,5,9,500)
    ENDIF
ENDIF
IF(PLAYER3,DUNGEON_DESTROYED == 1)
    IF(PLAYER1,DUNGEON_DESTROYED == 1)
        IF(PLAYER0,FLAG0 == 1)
            ADD_CREATURE_TO_LEVEL(PLAYER2,DRAGON,2,5,5,500)
        ENDIF
        IF(PLAYER0,FLAG0 == 2)
            ADD_CREATURE_TO_LEVEL(PLAYER2,SKELETON,2,10,6,500)
        ENDIF
        IF(PLAYER0,FLAG0 == 3)
            ADD_CREATURE_TO_LEVEL(PLAYER2,DARK_MISTRESS,2,5,8,500)
        ENDIF
        IF(PLAYER0,FLAG0 == 4)
            ADD_CREATURE_TO_LEVEL(PLAYER2,VAMPIRE,2,5,10,500)
        ENDIF
        IF(PLAYER0,FLAG0 == 5)
            ADD_CREATURE_TO_LEVEL(PLAYER2,HORNY,2,5,9,500)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER0,ALL_DUNGEONS_DESTROYED == 1)
    WIN_GAME
ENDIF
