REM ****************************************************************************
REM  Campaigns Consolidation Project for KeeperFX strategy game.
REM ****************************************************************************
REM  Script for Level Invisible (インビジブル)
REM  Campaign: Twin Keepers
REM  Authors:  Original author unknown
REM            KeeperFX CCP Team
REM  Date:     05 Aug 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,0)

SET_GENERATE_SPEED(500)

MAX_CREATURES(PLAYER0,20)

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

ADD_CREATURE_TO_POOL(DRAGON,20)
ADD_CREATURE_TO_POOL(TROLL,20)
ADD_CREATURE_TO_POOL(BUG,20)
ADD_CREATURE_TO_POOL(DEMONSPAWN,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(VAMPIRE,20)

CREATURE_AVAILABLE(ALL_PLAYERS,DRAGON,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,TROLL,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,BUG,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,DEMONSPAWN,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,VAMPIRE,1,1)

ROOM_AVAILABLE(PLAYER0,LAIR,1,1)
ROOM_AVAILABLE(PLAYER0,GARDEN,1,1)
ROOM_AVAILABLE(PLAYER0,TRAINING,1,1)
ROOM_AVAILABLE(PLAYER0,RESEARCH,1,1)
ROOM_AVAILABLE(PLAYER0,BARRACKS,1,0)
ROOM_AVAILABLE(PLAYER0,WORKSHOP,1,0)
ROOM_AVAILABLE(PLAYER0,TEMPLE,1,0)
ROOM_AVAILABLE(PLAYER0,SCAVENGER,1,0)

MAGIC_AVAILABLE(PLAYER0,POWER_IMP,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_OBEY,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_HOLD_AUDIENCE,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_HEAL_CREATURE,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_SPEED,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_PROTECT,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_CONCEAL,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_CALL_TO_ARMS,1,0)

TRAP_AVAILABLE(ALL_PLAYERS,ALARM,1,0)

SET_CREATURE_FEAR(IMP,30)
SET_CREATURE_FEAR(THIEF,255)

CREATE_PARTY(INVISIBLE)
    ADD_TO_PARTY(INVISIBLE,THIEF,9,0,STEAL_GOLD,0)

CREATE_PARTY(PARTY1)
    ADD_TO_PARTY(PARTY1,FAIRY,10,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY1,KNIGHT,10,10000,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY1,FAIRY,10,500,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(PARTY2)
    ADD_TO_PARTY(PARTY2,FAIRY,10,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY2,SAMURAI,10,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY2,FAIRY,10,500,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(PARTY3)
    ADD_TO_PARTY(PARTY3,DWARFA,1,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY3,WITCH,1,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY3,ARCHER,1,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY3,BARBARIAN,1,500,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(PARTY4)
    ADD_TO_PARTY(PARTY4,SAMURAI,5,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY4,GIANT,5,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY4,WIZARD,6,500,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(PARTY5)
    ADD_TO_PARTY(PARTY5,SAMURAI,10,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY5,DWARFA,10,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY5,WITCH,10,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY5,WITCH,10,500,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(PARTY6)
    ADD_TO_PARTY(PARTY6,WIZARD,10,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY6,MONK,10,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY6,ARCHER,10,500,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(PARTY7)
    ADD_TO_PARTY(PARTY7,DWARFA,4,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY7,BARBARIAN,5,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY7,GIANT,4,500,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(PARTY8)
    ADD_TO_PARTY(PARTY8,WIZARD,8,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY8,MONK,8,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY8,ARCHER,6,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY8,ARCHER,6,500,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(PARTY9)
    ADD_TO_PARTY(PARTY9,GIANT,9,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY9,GIANT,9,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY9,MONK,9,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY9,DWARFA,9,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY9,DWARFA,9,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY9,WITCH,9,500,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(PARTY10)
    ADD_TO_PARTY(PARTY10,SAMURAI,10,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY10,MONK,10,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY10,DWARFA,10,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY10,WITCH,10,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY10,BARBARIAN,10,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY10,WIZARD,10,500,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(PARTY11)
    ADD_TO_PARTY(PARTY11,ARCHER,3,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY11,DWARFA,3,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY11,WITCH,3,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY11,WIZARD,3,500,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(PARTY12)
    ADD_TO_PARTY(PARTY12,GIANT,2,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY12,MONK,2,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY12,ARCHER,2,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY12,WITCH,2,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY12,BARBARIAN,2,500,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(PARTY13)
    ADD_TO_PARTY(PARTY13,SAMURAI,4,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY13,WIZARD,4,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY13,BARBARIAN,4,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY13,ARCHER,3,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY13,ARCHER,3,500,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(PARTY14)
    ADD_TO_PARTY(PARTY14,GIANT,8,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY14,GIANT,8,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY14,GIANT,8,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY14,FAIRY,8,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY14,FAIRY,8,500,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(PARTY14,FAIRY,8,500,ATTACK_DUNGEON_HEART,0)

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

IF_ACTION_POINT(1,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY11,-1,1)
    SET_TIMER(PLAYER_GOOD,TIMER1)
ENDIF

IF_ACTION_POINT(2,PLAYER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,DWARFA,-1,4,3,500)
ENDIF

IF_ACTION_POINT(3,PLAYER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,BARBARIAN,-1,4,3,500)
ENDIF

IF_ACTION_POINT(4,PLAYER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,GIANT,-1,4,4,500)
ENDIF

IF_ACTION_POINT(5,PLAYER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,SAMURAI,5,4,4,500)
ENDIF

IF_ACTION_POINT(6,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY7,6,2)
ENDIF

IF_ACTION_POINT(28,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY4,28,2)
ENDIF

IF_ACTION_POINT(7,PLAYER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,WITCH,28,6,7,500)
ENDIF

IF_ACTION_POINT(9,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY14,8,1)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY14,10,1)
ENDIF

IF_ACTION_POINT(11,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY8,12,2)
ENDIF

IF_ACTION_POINT(13,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY9,14,1)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY9,15,1)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY9,16,1)
ENDIF

IF_ACTION_POINT(17,PLAYER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,SAMURAI,17,10,10,500)
ENDIF

IF_ACTION_POINT(18,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY6,19,4)
ENDIF

IF_ACTION_POINT(20,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY5,21,2)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY5,22,2)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY5,23,2)
ENDIF

IF_ACTION_POINT(24,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY10,25,2)
ENDIF

IF_ACTION_POINT(26,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY10,26,4)
ENDIF

IF_ACTION_POINT(29,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY5,29,3)
ENDIF

IF_ACTION_POINT(30,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY2,30,5)
ENDIF

IF(PLAYER0,GRAVEYARD >= 1)
    ROOM_AVAILABLE(PLAYER0,GRAVEYARD,1,1)
ENDIF

IF(PLAYER0,ENTRANCE >= 1)
    SET_TIMER(PLAYER_GOOD,TIMER0)
    IF(PLAYER0,MONEY == 0)
        SET_FLAG(PLAYER0,FLAG0,1)
    ENDIF
ENDIF

IF(PLAYER_GOOD,TIMER0 > 3000)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY3,27,1)
ENDIF

IF(PLAYER_GOOD,TIMER0 > 6000)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY12,27,1)
ENDIF

IF(PLAYER_GOOD,TIMER0 > 8000)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,DWARFA,-1,4,2,500)
ENDIF

IF(PLAYER_GOOD,TIMER0 > 10000)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY11,27,1)
ENDIF

IF(PLAYER_GOOD,TIMER0 > 15000)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY13,27,2)
ENDIF

IF(PLAYER_GOOD,TIMER0 > 20000)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,INVISIBLE,-1,2)
ENDIF

IF(PLAYER_GOOD,TIMER0 > 24000)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY7,27,3)
ENDIF

IF(PLAYER_GOOD,TIMER0 > 30000)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,BARBARIAN,-1,4,4,500)
ENDIF

IF(PLAYER_GOOD,TIMER0 > 35000)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY4,27,3)
ENDIF

IF(PLAYER_GOOD,TIMER0 > 39000)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,GIANT,-1,4,5,500)
ENDIF

IF(PLAYER_GOOD,TIMER0 > 42000)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY8,27,3)
ENDIF

IF(PLAYER_GOOD,TIMER0 > 50000)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,INVISIBLE,-1,3)
    SET_FLAG(PLAYER0,FLAG2,1)
ENDIF

IF(PLAYER_GOOD,TIMER0 > 51000)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY14,27,2)
ENDIF

IF(PLAYER_GOOD,TIMER0 > 62000)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY9,27,2)
ENDIF

IF(PLAYER_GOOD,TIMER0 > 75000)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY5,27,3)
ENDIF

IF(PLAYER0,SAMURAI >= 1)
    SET_FLAG(PLAYER0,FLAG2,2)
ENDIF

IF(PLAYER0,FLAG2 == 1)
    IF(PLAYER_GOOD,THIEF < 5)
        NEXT_COMMAND_REUSABLE
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,INVISIBLE,-1,1)
    ENDIF
ENDIF

IF(PLAYER0,ALL_DUNGEONS_DESTROYED == 1)
    SET_FLAG(PLAYER0,FLAG0,1)
    SET_FLAG(PLAYER0,FLAG1,1)
ENDIF

IF(PLAYER0,FLAG0 == 1)
    SET_TIMER(PLAYER_GOOD,TIMER1)
    IF(PLAYER_GOOD,TIMER1 > 100)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY1,17,1)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,PARTY2,17,9)
    ENDIF
    
    IF(PLAYER_GOOD,TIMER1 > 110)
        IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
            IF(PLAYER0,FLAG1 == 1)
                WIN_GAME
            ENDIF
        ENDIF
    ENDIF
ENDIF
