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            Switched to translatable objectives by dayokay Nov 2014
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 ****************************************************************************

LEVEL_VERSION(1)

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,1)
ALLY_PLAYERS(PLAYER2,PLAYER3,1)
ALLY_PLAYERS(PLAYER1,PLAYER3,1)

SET_GENERATE_SPEED(300)

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

ADD_CREATURE_TO_POOL(BUG,16)
ADD_CREATURE_TO_POOL(TROLL,16)
ADD_CREATURE_TO_POOL(DEMONSPAWN,12)
ADD_CREATURE_TO_POOL(SORCEROR,20)
ADD_CREATURE_TO_POOL(BILE_DEMON,12)
ADD_CREATURE_TO_POOL(SPIDER,16)
ADD_CREATURE_TO_POOL(ORC,8)
ADD_CREATURE_TO_POOL(FLY,20)
ADD_CREATURE_TO_POOL(DARK_MISTRESS,8)

CREATURE_AVAILABLE(ALL_PLAYERS,BUG,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,SORCEROR,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,SPIDER,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,FLY,1,0)

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)
ROOM_AVAILABLE(PLAYER1,BRIDGE,1,0)
ROOM_AVAILABLE(PLAYER2,BRIDGE,1,0)
ROOM_AVAILABLE(PLAYER3,BRIDGE,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)

DISPLAY_OBJECTIVE(31)

REM Cannot transfer creature from previous realm
IF(PLAYER0,TOTAL_CREATURES > 0)
    IF(PLAYER0,GAME_TURN <= 100)
        LOSE_GAME
    ENDIF
ENDIF

REM Over time, give better creatures and increase creature limit
IF(PLAYER0,GAME_TURN > 15000)
    MAX_CREATURES(ALL_PLAYERS,15)
    CREATURE_AVAILABLE(ALL_PLAYERS,DEMONSPAWN,1,0)
    CREATURE_AVAILABLE(ALL_PLAYERS,BILE_DEMON,1,0)
ENDIF
IF(PLAYER0,GAME_TURN > 30000)
    MAX_CREATURES(ALL_PLAYERS,20)
    CREATURE_AVAILABLE(ALL_PLAYERS,TROLL,1,0)
    CREATURE_AVAILABLE(ALL_PLAYERS,ORC,1,0)
ENDIF
IF(PLAYER0,GAME_TURN > 40000)
    MAX_CREATURES(ALL_PLAYERS,30)
    CREATURE_AVAILABLE(ALL_PLAYERS,DARK_MISTRESS,1,0)
ENDIF

REM Killing a player strengthens the other players

IF(PLAYER0,FLAG1 == 1)
REM "A good start keeper, but beware. The remaining keepers grow stronger by pilfering the remnants of this dead kingdom, and therefore attract more creatures anxious to share the spoils!"
    DISPLAY_INFORMATION(34)
ENDIF

REM Triggered by PLAYER1 being destroyed

IF(PLAYER1,DUNGEON_DESTROYED == 1)
    SET_TIMER(PLAYER0,TIMER1)
    ADD_TO_FLAG(PLAYER0,FLAG1,1)
ENDIF

IF(PLAYER0,TIMER1 > 1000)
    ADD_CREATURE_TO_LEVEL(PLAYER2,TENTACLE,2,5,4,500)
    ADD_CREATURE_TO_LEVEL(PLAYER3,TENTACLE,3,5,4,500)
ENDIF
IF(PLAYER0,TIMER1 > 3000)
    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,TIMER1 > 6000)
    ADD_CREATURE_TO_LEVEL(PLAYER2,DRAGON,2,5,8,500)
    ADD_CREATURE_TO_LEVEL(PLAYER3,DRAGON,3,5,8,500)
ENDIF
IF(PLAYER0,TIMER1 > 8000)
    ADD_CREATURE_TO_LEVEL(PLAYER2,ORC,2,5,9,500)
    ADD_CREATURE_TO_LEVEL(PLAYER3,ORC,3,5,9,500)
ENDIF
IF(PLAYER0,TIMER1 > 10000)
    ADD_CREATURE_TO_LEVEL(PLAYER2,DARK_MISTRESS,2,5,9,500)
    ADD_CREATURE_TO_LEVEL(PLAYER3,DARK_MISTRESS,3,5,9,500)
ENDIF

REM Triggered by PLAYER2 being destroyed

IF(PLAYER2,DUNGEON_DESTROYED == 1)
    ADD_TO_FLAG(PLAYER0,FLAG1,1)
    SET_TIMER(PLAYER0,TIMER2)
ENDIF

IF(PLAYER0,TIMER2 > 1000)
    ADD_CREATURE_TO_LEVEL(PLAYER3,TENTACLE,3,5,4,500)
    ADD_CREATURE_TO_LEVEL(PLAYER1,TENTACLE,1,5,4,500)
ENDIF
IF(PLAYER0,TIMER2 > 3000)
    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,TIMER2 > 6000)
    ADD_CREATURE_TO_LEVEL(PLAYER3,DRAGON,3,5,8,500)
    ADD_CREATURE_TO_LEVEL(PLAYER1,DRAGON,1,5,8,500)
ENDIF
IF(PLAYER0,TIMER2 > 8000)
    ADD_CREATURE_TO_LEVEL(PLAYER3,ORC,3,5,9,500)
    ADD_CREATURE_TO_LEVEL(PLAYER1,ORC,1,5,9,500)
ENDIF
IF(PLAYER0,TIMER2 > 10000)
    ADD_CREATURE_TO_LEVEL(PLAYER3,DARK_MISTRESS,3,5,9,500)
    ADD_CREATURE_TO_LEVEL(PLAYER1,DARK_MISTRESS,1,5,9,500)
ENDIF

REM Triggered by PLAYER3 being destroyed
IF(PLAYER3,DUNGEON_DESTROYED == 1)
    ADD_TO_FLAG(PLAYER0,FLAG1,1)
    SET_TIMER(PLAYER0,TIMER3)
ENDIF

IF(PLAYER0,TIMER3 > 1000)
    ADD_CREATURE_TO_LEVEL(PLAYER1,TENTACLE,1,5,4,500)
    ADD_CREATURE_TO_LEVEL(PLAYER2,TENTACLE,2,5,4,500)
ENDIF
IF(PLAYER0,TIMER3 > 3000)
    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,TIMER3 > 6000)
    ADD_CREATURE_TO_LEVEL(PLAYER1,DRAGON,1,5,8,500)
    ADD_CREATURE_TO_LEVEL(PLAYER2,DRAGON,2,5,8,500)
ENDIF
IF(PLAYER0,TIMER3 > 8000)
    ADD_CREATURE_TO_LEVEL(PLAYER1,ORC,1,5,9,500)
    ADD_CREATURE_TO_LEVEL(PLAYER2,ORC,2,5,9,500)
ENDIF
IF(PLAYER0,TIMER3 > 10000)
    ADD_CREATURE_TO_LEVEL(PLAYER1,DARK_MISTRESS,1,5,9,500)
    ADD_CREATURE_TO_LEVEL(PLAYER2,DARK_MISTRESS,2,5,9,500)
ENDIF

REM Additional actions triggered when two of the enemy players are destroyed
IF(PLAYER0,FLAG1 == 2)
REM Impressive work master. It is a privilege to watch you wreak destruction on your enemies. Only one enemy remains, but beware, he has seen his allies' fate and will throw everything into the battle to save his skin!"
    DISPLAY_INFORMATION(32)
ENDIF

REM When PLAYER1 and PLAYER2 are gone
IF(PLAYER0,TIMER1 > 1000)
    IF(PLAYER0,TIMER2 > 1000)
        ADD_CREATURE_TO_LEVEL(PLAYER3,HORNY,3,5,9,500)
    ENDIF
ENDIF

REM When PLAYER2 and PLAYER3 are gone
IF(PLAYER0,TIMER2 > 1000)
    IF(PLAYER0,TIMER3 > 1000)
        ADD_CREATURE_TO_LEVEL(PLAYER1,HORNY,1,5,9,500)
    ENDIF
ENDIF

REM When PLAYER1 and PLAYER3 are gone
IF(PLAYER0,TIMER1 > 1000)
    IF(PLAYER0,TIMER3 > 1000)
        ADD_CREATURE_TO_LEVEL(PLAYER2,HORNY,2,5,9,500)
    ENDIF
ENDIF

IF(PLAYER0,ALL_DUNGEONS_DESTROYED == 1)
REM "An excellent victory once again. All three enemies lie amongst the dust of this once green and pleasant land. I sense you want to find the next land, Master?"
    DISPLAY_OBJECTIVE(33,ALL_PLAYERS)
    WIN_GAME
ENDIF
