REM ****************************************************************************
REM  Campaigns Consolidation Project for KeeperFX strategy game.
REM ****************************************************************************
REM  Script for Level Blaise End
REM  Campaign: DK Original
REM  Authors:  based on Bullfrog script
REM            KeeperFX CCP Team
REM  Date:     17 Dec 1996 - 11 Feb 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 ****************************************************************************

REM Nothing new for the player

SET_GENERATE_SPEED(800)

START_MONEY(PLAYER0,10000)

MAX_CREATURES(PLAYER0,60)

ADD_CREATURE_TO_POOL(TROLL,5)
ADD_CREATURE_TO_POOL(SORCEROR,3)
ADD_CREATURE_TO_POOL(BILE_DEMON,7)
ADD_CREATURE_TO_POOL(DARK_MISTRESS,15)
ADD_CREATURE_TO_POOL(TENTACLE,15)
ADD_CREATURE_TO_POOL(HELL_HOUND,10)
ADD_CREATURE_TO_POOL(DRAGON,20)
ADD_CREATURE_TO_POOL(VAMPIRE,3)
ADD_CREATURE_TO_POOL(ORC,20)

REM Creature availability
CREATURE_AVAILABLE(ALL_PLAYERS,TROLL,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,SORCEROR,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,BILE_DEMON,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,DARK_MISTRESS,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,TENTACLE,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,HELL_HOUND,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,DRAGON,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,VAMPIRE,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,ORC,1,1)
    
REM Room availability
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,BRIDGE,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)

REM Spells availability
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HAND,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_IMP,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SLAP,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SIGHT,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CALL_TO_ARMS,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_HOLD_AUDIENCE,1,0)

REM Doors and traps availability
DOOR_AVAILABLE(ALL_PLAYERS,WOOD,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,ALARM,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,BRACED,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,POISON_GAS,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,LAVA,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,STEEL,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,BOULDER,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,MAGIC,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,LIGHTNING,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,WORD_OF_POWER,1,0)

CREATE_PARTY(ONE)
    ADD_TO_PARTY(ONE,THIEF,2,300,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,THIEF,2,300,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,THIEF,2,300,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ONE,ARCHER,4,400,ATTACK_ENEMIES,0)

CREATE_PARTY(TWO)
    ADD_TO_PARTY(TWO,ARCHER,3,400,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TWO,ARCHER,3,400,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TWO,ARCHER,3,400,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TWO,BARBARIAN,4,500,ATTACK_ENEMIES,0)

CREATE_PARTY(THREE)
    ADD_TO_PARTY(THREE,DWARFA,4,300,ATTACK_ROOMS,0)
    ADD_TO_PARTY(THREE,DWARFA,4,300,ATTACK_ROOMS,0)
    ADD_TO_PARTY(THREE,DWARFA,4,300,ATTACK_ROOMS,0)
    ADD_TO_PARTY(THREE,DWARFA,4,300,ATTACK_ROOMS,0)
    ADD_TO_PARTY(THREE,DWARFA,4,300,ATTACK_ROOMS,0)

CREATE_PARTY(FOUR)
    ADD_TO_PARTY(FOUR,WITCH,5,750,STEAL_SPELLS,0)
    ADD_TO_PARTY(FOUR,WITCH,5,750,STEAL_SPELLS,0)
    ADD_TO_PARTY(FOUR,WITCH,5,750,STEAL_SPELLS,0)
    ADD_TO_PARTY(FOUR,THIEF,5,500,STEAL_GOLD,0)

CREATE_PARTY(FIVE)
    ADD_TO_PARTY(FIVE,BARBARIAN,5,1000,DEFEND_PARTY,0)
    ADD_TO_PARTY(FIVE,FAIRY,5,1000,STEAL_SPELLS,0)
    ADD_TO_PARTY(FIVE,BARBARIAN,5,1000,DEFEND_PARTY,0)
    ADD_TO_PARTY(FIVE,FAIRY,5,1000,STEAL_SPELLS,0)
    ADD_TO_PARTY(FIVE,BARBARIAN,5,1000,DEFEND_PARTY,0)
    ADD_TO_PARTY(FIVE,FAIRY,7,1000,STEAL_SPELLS,0)

CREATE_PARTY(SIX)
    ADD_TO_PARTY(SIX,ARCHER,5,1250,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SIX,ARCHER,5,1250,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SIX,ARCHER,5,1250,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SIX,ARCHER,5,1250,ATTACK_ENEMIES,0)

CREATE_PARTY(SEVEN)
    ADD_TO_PARTY(SEVEN,BARBARIAN,7,2000,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SEVEN,BARBARIAN,7,2000,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SEVEN,BARBARIAN,7,2000,ATTACK_ENEMIES,0)

CREATE_PARTY(LORDGUARD)
    ADD_TO_PARTY(LORDGUARD,BARBARIAN,5,1000,DEFEND_PARTY,0)
    ADD_TO_PARTY(LORDGUARD,GIANT,7,1500,DEFEND_PARTY,0)
    ADD_TO_PARTY(LORDGUARD,BARBARIAN,5,1000,DEFEND_PARTY,0)
    ADD_TO_PARTY(LORDGUARD,GIANT,7,1500,DEFEND_PARTY,0)
    ADD_TO_PARTY(LORDGUARD,FAIRY,7,1500,DEFEND_PARTY,0)
    ADD_TO_PARTY(LORDGUARD,FAIRY,7,1500,DEFEND_PARTY,0)

CREATE_PARTY(LANDLORD)
    ADD_TO_PARTY(LANDLORD,FAIRY,9,1200,DEFEND_PARTY,0)
    ADD_TO_PARTY(LANDLORD,FAIRY,9,1200,DEFEND_PARTY,0)
    ADD_TO_PARTY(LANDLORD,FAIRY,9,1200,DEFEND_PARTY,0)
    ADD_TO_PARTY(LANDLORD,FAIRY,9,1200,DEFEND_PARTY,0)
    ADD_TO_PARTY(LANDLORD,FAIRY,6,1200,DEFEND_PARTY,0)
    ADD_TO_PARTY(LANDLORD,FAIRY,6,1200,DEFEND_PARTY,0)
    ADD_TO_PARTY(LANDLORD,KNIGHT,7,1200,DEFEND_PARTY,0)

CREATE_PARTY(TROOPA)
    ADD_TO_PARTY(TROOPA,ARCHER,3,200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TROOPA,ARCHER,3,200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TROOPA,ARCHER,3,200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TROOPA,ARCHER,3,200,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TROOPA,ARCHER,3,200,ATTACK_ENEMIES,0)

CREATE_PARTY(TROOPB)
    ADD_TO_PARTY(TROOPB,THIEF,4,300,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TROOPB,THIEF,4,300,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TROOPB,THIEF,4,300,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TROOPB,THIEF,4,300,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TROOPB,ARCHER,4,300,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(TROOPB,ARCHER,4,300,ATTACK_ENEMIES,0)

CREATE_PARTY(CASTERS)
    ADD_TO_PARTY(CASTERS,WIZARD,4,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(CASTERS,WIZARD,4,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(CASTERS,WIZARD,4,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(CASTERS,WITCH,4,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(CASTERS,WITCH,4,500,ATTACK_ENEMIES,0)    
    ADD_TO_PARTY(CASTERS,WITCH,4,500,ATTACK_ENEMIES,0)

CREATE_PARTY(BARBIES)
    ADD_TO_PARTY(BARBIES,BARBARIAN,5,750,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(BARBIES,BARBARIAN,5,750,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(BARBIES,BARBARIAN,5,750,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(BARBIES,BARBARIAN,5,750,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(BARBIES,BARBARIAN,5,750,ATTACK_ENEMIES,0)

CREATE_PARTY(GIANTS)
    ADD_TO_PARTY(GIANTS,GIANT,8,1750,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(GIANTS,GIANT,8,1750,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(GIANTS,GIANT,8,1750,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(GIANTS,GIANT,8,1750,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(GIANTS,GIANT,8,1750,ATTACK_ENEMIES,0)

CREATE_PARTY(FAIRIES)
    ADD_TO_PARTY(FAIRIES,FAIRY,8,1750,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FAIRIES,FAIRY,8,1750,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FAIRIES,FAIRY,8,1750,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FAIRIES,FAIRY,8,1750,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FAIRIES,FAIRY,8,1750,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(FAIRIES,FAIRY,8,1750,ATTACK_ENEMIES,0)

REM ****************************************************************************

REM        FLAG LIST

REM        PLAYER0,FLAG0        ~    SAYS WHICH OF THE PHASES WE'RE IN

REM        LIST OF ACTION POINTS

REM        AP1                ~    ENTRANCE TO HERO DUNGEON
REM        AP2                ~        
REM        AP3                ~        
REM        AP4                ~        
REM        AP5                ~        
REM        AP6                ~        

REM        TIMER LIST

REM        PLAYER_GOOD,TIMER0     ~    GAP AFTER INVADING BEFORE YOU ARE CRUSHED
REM        PLAYER0,TIMER1        ~       
REM        PLAYER0,TIMER2        ~       
REM        PLAYER0,TIMER3        ~       

REM 127 "The good forces of this land lay slumbering, unaware of your arrival. Plan an early attack on the heroes castle, delay too long, and you will lose the advantage of surprise."
REM 128 "Beware, you may encounter hero patrols whilst you explore this land. It is imperative that none of their number are permitted to escape and reveal your presence."
REM 129 "Time is running out. Attack and destroy the heroes dungeon soon, before more help can be called."
REM 130 "Hero reinforcements have arrived, fight for your life."
REM 131 "Make sure that your assault on the hero castle deals a final blow to the hero forces of the land. Kill all of the heroes and then destroy the dungeon heart."

DISPLAY_OBJECTIVE(127,PLAYER0)

IF(PLAYER0,TOTAL_GOLD_MINED >= 12000)
    DISPLAY_INFORMATION(128)
ENDIF

IF(PLAYER0,TOTAL_GOLD_MINED >= 15000)
    ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,ONE,-1,DUNGEON,0,2,250)
ENDIF

IF(PLAYER0,TOTAL_GOLD_MINED >= 25000)
    ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TWO,-2,DUNGEON,0,3,250)
    SET_TIMER(PLAYER_GOOD,TIMER6)
    IF(PLAYER_GOOD,TIMER6 >= 5000)
        ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,ONE,-2,DUNGEON,0,4,300)
    ENDIF
ENDIF

IF(PLAYER0,TOTAL_GOLD_MINED >= 35000)
    ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TWO,-2,DUNGEON,0,5,250)
    SET_TIMER(PLAYER_GOOD,TIMER7)
    IF(PLAYER_GOOD,TIMER7 >= 1500)
        ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,THREE,-2,DUNGEON,0,6,250)
        IF(PLAYER_GOOD,DWARFA == 0)
            DISPLAY_INFORMATION(129)
            SET_TIMER(PLAYER0,TIMER5)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER0,TIMER5 >= 5000)
    IF(PLAYER0,FLAG4 == 0)
        ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TROOPA,-1,DUNGEON,0,5,300)
        ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TROOPB,-2,DUNGEON,0,5,300)
        ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,CASTERS,-1,DUNGEON,0,5,300)
        ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,BARBIES,-2,DUNGEON,0,5,300)
        ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,GIANTS,-1,DUNGEON,0,5,300)
        ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,FAIRIES,-2,DUNGEON,0,5,300)
    ENDIF
ENDIF

IF_ACTION_POINT(1,PLAYER0)
    SET_FLAG(PLAYER0,FLAG4,1)
    DISPLAY_OBJECTIVE(131,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,LORDGUARD,5,1)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,LANDLORD,PLAYER_GOOD,1)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,1,6,6,500)
    SET_TIMER(PLAYER2,TIMER2)
    SET_FLAG(PLAYER2,FLAG2,2)
    SET_TIMER(PLAYER_GOOD,TIMER0)
    IF(PLAYER_GOOD,KNIGHT == 0)
        IF(PLAYER_GOOD,DUNGEON_DESTROYED == 1)
            WIN_GAME
            DISPLAY_OBJECTIVE(162,PLAYER0)
            SET_FLAG(PLAYER2,FLAG2,3)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER2,FLAG2 == 2)
    IF(PLAYER2,TIMER2 >= 2500)
        NEXT_COMMAND_REUSABLE
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TWO,PLAYER_GOOD,1)
        NEXT_COMMAND_REUSABLE
        SET_TIMER(PLAYER2,TIMER2)
    ENDIF
ENDIF

IF(PLAYER_GOOD,TIMER0 >= 10000)
    DISPLAY_INFORMATION(130)
    ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,ONE,-1,DUNGEON,0,2,250)
    ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,TWO,-1,DUNGEON,0,2,250)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,THREE,PLAYER_GOOD,1)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FOUR,PLAYER_GOOD,1)
    ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,FIVE,-2,DUNGEON,0,2,250)
ENDIF

IF_ACTION_POINT(2,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SIX,-3,1)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SEVEN,-4,1)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,2,4,4,500)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,2,4,6,500)
ENDIF

IF_ACTION_POINT(3,PLAYER0)
    SET_TIMER(PLAYER0,TIMER4)
    IF(PLAYER0,TIMER4 >= 200)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SEVEN,4,1)
    ENDIF
ENDIF

IF_ACTION_POINT(5,PLAYER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,WIZARD,5,7,8,500)
ENDIF

IF_ACTION_POINT(6,PLAYER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,6,6,6,500)
ENDIF

IF_ACTION_POINT(7,PLAYER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,7,6,8,500)
ENDIF

IF_ACTION_POINT(8,PLAYER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,GIANT,8,6,8,500)
ENDIF

IF_ACTION_POINT(9,PLAYER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,BARBARIAN,9,8,7,500)
ENDIF

IF_ACTION_POINT(10,PLAYER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,10,4,4,500)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,10,4,6,500)
ENDIF

IF_ACTION_POINT(11,PLAYER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,WIZARD,11,7,8,500)
ENDIF
