LEVEL_VERSION(1)
REM LevelVersion1 is required for FX to work with Commands
REM XXX By LordofRoses, Tale of Marlo Brum P1

REM XXXXXXXXXXXXX can do a 26th message line

REM XXX HELPS AND TIPS, at the very bottom (and places in between kek)

REM XXXXXXXXXXXXX The order the script is done is top to bottom, excluding SET lines, unless they're in an  IF
REM Game Settings 
SET_GENERATE_SPEED(400)
START_MONEY(PLAYER0,1000)
START_MONEY(PLAYER1,10000)
MAX_CREATURES(PLAYER0,10)
MAX_CREATURES(PLAYER1,20)
REM Game does not automatically end if a player wins
RUN_AFTER_VICTORY(1)
REM XXX Change rules inside the game XXX
SET_GAME_RULE(GhostConvertChance,0)
SET_GAME_RULE(PrisonSkeletonChance,0)
SET_GAME_RULE(TortureConvertChance,0)
REM Call to Arms CTA
SET_GAME_RULE(AlliesShareCta,1)
REM ImpWorkExp number should be amount of exp per task
SET_GAME_RULE(ImpWorkExperience,10)
SET_GAME_RULE(AlliesShareDrop,0)
SET_GAME_RULE(AlliesShareVision,0)

REM XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX COMPUTER AI BEGIN XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
REM XXX Second entry after "IMPRISONMENT", "0" is disabled, 1 Enabled, 2 Can only switch on, 3 can only switch off
REM "100" is how many game turns need to pass before the check is done again
REM "20" is the minimum required total prison capacity before prison is enabled
REM "1" is how many creatures the computer needs to be able to disable it
REM "100" is how many game turns before it starts checking

REM XXX Computer AI XXX, for singleplayer only otherwise the AI player won't be able to do anything
REM COMPUTER_PLAYER(PLAYER1,1)
REM SET_COMPUTER_CHECKS(PLAYER1,"COMPUTER CHECK IMPRISONMENT",100,0,20,10,100)

REM XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX COMPUTER AI END XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
REM XXX Not needed to be activated
REM DEAD_CREATURES_RETURN_TO_POOL(0)

REM XXX Removing Sacrifice Recipes
REMOVE_SACRIFICE_RECIPE(SPIDER, SPIDER, SPIDER)
REMOVE_SACRIFICE_RECIPE(IMP)
REMOVE_SACRIFICE_RECIPE(BUG, BUG)
REMOVE_SACRIFICE_RECIPE(FLY, FLY)
REMOVE_SACRIFICE_RECIPE(FLY, SPIDER)
REMOVE_SACRIFICE_RECIPE(BUG, SPIDER)
REMOVE_SACRIFICE_RECIPE(DARK_MISTRESS, BILE_DEMON, TROLL)

REM XXX Creature max levels
SET_CREATURE_MAX_LEVEL(PLAYER0,THIEF,5)
SET_CREATURE_MAX_LEVEL(PLAYER0,KNIGHT,5)
SET_CREATURE_MAX_LEVEL(PLAYER0,WITCH,5)
SET_CREATURE_MAX_LEVEL(PLAYER0,GIANT,5)
SET_CREATURE_MAX_LEVEL(PLAYER0,SAMURAI,5)
SET_CREATURE_MAX_LEVEL(PLAYER0,TUNNELLER,5)
SET_CREATURE_MAX_LEVEL(PLAYER0,DWARFA,5)
SET_CREATURE_MAX_LEVEL(PLAYER0,WIZARD,5)
SET_CREATURE_MAX_LEVEL(PLAYER0,ARCHER,5)
SET_CREATURE_MAX_LEVEL(PLAYER0,MONK,5)
SET_CREATURE_MAX_LEVEL(PLAYER0,FAIRY,5)
SET_CREATURE_MAX_LEVEL(PLAYER0,TIME_MAGE,5)

SET_CREATURE_MAX_LEVEL(PLAYER1,THIEF,5)
SET_CREATURE_MAX_LEVEL(PLAYER1,KNIGHT,5)
SET_CREATURE_MAX_LEVEL(PLAYER1,WITCH,5)
SET_CREATURE_MAX_LEVEL(PLAYER1,GIANT,5)
SET_CREATURE_MAX_LEVEL(PLAYER1,SAMURAI,5)
SET_CREATURE_MAX_LEVEL(PLAYER1,TUNNELLER,5)
SET_CREATURE_MAX_LEVEL(PLAYER1,DWARFA,5)
SET_CREATURE_MAX_LEVEL(PLAYER1,WIZARD,5)
SET_CREATURE_MAX_LEVEL(PLAYER1,ARCHER,5)
SET_CREATURE_MAX_LEVEL(PLAYER1,MONK,5)
SET_CREATURE_MAX_LEVEL(PLAYER1,FAIRY,5)
SET_CREATURE_MAX_LEVEL(PLAYER1,TIME_MAGE,5)

REM XXX Flag list -------------------------
REM PLAYER0, FLAG0
REM PLAYER1, FLAG0
REM PLAYER3, FLAG0
REM PLAYERGOOD, FLAG0, 1, 2, 3
REM END -----------------------------------
REM XXX Timer list ------------------------
REM PLAYER0, TIMER0,
REM PLAYER1
REM PLAYER3
REM PLAYERGOOD, TIMER0, 1, 2
REM END -----------------------------------

REM XXX PUNISHED or REWARDED
REM Sacrifice Recipe summons a GOOD Horny
SET_SACRIFICE_RECIPE(MkGoodHero,HORNY,MONK)
SET_SACRIFICE_RECIPE(MkGoodHero,HORNY,WIZARD)
SET_SACRIFICE_RECIPE(MkGoodHero,HORNY,BARBARIAN)
SET_SACRIFICE_RECIPE(MkGoodHero,HORNY,ARCHER)
SET_SACRIFICE_RECIPE(MkGoodHero,HORNY,DWARFA)
SET_SACRIFICE_RECIPE(MkGoodHero,HORNY,TUNNELLER)
SET_SACRIFICE_RECIPE(MkGoodHero,HORNY,WITCH)
SET_SACRIFICE_RECIPE(MkGoodHero,HORNY,GIANT)
SET_SACRIFICE_RECIPE(MkGoodHero,HORNY,FAIRY)
SET_SACRIFICE_RECIPE(MkGoodHero,HORNY,THIEF)
SET_SACRIFICE_RECIPE(MkGoodHero,HORNY,SAMURAI)
SET_SACRIFICE_RECIPE(MkGoodHero,HORNY,TIME_MAGE)

REM XXX IF maximum is 256
REM XXX in the log file you can see how many IFs you're using
REM Sacrificing any creatures creates a GOOD HORNY
IF(ALL_PLAYERS,CREATURES_SACRIFICED == 1)
  QUICK_INFORMATION(1,"Your heroes have been punished for daring to fiddle with the powers of the dark gods!")
ENDIF

REM Sacrifice 3 heroes for the avatar to arrive from the temple, ActionPoint 2
SET_SACRIFICE_RECIPE(MkCreature,AVATAR,KNIGHT,KNIGHT,KNIGHT)
IF(ALL_PLAYERS,REWARDED[AVATAR] == 1)
    QUICK_INFORMATION(2,"Knights have given their lives to summon the powerful Avatar, destroy your enemy, Hero!")
ENDIF

REM XXX Alliances and factions XXX
ALLY_PLAYERS(PLAYER0,PLAYER1,3)
ALLY_PLAYERS(PLAYER0,PLAYER3,3)
ALLY_PLAYERS(PLAYER1,PLAYER3,3)
ALLY_PLAYERS(PLAYER_GOOD,PLAYER2,3)
REM Player0 is The Lord, Player1 is the Princess and Defenders
REM Player2 is the Traitor Lord, Player3 are the Civilians

REM XXX Note Entrance is Portal and Library is RESEARCH
REM XXX Garden is Hatchery

REM XXX MakerFullMapVision whilst developing
REM XXX Command is: REVEAL_MAP_RECT, conceal map with CONCEAL_MAP_RECT([player, [x], [y], [width], [height], [hide revealed*])

REM XXX Objective XXX
REM Action Point 1, traitor Lord's prison
QUICK_OBJECTIVE(3,"This location of your kin has been delivered to your enemies by a treacherous lord. Do not allow the prisoner to be freed, nor should you end his life yet. Have caution Heroes, I will bring further news!",1)
REM QUICK_INFORMATION(9,"Do not allow the Knight to escape, and it is not yet time to end his treacherous life!")
REM Shows the location of Action Point 1 at a radius of 3 squares
REVEAL_MAP_LOCATION(ALL_PLAYERS,1, 3)

REM XXX Creature Starts Available XXX
REM XX Last digit represents 1 = skip attraction requirements
CREATURE_AVAILABLE(PLAYER1,TUNNELLER,1,20)
CREATURE_AVAILABLE(ALL_PLAYERS,DWARFA,1,15)
CREATURE_AVAILABLE(PLAYER1,ARCHER,1,6)
CREATURE_AVAILABLE(PLAYER1,THIEF,1,0)

REM XXX Creatures in total pool XXX
REM XX Slain creatures go back into the creature pool
ADD_CREATURE_TO_POOL(WIZARD,1)
ADD_CREATURE_TO_POOL(BARBARIAN,0)
ADD_CREATURE_TO_POOL(ARCHER,6)
ADD_CREATURE_TO_POOL(MONK,2)
ADD_CREATURE_TO_POOL(DWARFA,15)
ADD_CREATURE_TO_POOL(TUNNELLER,20)
ADD_CREATURE_TO_POOL(GIANT,2)
ADD_CREATURE_TO_POOL(FAIRY,2)
ADD_CREATURE_TO_POOL(THIEF,15)
ADD_CREATURE_TO_POOL(TIME_MAGE,-2)

REM XXX Creature Starts Unavailable XXX
CREATURE_AVAILABLE(PLAYER1,WIZARD,0,0)
CREATURE_AVAILABLE(PLAYER1,BARBARIAN,0,0)
CREATURE_AVAILABLE(PLAYER1,MONK,0,0)
CREATURE_AVAILABLE(PLAYER1,DWARFA,0,15)
CREATURE_AVAILABLE(PLAYER1,GIANT,0,2)
CREATURE_AVAILABLE(PLAYER1,FAIRY,0,2)
CREATURE_AVAILABLE(PLAYER1,TIME_MAGE,0,0)

REM XXX Rooms mention on the fandom what creatures they attract
REM XXX Rooms Unavailable XXX
ROOM_AVAILABLE(ALL_PLAYERS,BRIDGE,0,0)
ROOM_AVAILABLE(ALL_PLAYERS,GUARD_POST,0,0)
ROOM_AVAILABLE(ALL_PLAYERS,TEMPLE,0,0)
ROOM_AVAILABLE(ALL_PLAYERS,GRAVEYARD,0,0)
ROOM_AVAILABLE(ALL_PLAYERS,SCAVENGER,0,0)
ROOM_AVAILABLE(ALL_PLAYERS,TREASURE,0,0)
ROOM_AVAILABLE(ALL_PLAYERS,LAIR,0,0)
ROOM_AVAILABLE(PLAYER1,GARDEN,0,0)
ROOM_AVAILABLE(PLAYER1,BARRACKS,0,0)
ROOM_AVAILABLE(PLAYER1,TRAINING,0,0)
ROOM_AVAILABLE(PLAYER1,PRISON,0,0)

REM XXX Rooms Researchable XXX
ROOM_AVAILABLE(ALL_PLAYERS,TORTURE,1,0)
ROOM_AVAILABLE(PLAYER0,TRAINING,1,0)
ROOM_AVAILABLE(PLAYER0,PRISON,1,0)
ROOM_AVAILABLE(PLAYER0,BARRACKS,1,0)
ROOM_AVAILABLE(PLAYER0,GARDEN,1,0)
ROOM_AVAILABLE(PLAYER1,RESEARCH,1,0)
ROOM_AVAILABLE(PLAYER1,WORKSHOP,1,0)

REM XXX Rooms Starts Available XXX
ROOM_AVAILABLE(PLAYER0,RESEARCH,1,1)

REM XXX Spells Unavailable XXX
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_DISEASE,0,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_ARMAGEDDON,0,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_DESTROY_WALLS,0,0)
MAGIC_AVAILABLE(PLAYER0,POWER_SLAP,0,0)
MAGIC_AVAILABLE(PLAYER1,POWER_SLAP,0,0)
MAGIC_AVAILABLE(PLAYER0,POWER_IMP,0,0)
MAGIC_AVAILABLE(PLAYER1,POWER_IMP,0,0)
MAGIC_AVAILABLE(PLAYER0,POWER_CONCEAL,0,0)
MAGIC_AVAILABLE(PLAYER1,POWER_CONCEAL,0,0)
MAGIC_AVAILABLE(PLAYER0,POWER_HOLD_AUDIENCE,0,0)
MAGIC_AVAILABLE(PLAYER0,POWER_CAVE_IN,0,0)
MAGIC_AVAILABLE(PLAYER0,POWER_LIGHTNING,0,0)
MAGIC_AVAILABLE(PLAYER0,POWER_CHICKEN,0,0)

REM XXX Spells Researchable XXX
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_HEAL_CREATURE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_PROTECT,1,0)
MAGIC_AVAILABLE(PLAYER1,POWER_CHICKEN,1,0)
MAGIC_AVAILABLE(PLAYER1,POWER_HOLD_AUDIENCE,1,0)
MAGIC_AVAILABLE(PLAYER1,POWER_CAVE_IN,1,0)
MAGIC_AVAILABLE(PLAYER1,POWER_LIGHTNING,1,0)

REM XXX Spells Starts Available XXX
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HAND,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_POSSESS,1,1)

REM XXX Traps Unavailable XXX
TRAP_AVAILABLE(ALL_PLAYERS,LIGHTNING,0,0)
TRAP_AVAILABLE(ALL_PLAYERS,LAVA,0,0)
TRAP_AVAILABLE(ALL_PLAYERS,BOULDER,0,0)
TRAP_AVAILABLE(ALL_PLAYERS,WORD_OF_POWER,0,0)
DOOR_AVAILABLE(PLAYER0,MAGIC,0,0)
DOOR_AVAILABLE(PLAYER0,STEEL,0,0)

REM XXX Traps Researchable XXX
TRAP_AVAILABLE(ALL_PLAYERS,POISON_GAS,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,BRACED,1,0)
TRAP_AVAILABLE(PLAYER0,ALARM,1,0) 
DOOR_AVAILABLE(PLAYER0,WOOD,1,0)
DOOR_AVAILABLE(PLAYER1,STEEL,1,0)

REM XXX Traps Starts Available XXX
TRAP_AVAILABLE(PLAYER1,ALARM,1,1)
DOOR_AVAILABLE(PLAYER1,WOOD,1,1)

REM Both players have researched SIGHT, they both get vision over each others dungeons
IF_AVAILABLE(PLAYER0,POWER_SIGHT > 0)
  IF_AVAILABLE(PLAYER1,POWER_SIGHT > 0)
    QUICK_OBJECTIVE(9,"Heroes, you have sight over your allies due to your shared powers of Power Sight!.")
    SET_GAME_RULE(AlliesShareVision,1)
  ENDIF
ENDIF

REM XXX  == = means equal to ("=" singular isn't used in DK script), > = Greater, < = Less, >= Greater or equal
REM XXX != Not equal to

REM XXX PLAYER0 has 0 Tunnellers remaining
REM DO NOT use ALL_PLAYERS for timers or flags, it may mess the player(specific) ones up! .. Unless they all want to be intentionally increased/decreased/changed
REM Hero Gate -6 at Player0 base
SET_TIMER(PLAYER0,TIMER0)
IF(PLAYER0,TIMER0 == 1500)
    QUICK_INFORMATION(4,"The maximum level of your Heroes is level 5, you cannot become a legendary hero during your first battle!")
    IF(PLAYER0,TUNNELLER <= 4)
	    NEXT_COMMAND_REUSABLE
        ADD_CREATURE_TO_LEVEL(PLAYER0,TUNNELLER,-6,4,1,0)
    ENDIF
    REM Hero Gate -7 at Player1 base
    IF(PLAYER1,TUNNELLER<= 4)
	NEXT_COMMAND_REUSABLE
    ADD_CREATURE_TO_LEVEL(PLAYER1,TUNNELLER,-7,4,1,0)
    ENDIF
    ADD_TO_TIMER(PLAYER0,TIMER0,-2400)
ENDIF

REM IF Room, the required number is equal to slabs rather than whole rooms.
REM Availability on capture
IF(PLAYER1,LAIR > 30)
    ROOM_AVAILABLE(PLAYER1,LAIR,1,1)
    QUICK_INFORMATION(5,"The Princess's forces have found the means to expand their Lair!")
ENDIF

REM flag is how many tiered upgrades players get for spawns from further down.
SET_FLAG(PLAYER0,FLAG0,0)
IF(PLAYER_GOOD,HORNY == 0)
    ROOM_AVAILABLE(ALL_PLAYERS,TREASURE,1,1)
    CREATURE_AVAILABLE(PLAYER1,MONK,1,1)
    ADD_CREATURE_TO_LEVEL(PLAYER1,MONK,-7,1,5,0)
    ADD_CREATURE_TO_LEVEL(PLAYER0,MONK,-6,1,5,0)
    ADD_TO_FLAG(PLAYER0,FLAG0,1)
    QUICK_INFORMATION(6,"With the destruction of Horny, you are able to create Treasuries, and Monks have come to your sanctuary, Heroes!")
ENDIF

IF(PLAYER0,RESEARCH == 9)     
    CREATURE_AVAILABLE(ALL_PLAYERS,WIZARD,1,0)
    ADD_CREATURE_TO_LEVEL(PLAYER0,WIZARD,-6,1,1,0)
    QUICK_INFORMATION(22,"Wizards are prepared to come to your Sanctuary, Heroes!")
ENDIF

REM Player0 takes the colour just below blue's door will then naturally unlock the door.
IF_SLAB_OWNER(40,65,PLAYER0)    
SET_DOOR(UNLOCKED,40,64)
ENDIF
REM XXX playernumber and Flagnumber must always be assigned to their respective number and potential timer
REM Yellow creep spawns when they run out of dudes. Positions 3 to 6
SET_TIMER(PLAYER3,TIMER1)

IF(PLAYER1,WITCH > 0)    
    IF(PLAYER3,TIMER1 == 6000)
        IF(PLAYER3,TOTAL_CREATURES == 0)
	        NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,THIEF,3,1,1,0)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,MONK,3,1,1,0)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,BARBARIAN,3,1,1,0)

            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,THIEF,4,1,1,0)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,THIEF,4,1,1,0)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,ARCHER,4,1,1,0)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,ARCHER,4,1,1,0)

            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,THIEF,5,1,1,0)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,THIEF,5,1,1,0)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,THIEF,5,1,1,0)

            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,GIANT,5,1,1,0)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,DWARFA,5,1,1,0)
            NEXT_COMMAND_REUSABLE
            ADD_CREATURE_TO_LEVEL(PLAYER3,DWARFA,5,1,1,0)
            IF(PLAYER3,TIMER1 >= 21000)
                QUICK_INFORMATION(7,"Civilians are being slaughtered by the droves, when will you end this, heroes!")
                NEXT_COMMAND_REUSABLE
                ADD_TO_TIMER(PLAYER3,TIMER1,-6000)
            ENDIF
        ENDIF
    ENDIF
ENDIF

IF(PLAYER1,WITCH == 0)   
    QUICK_INFORMATION(11,"The princess has been badly injured, any remaining civilians will be fleeing believing that they cannot be protected!")
ENDIF
IF(PLAYER0,KNIGHT == 0)   
    QUICK_INFORMATION(16,"Sir Marlo Brum has been gravely injured!")
ENDIF
    
REM XXX == "0" up to "6" on how many Lairs have been lost, the 6 being met stops Lair uglies
REM XXX Player, Flagname, Flag'sNumber
REM Flag0 is to stop Lair spawnings when taken
REM 6 = GOOD lair amount

REM 36 lair tiles
SET_FLAG(PLAYER_GOOD,FLAG0,0)
IF(PLAYER_GOOD,FLAG0 == 1)
    IF(PLAYER_GOOD,LAIR <= 30)
        ADD_TO_FLAG(PLAYER_GOOD,FLAG0,1)
        QUICK_INFORMATION(8,"Well done heroes, you have beridden one of their monster lairs!")
    ENDIF
ENDIF

IF(PLAYER_GOOD,FLAG0 == 2)
    IF(PLAYER_GOOD,LAIR == 24)
        ADD_TO_FLAG(PLAYER_GOOD,FLAG0,1)
        QUICK_INFORMATION(26,"Two lairs have been destroyed, there are reports of at least four more remaining!")
    ENDIF
ENDIF
 
IF(PLAYER_GOOD,FLAG0 == 3)
    IF(PLAYER_GOOD,LAIR == 18)
        ADD_TO_FLAG(PLAYER_GOOD,FLAG0,1)
        QUICK_INFORMATION(39,"Three monstrous lairs have been destroyed!")
    ENDIF
ENDIF

IF(PLAYER_GOOD,FLAG0 == 4)
    IF(PLAYER_GOOD,LAIR == 12)
        ADD_TO_FLAG(PLAYER_GOOD,FLAG0,1)
        QUICK_INFORMATION(40,"A fourth lair has been claimed!")
    ENDIF
ENDIF

IF(PLAYER_GOOD,FLAG0 == 5)
    IF(PLAYER_GOOD,LAIR == 6)
        ADD_TO_FLAG(PLAYER_GOOD,FLAG0,1)
        QUICK_INFORMATION(41,"A fifth lair has been claimed, one more to go Heroes!")
    ENDIF
ENDIF

IF(PLAYER_GOOD,FLAG0 == 6)
    IF(PLAYER_GOOD,LAIR == 0)
        ADD_TO_FLAG(PLAYER_GOOD,FLAG0,1)
        ADD_TO_FLAG(PLAYER0,FLAG0,1)
        QUICK_INFORMATION(42,"You have claimed the monsters Lairs, their attacks have been stopped!")
    ENDIF
ENDIF
REM After 45 minutes of existing, the players get an extra flag to their creature pool
IF(PLAYER0,GAME_TURN >= 54000)    
    ADD_TO_FLAG(PLAYER0,FLAG0,1)
ENDIF

REM POOL UPGRADE players
REM +1 Lair destruction, +1 surviving Timer0, killing Horny, traitor Knight escaping, time elapsed
IF(PLAYER0,FLAG0 == 1) 
    MAX_CREATURES(PLAYER0,15)
    MAX_CREATURES(PLAYER1,20) 
    QUICK_INFORMATION(27,"Additional Heroes are arriving to aid you Heroes, you have 5 additional objectives Heroes!")
ENDIF
IF(PLAYER0,FLAG0 == 2) 
    MAX_CREATURES(PLAYER0,16)
    MAX_CREATURES(PLAYER1,22) 
    CREATURE_ENTRANCE_LEVEL (PLAYER0,2)
    QUICK_INFORMATION(28,"Your power is being slowly bolstered Heroes, only four more objectives remaining!")
ENDIF
IF(PLAYER0,FLAG0 == 3) 
    MAX_CREATURES(PLAYER0,17)
    MAX_CREATURES(PLAYER1,24)
    CREATURE_ENTRANCE_LEVEL (PLAYER0,3) 
    QUICK_INFORMATION(29,"The tide is turning, Heroes will berid this field soon, I can feel it!")
ENDIF
IF(PLAYER0,FLAG0 == 4) 
    MAX_CREATURES(PLAYER0,18)
    MAX_CREATURES(PLAYER1,26) 
    CREATURE_ENTRANCE_LEVEL (PLAYER0,4) 
    QUICK_INFORMATION(30,"Despite the grevious mayhem that has fallen upon these waters... The day will soon be yours heroes, only two more objectives remaining!")
ENDIF
IF(PLAYER0,FLAG0 == 5) 
    MAX_CREATURES(PLAYER0,19)
    MAX_CREATURES(PLAYER1,28) 
    CREATURE_ENTRANCE_LEVEL (PLAYER1,2)
    CREATURE_ENTRANCE_LEVEL (PLAYER0,5) 
    QUICK_INFORMATION(31,"Your heroes are swelling with power heroes, it is only a matter of time, one last objective to seize the day!")
ENDIF
IF(PLAYER0,FLAG0 == 6) 
    MAX_CREATURES(PLAYER0,20)
    MAX_CREATURES(PLAYER1,30) 
    ADD_CREATURE_TO_LEVEL(PLAYER1,SAMURAI,-7,1,5,0)
    QUICK_INFORMATION(32,"The final threshold, you have completed all of your objectives... Now, destroy the traitor and their disgusting minions!")
ENDIF
REM XXX PLAYER, Timername
REM Timer0 is made to spawn parties

REM START OF INVASIONS-------------------------------------------------------------------------------------------------------------------

REM XXX Arrival party creation tables
REM XXX All creatures within party "PARTYNAME", note "Attack_Dungeon_Heart" refers to the strongest player within reach
REM XXX Party limit has been increased to 30 despite the script guide
REM XXX Partyname, Creaturename, Experience, Gold, Objective, Countdown (how long until the leader of the party goes to the objective)

Rem XXX command: delete_from_party
REM ActionPoint8
CREATE_PARTY(Flies)

ADD_TO_PARTY(Flies,	FLY,		1,		0,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies,	FLY,		1,		0,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies,	FLY,		1,		0,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies,	FLY,		1,		0,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies,	FLY,		1,		0,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies,	FLY,		1,		0,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies,	FLY,		1,		0,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies,	FLY,		1,		0,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies,	FLY,		1,		0,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies,	FLY,		1,		0,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies,	FLY,		1,		0,		ATTACK_ENEMIES,	0)

CREATE_PARTY(Flies2)

ADD_TO_PARTY(Flies2,	FLY,		2,		20,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies2,	FLY,		2,		20,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies2,	FLY,		2,		20,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies2,	FLY,		2,		20,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies2,	FLY,		2,		20,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies2,	FLY,		2,		20,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies2,	FLY,		2,		20,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies2,	FLY,		2,		20,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies2,	FLY,		2,		20,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies2,	FLY,		2,		20,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies2,	FLY,		2,		20,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies2,	FLY,		2,		20,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies2,	FLY,		3,		20,		ATTACK_ENEMIES,	0)

CREATE_PARTY(Flies3)

ADD_TO_PARTY(Flies3,	FLY,		3,		20,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies3,	FLY,		3,		20,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies3,	FLY,		3,		20,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies3,	FLY,		3,		20,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies3,	FLY,		3,		20,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies3,	FLY,		3,		20,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies3,	FLY,		4,		30,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies3,	FLY,		4,		30,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies3,	FLY,		4,		30,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies3,	FLY,		4,		30,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies3,	FLY,		4,		30,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies3,	FLY,		4,		30,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(Flies3,	FLY,		5,		30,		ATTACK_ENEMIES,	0)

REM Flies party comes
IF(PLAYER_GOOD,LAIR > 0)    
    IF(PLAYER_GOOD,GAME_TURN == 6000) 
        IF(PLAYER_GOOD,FLAG0 < 6)
        SET_TIMER(PLAYER_GOOD,TIMER2) 
        ADD_TO_PARTY(Flies,IMP,5,0,ATTACK_DUNGEON_HEART,0)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Flies,8,1)
        ENDIF
    ENDIF
    IF(PLAYER_GOOD,TIMER2 == 10000)
        DELETE_FROM_PARTY(Flies,IMP,5)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Flies,8,1)
    ENDIF
    IF(PLAYER_GOOD,TIMER2 == 15000)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Flies,8,1)
    ENDIF
    IF(PLAYER_GOOD,TIMER2 == 18000)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Flies,8,1)
    ENDIF
    IF(PLAYER_GOOD,FLAG0 < 1)
        IF(PLAYER_GOOD,TIMER2 == 21000)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Flies2,8,1)
        ENDIF
    ENDIF
    IF(PLAYER_GOOD,FLAG0 < 2)
        IF(PLAYER_GOOD,TIMER2 == 25000)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Flies2,8,1)
        ENDIF
    ENDIF
    IF(PLAYER_GOOD,FLAG0 < 4)
        IF(PLAYER_GOOD,TIMER2 == 30000)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Flies2,8,1)
        ENDIF
    ENDIF
    IF(PLAYER_GOOD,FLAG0 < 5)
        IF(PLAYER_GOOD,TIMER2 == 35000)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Flies2,8,1)
        ENDIF
    ENDIF
    REM ">=" for the ending timer because "==" can be skipped sometimes
    IF(PLAYER_GOOD,FLAG0 < 6)
        IF(PLAYER_GOOD,TIMER2 >= 40000)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Flies3,8,1)
            NEXT_COMMAND_REUSABLE
            ADD_TO_TIMER(PLAYER_GOOD,TIMER2,-20000)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER_GOOD,FLAG0 == 1)

Endif

REM Actionpoint 8
CREATE_PARTY(Trolls)

ADD_TO_PARTY(Trolls,	TROLL,		1,		20,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(Trolls,	TROLL,		1,		20,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(Trolls,	TROLL,		1,		20,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(Trolls,	TROLL,		1,		20,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(Trolls,	TROLL,		1,		20,		ATTACK_ROOMS,	0)

CREATE_PARTY(Trolls2)

ADD_TO_PARTY(Trolls2,	TROLL,		1,		20,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(Trolls2,	TROLL,		1,		20,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(Trolls2,	TROLL,		1,		20,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(Trolls2,	TROLL,		1,		20,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(Trolls2,	TROLL,		2,		30,		ATTACK_ROOMS,	0)


CREATE_PARTY(Trolls3)

ADD_TO_PARTY(Trolls3,	TROLL,		2,		30,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(Trolls3,	TROLL,		2,		30,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(Trolls3,	TROLL,		2,		30,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(Trolls3,	TROLL,		2,		30,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(Trolls3,	TROLL,		3,		40,		ATTACK_ROOMS,	0)


REM Trolls party comes
IF(PLAYER_GOOD,LAIR > 0)    
    IF(PLAYER_GOOD,GAME_TURN == 10000) 
        SET_TIMER(PLAYER_GOOD,TIMER2) 
        ADD_TO_PARTY(Trolls,IMP,5,0,ATTACK_DUNGEON_HEART,10)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Trolls,10,1)
    ENDIF
    IF(PLAYER_GOOD,TIMER2 == 10000)
        DELETE_FROM_PARTY(Trolls,IMP,5)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Trolls,10,1)
        QUICK_INFORMATION(34,"Both Hero player pools increase as objectives are completed. Additionally, Tunnellers will find themselves to you if you should run out")
    ENDIF
    IF(PLAYER_GOOD,TIMER2 == 20000)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Trolls,10,1)
    ENDIF
    IF(PLAYER_GOOD,TIMER2 == 24000)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Trolls,10,1)
    ENDIF
    IF(PLAYER_GOOD,FLAG0 < 2)
        IF(PLAYER_GOOD,TIMER2 == 28000)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Trolls2,10,1)
        ENDIF
    ENDIF
    IF(PLAYER_GOOD,FLAG0 < 3)
        IF(PLAYER_GOOD,TIMER2 == 32000)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Trolls2,10,1)
        ENDIF
    ENDIF
    IF(PLAYER_GOOD,FLAG0 < 4)
        IF(PLAYER_GOOD,TIMER2 == 36000)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Trolls2,10,1)
        ENDIF
    ENDIF
    IF(PLAYER_GOOD,FLAG0 < 5)
        IF(PLAYER_GOOD,TIMER2 == 40000)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Trolls3,10,1)
        ENDIF
    ENDIF
    IF(PLAYER_GOOD,FLAG0 < 6)
        IF(PLAYER_GOOD,TIMER2 >= 44000)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,Trolls3,10,1)
            NEXT_COMMAND_REUSABLE
            REM timer resets just before Timer2
            ADD_TO_TIMER(PLAYER_GOOD,TIMER2,-19950)
            QUICK_INFORMATION(10,"The monsters attacks will be relentless unless you claim their Lairs, Heroes!")
        ENDIF
    ENDIF
ENDIF
REM ActionPoint7
CREATE_PARTY(MAINATTACKERS)

ADD_TO_PARTY(MAINATTACKERS,	BUG,		1,		0,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERS,	BUG,		1,		0,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERS,	BUG,		1,		0,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERS,	BUG,		1,		0,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERS,	BUG,		1,		0,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERS,	BUG,		1,		0,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERS,	BUG,		1,		0,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERS,	SPIDER,		1,		0,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERS,	SPIDER,		1,		0,		ATTACK_DUNGEON_HEART,	0)

CREATE_PARTY(MAINATTACKERSL2)

ADD_TO_PARTY(MAINATTACKERSL2,	BUG,		2,		20,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL2,	BUG,		2,		20,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL2,	BUG,		2,		20,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL2,	BUG,		2,		20,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL2,	BUG,		2,		20,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL2,	BUG,		2,		20,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL2,	BUG,		2,		20,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL2,	BUG,		2,		20,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL2,	SPIDER,		2,		20,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL2,	SPIDER,		2,		20,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL2,	SPIDER,		2,		20,		ATTACK_DUNGEON_HEART,	0)

CREATE_PARTY(MAINATTACKERSL34)

ADD_TO_PARTY(MAINATTACKERSL34,	BUG,		3,		30,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL34,	BUG,		3,		30,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL34,	BUG,		3,		30,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL34,	BUG,		3,		30,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL34,	BUG,		3,		30,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL34,	BUG,		3,		30,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL34,	SPIDER,		3,		50,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL34,	SPIDER,		3,		50,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL34,	SPIDER,		3,		50,		ATTACK_DUNGEON_HEART,	0)
ADD_TO_PARTY(MAINATTACKERSL34,	SPIDER,		4,		50,		ATTACK_DUNGEON_HEART,	0)


REM XXX 1200 turns are the equivalent of 1 real minute, 20 turns = 1 second.
REM XX Player, Partyname, ActionPoint/HeroDoor/, number of party copies
REM NEXT_COMMAND_REUSABLE

REM XXX ADD_TO_TIMER can be used with negative numbers to drop TIMERS.
REM 5 Minutes after the start of the game a Party spawns
REM Actionpoint 7 is in open water mid north of blue  
IF(PLAYER_GOOD,LAIR > 0)    
    IF(PLAYER_GOOD,GAME_TURN == 6000)    
         ADD_PARTY_TO_LEVEL(PLAYER_GOOD,MAINATTACKERS,7,1)
         SET_TIMER(PLAYER_GOOD,TIMER0)
         QUICK_INFORMATION(35,"Be careful Heroes, the monsters are coming!")
    ENDIF
        REM XXX TIMER is still done in game turns
    IF(PLAYER_GOOD,FLAG0 < 1)
        IF(PLAYER_GOOD,TIMER0 == 6000)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,MAINATTACKERS,7,2)
        ENDIF
    ENDIF
    IF(PLAYER_GOOD,FLAG0 < 2)
        IF(PLAYER_GOOD,TIMER0 == 10000)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,MAINATTACKERSL2,7,1)
            QUICK_INFORMATION(38,"Word is, there is a Dungeon Heart to your north west, Heroes!")
        ENDIF
    ENDIF

    SET_TIMER(PLAYER0,TIMER1)
    IF(PLAYER_GOOD,FLAG0 < 3)
        IF(PLAYER0,TIMER1 == 18000)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,MAINATTACKERSL2,7,2)
        ENDIF
    ENDIF
    IF(PLAYER_GOOD,FLAG0 < 4)
        IF(PLAYER0,TIMER1 == 24000)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,MAINATTACKERSL34,7,1)
        ENDIF
    ENDIF
    REM 15 minutes equivalent (18000)
    IF(PLAYER_GOOD,FLAG0 < 5)
        IF(PLAYER0,TIMER1 == 24000)
            ROOM_AVAILABLE(PLAYER1,BRIDGE,1,1)
            QUICK_INFORMATION(36,"The Princess has gained the technology to create a bridge!")
        ENDIF
    ENDIF
    REM Minustimer = just after first timer0
    IF(PLAYER_GOOD,FLAG0 < 6)
        IF(PLAYER0,TIMER1 >= 28000)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,MAINATTACKERSL34,7,2)
            NEXT_COMMAND_REUSABLE
            ADD_TO_TIMER(PLAYER0,TIMER1,-21900)
            CREATURE_AVAILABLE(PLAYER1,GIANT,1,1)
            CREATURE_AVAILABLE(PLAYER1,FAIRY,1,0)
            CREATURE_AVAILABLE(PLAYER0,GIANT,1,1)
            CREATURE_AVAILABLE(PLAYER0,FAIRY,1,0)
            ADD_CREATURE_TO_LEVEL(PLAYER0,GIANT,-7,1,2,0)
            ADD_CREATURE_TO_LEVEL(PLAYER1,GIANT,-6,1,2,0)
            ADD_CREATURE_TO_LEVEL(PLAYER1,FAIRY,-6,1,4,0)
            ADD_CREATURE_TO_LEVEL(PLAYER0,FAIRY,-7,1,4,0)
            ADD_TO_FLAG(PLAYER0,FLAG0,1)
            QUICK_INFORMATION(23,"Fairies, Giants and reinforcements have come to aid you Heroes, with that to the access of a Workshop!")
            ROOM_AVAILABLE(PLAYER0,WORKSHOP,1,1)
            ADD_CREATURE_TO_LEVEL(PLAYER0,DWARFA,-7,1,4,0)
            ADD_CREATURE_TO_LEVEL(PLAYER1,DWARFA,-6,1,4,0)
            ADD_CREATURE_TO_LEVEL(PLAYER0,DWARFA,-7,1,4,0)
            ADD_CREATURE_TO_LEVEL(PLAYER1,DWARFA,-6,1,4,0)
            ADD_CREATURE_TO_LEVEL(PLAYER0,DWARFA,-7,1,4,0)
            ADD_CREATURE_TO_LEVEL(PLAYER1,DWARFA,-6,1,4,0)
        ENDIF
    ENDIF
ENDIF

REM Actionpoint 9
CREATE_PARTY(TRAITORS)

ADD_TO_PARTY(TRAITORS,	ARCHER,		3,		50,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(TRAITORS,	ARCHER,		3,		50,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(TRAITORS,	ARCHER,		3,		50,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(TRAITORS,	THIEF,		3,		50,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(TRAITORS,	THIEF,		3,		50,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(TRAITORS,	THIEF,		4,		100,		STEAL_GOLD,	0)

CREATE_PARTY(TRAITORS2)

ADD_TO_PARTY(TRAITORS2,	ARCHER,		3,		50,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(TRAITORS2,	ARCHER,		3,		50,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(TRAITORS2,	THIEF,		3,		50,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(TRAITORS2,	THIEF,		3,		50,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(TRAITORS2,	THIEF,		4,		100,		STEAL_GOLD,	0)

CREATE_PARTY(TRAITORS3)

ADD_TO_PARTY(TRAITORS3,	ARCHER,		6,		50,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(TRAITORS3,	ARCHER,		5,		50,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(TRAITORS3,	THIEF,		5,		50,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(TRAITORS3,	THIEF,		5,		50,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(TRAITORS3,	THIEF,		5,		100,		STEAL_GOLD,	0)

CREATE_PARTY(TRAITORS4)

ADD_TO_PARTY(TRAITORS4,	ARCHER,		6,		100,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(TRAITORS4,	ARCHER,		5,		100,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(TRAITORS4,	THIEF,		5,		80,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(TRAITORS4,	THIEF,		5,		80,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(TRAITORS4,	BARBARIAN,		5,		200,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(TRAITORS4,	THIEF,		6,		100,		STEAL_GOLD,	0)

CREATE_PARTY(TRAITORS5)

ADD_TO_PARTY(TRAITORS5,	ARCHER,		7,		100,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(TRAITORS5,	ARCHER,		6,		100,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(TRAITORS5,	THIEF,		6,		80,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(TRAITORS5,	THIEF,		5,		80,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(TRAITORS5,	BARBARIAN,		6,		250,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(TRAITORS5,	BARBARIAN,		5,		200,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(TRAITORS5,	BARBARIAN,		5,		200,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(TRAITORS5,	THIEF,		7,		100,		STEAL_GOLD,	0)

CREATE_PARTY(TRAITORS6)

ADD_TO_PARTY(TRAITORS6,	ARCHER,		8,		250,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(TRAITORS6,	ARCHER,		8,		250,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(TRAITORS6,	WIZARD,		9,		350,		ATTACK_ENEMIES,	0)
ADD_TO_PARTY(TRAITORS6,	BARBARIAN,		8,		300,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(TRAITORS6,	BARBARIAN,		7,		250,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(TRAITORS6,	BARBARIAN,		7,		250,		ATTACK_ROOMS,	0)
ADD_TO_PARTY(TRAITORS6,	THIEF,		9,		300,		STEAL_GOLD,	0)
ADD_TO_PARTY(TRAITORS6,	THIEF,		9,		300,		STEAL_GOLD,	0)
ADD_TO_PARTY(TRAITORS6,	THIEF,		9,		300,		STEAL_GOLD,	0)

REM Traitor party comes
IF(PLAYER_GOOD,KNIGHT > 0) 
    IF(PLAYER_GOOD,GAME_TURN == 12000) 
        SET_TIMER(PLAYER_GOOD,TIMER2) 
        ADD_TO_PARTY(TRAITORS,IMP,9,0,ATTACK_DUNGEON_HEART,10)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TRAITORS,9,1)
        QUICK_INFORMATION(37,"Traitors have come to free their liege, stop them Heroes!")
    ENDIF
    IF(PLAYER_GOOD,TIMER2 == 17000)
        DELETE_FROM_PARTY(TRAITORS,IMP,9)
        NEXT_COMMAND_REUSABLE
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TRAITORS,9,2)
    ENDIF
    IF(PLAYER_GOOD,TIMER2 == 23000)
        NEXT_COMMAND_REUSABLE
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TRAITORS2,9,1)
    ENDIF
    IF(PLAYER_GOOD,TIMER2 == 29000)
        NEXT_COMMAND_REUSABLE
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TRAITORS2,9,2)
    ENDIF
    IF(PLAYER_GOOD,TIMER2 == 33000)
        NEXT_COMMAND_REUSABLE
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TRAITORS3,9,1)
    ENDIF
    IF(PLAYER_GOOD,TIMER2 == 36000)
        NEXT_COMMAND_REUSABLE
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TRAITORS3,9,1)
    ENDIF
    IF(PLAYER_GOOD,TIMER2 == 39000)
        NEXT_COMMAND_REUSABLE
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TRAITORS4,9,1)
        QUICK_INFORMATION(25,"There is a temple to the mid-north, a creature lays within, take it and banish these dark gods, Heroes!")
    ENDIF
    IF(PLAYER_GOOD,TIMER2 == 42000)
        NEXT_COMMAND_REUSABLE
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TRAITORS5,9,1)
    ENDIF
    IF(PLAYER_GOOD,TIMER2 >= 47000)
        NEXT_COMMAND_REUSABLE
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TRAITORS6,9,1)
        NEXT_COMMAND_REUSABLE
        ADD_TO_TIMER(PLAYER_GOOD,TIMER2,-10900)
        ROOM_AVAILABLE(PLAYER1,BARRACKS,1,0)
        ADD_CREATURE_TO_LEVEL(PLAYER0,BARBARIAN,-6,2,5,0)
        ADD_CREATURE_TO_LEVEL(PLAYER1,BARBARIAN,-7,2,5,0)
        CHANGE_SLAB_TYPE(40,47,PATH)
        CHANGE_SLAB_TYPE(41,47,PATH)
        CHANGE_SLAB_TYPE(40,48,PATH)
        CHANGE_SLAB_TYPE(41,49,PATH)
        CHANGE_SLAB_TYPE(40,49,PATH)
        QUICK_INFORMATION(12,"The Princess has received the means to create a Barracks, and with it two Barbarians have arrived to aid your cause!")
    ENDIF
ENDIF

CREATE_PARTY(LordsEscape)

ADD_TO_PARTY(LordsEscape,SPIDER,9,400,ATTACK_DUNGEON_HEART,40)
ADD_TO_PARTY(LordsEscape,SPIDER,9,400,ATTACK_DUNGEON_HEART,40)
ADD_TO_PARTY(LordsEscape,TROLL,9,400,ATTACK_DUNGEON_HEART,40)
ADD_TO_PARTY(LordsEscape,TROLL,9,400,ATTACK_DUNGEON_HEART,40)
ADD_TO_PARTY(LordsEscape,TROLL,7,300,ATTACK_DUNGEON_HEART,40)
ADD_TO_PARTY(LordsEscape,TROLL,7,300,ATTACK_DUNGEON_HEART,40)
ADD_TO_PARTY(LordsEscape,TROLL,7,300,ATTACK_DUNGEON_HEART,40)
ADD_TO_PARTY(LordsEscape,TROLL,7,300,ATTACK_DUNGEON_HEART,40)
ADD_TO_PARTY(LordsEscape,DARK_MISTRESS,9,400,ATTACK_DUNGEON_HEART,40)
ADD_TO_PARTY(LordsEscape,BUG,7,200,ATTACK_DUNGEON_HEART,40)
ADD_TO_PARTY(LordsEscape,BUG,7,200,ATTACK_DUNGEON_HEART,40)
ADD_TO_PARTY(LordsEscape,BUG,7,200,ATTACK_DUNGEON_HEART,40)
ADD_TO_PARTY(LordsEscape,BUG,7,200,ATTACK_DUNGEON_HEART,40)
ADD_TO_PARTY(LordsEscape,BUG,7,200,ATTACK_DUNGEON_HEART,40)
ADD_TO_PARTY(LordsEscape,BUG,7,200,ATTACK_DUNGEON_HEART,40)

REM TIMER spawns max's at 80000 (1Hour and a bit)
REM END OF INVASIONS -------------------------------------------------------------------------------------------------------------------
REM KNIGHT AND MAGE BETRAYAL AND ESCAPE -----------------------------------------------------------------------------------

REM Time Mage betrayal, if Player1 doesn't have the Time Mage
SET_FLAG(PLAYER_GOOD,FLAG2,1)

SET_CREATURE_PROPERTY(KNIGHT,NO_CORPSE_ROTTING,1)
SET_CREATURE_CONFIGURATION(KNIGHT,CorpseVanishEffect,64)
SET_CREATURE_PROPERTY(TIME_MAGE,NO_CORPSE_ROTTING,1)
SET_CREATURE_CONFIGURATION(TIME_MAGE,CorpseVanishEffect,64)

REM XXX Unused, how to check creatures at ACTION POINT location
REM IF(PLAYER_GOOD,GAME_TURN > 20)
REM SET_FLAG(PLAYER_GOOD,FLAG3,1)
 REM NEXT_COMMAND_REUSABLE
 REM COUNT_CREATURES_AT_ACTION_POINT(11,PLAYER_GOOD,KNIGHT,PLAYER_GOOD,FLAG3)
   
 REM IF(PLAYER_GOOD,FLAG3 < 1)
 REM WIN_GAME
REM ENDIF
REM ENDIF

REM Knight escape
SET_FLAG(PLAYER_GOOD,FLAG1,1)
IF(PLAYER_GOOD,FLAG1 > 0)
    IF(PLAYER_GOOD,KNIGHT == 0)
        ADD_TO_FLAG(PLAYER_GOOD,FLAG0,-1)
        ADD_TO_PARTY(LordsEscape,IMP,10,0,ATTACK_DUNGEON_HEART,10)
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,KNIGHT,-4,1,10,1000)
        ADD_PARTY_TO_LEVEL(PLAYER_GOOD,LordsEscape,-4,1)
        SET_CREATURE_PROPERTY(KNIGHT,NO_IMPRISONMENT,0)
		SET_CREATURE_PROPERTY(KNIGHT,NO_CORPSE_ROTTING,0)
        CREATURE_AVAILABLE(ALL_PLAYERS,BARBARIAN,1,3)
        QUICK_OBJECTIVE(24,"The traitor lord has arisen reinforcements, enranged Barbarians have joined your forces, prepare for a fight Heroes!")
        ADD_TO_FLAG(PLAYER0,FLAG0,1)
    ENDIF
    REM If the prison is smaller than 9 squares
    IF(PLAYER1,PRISON < 5)
        IF(PLAYER_GOOD,KNIGHT == 1)
            MOVE_CREATURE(PLAYER_GOOD,KNIGHT,​ANYWHERE,1,-4,75)
            ADD_TO_PARTY(LordsEscape,IMP,10,0,ATTACK_DUNGEON_HEART,10)
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,LordsEscape,-4,1)
            ADD_TO_FLAG(PLAYER_GOOD,FLAG1,-1)
            SET_CREATURE_PROPERTY(KNIGHT,NO_IMPRISONMENT,0)
		    SET_CREATURE_PROPERTY(KNIGHT,NO_CORPSE_ROTTING,0)
            CREATURE_AVAILABLE(ALL_PLAYERS,BARBARIAN,1,3)
            QUICK_OBJECTIVE(14,"The traitor Knight has escaped captivity, enraged Barbarians join your cause!")
            ADD_TO_FLAG(PLAYER0,FLAG0,1)
            IF(PLAYER_GOOD,FLAG2 > 0)
                REM 75 is harmless fart gas to show creature arriving
                REM If Player1 has the Time Mage
                IF(PLAYER1,TIME_MAGE > 0)
                    IF(PLAYER_GOOD,TIME_MAGE == 0)
                        ADD_TO_FLAG(PLAYER_GOOD,FLAG2,-1)
                        MOVE_CREATURE(PLAYER1,TIME_MAGE,ANYWHERE,1,-4,75)
                        CHANGE_CREATURE_OWNER(​PLAYER1,TIME_MAGE,​ANYWHERE,​PLAYER_GOOD)
                        LEVEL_UP_CREATURE(​PLAYER_GOOD,TIME_MAGE,ANYWHERE,10)

                        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,BARBARIAN,PLAYER_GOOD,1,9,400)
                        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,BARBARIAN,PLAYER_GOOD,1,9,400)
                        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,PLAYER_GOOD,1,9,400)
                        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,PLAYER_GOOD,1,9,400)
                        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,PLAYER_GOOD,1,9,400)
                        ADD_CREATURE_TO_LEVEL(PLAYER1,WIZARD,-7,1,5,0)
                        SET_CREATURE_PROPERTY(TIME_MAGE,NO_CORPSE_ROTTING,0)
                        QUICK_OBJECTIVE(15,"One of our Mage's has betrayed our cause, be careful Heroes!")
	                ENDIF
                ENDIF
            ENDIF
	    ENDIF
        REM If a Torture Chamber is built
        IF(ALL_PLAYERS,TORTURE > 0)
            IF(PLAYER_GOOD,KNIGHT == 1)
                MOVE_CREATURE(PLAYER_GOOD,KNIGHT,​ANYWHERE,1,-4,75)
                ADD_TO_PARTY(LordsEscape,IMP,10,0,ATTACK_DUNGEON_HEART,10)
                ADD_PARTY_TO_LEVEL(PLAYER_GOOD,LordsEscape,-4,1)
                ADD_TO_FLAG(PLAYER_GOOD,FLAG1,-1)
                SET_CREATURE_PROPERTY(KNIGHT,NO_IMPRISONMENT,0)
		        SET_CREATURE_PROPERTY(KNIGHT,NO_CORPSE_ROTTING,0)
                CREATURE_AVAILABLE(ALL_PLAYERS,BARBARIAN,1,3)
                QUICK_OBJECTIVE(19,"The traitor Knight has escaped torture, enraged Barbarians join your cause!")
                ADD_TO_FLAG(PLAYER0,FLAG0,1)
                IF(PLAYER_GOOD,FLAG2 > 0)
                    IF(PLAYER1,TIME_MAGE > 0)
                        IF(PLAYER_GOOD,TIME_MAGE == 0)
                            ADD_TO_FLAG(PLAYER_GOOD,FLAG2,-1)
                            MOVE_CREATURE(PLAYER1,TIME_MAGE,ANYWHERE,1,-4,75)
                            CHANGE_CREATURE_OWNER(​PLAYER1,TIME_MAGE,​ANYWHERE,​PLAYER_GOOD)
                            LEVEL_UP_CREATURE(​PLAYER_GOOD,TIME_MAGE,ANYWHERE,10)

                            ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,BARBARIAN,PLAYER_GOOD,1,9,400)
                            ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,BARBARIAN,PLAYER_GOOD,1,9,400)
                            ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,PLAYER_GOOD,1,9,400)
                            ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,PLAYER_GOOD,1,9,400)
                            ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,PLAYER_GOOD,1,9,400)
                            ADD_CREATURE_TO_LEVEL(PLAYER1,WIZARD,-7,1,5,0)
                            SET_CREATURE_PROPERTY(TIME_MAGE,NO_CORPSE_ROTTING,0)
                            QUICK_OBJECTIVE(20,"One of our Mage's has betrayed our cause, becareful Heroes!")
	                    ENDIF
                    ENDIF
                ENDIF
	        ENDIF
        ENDIF          
    ENDIF
ENDIF
IF(PLAYER_GOOD,FLAG2 > 0)
    IF(PLAYER1,TIME_MAGE == 0)
        ADD_TO_FLAG(PLAYER_GOOD,FLAG2,-1)
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,TIME_MAGE,-4,1,10,700)
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,BARBARIAN,-4,1,9,500)
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,BARBARIAN,-4,1,9,500)
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,-4,1,6,200)
        ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,-4,1,6,200)
        ADD_CREATURE_TO_LEVEL(PLAYER1,WIZARD,-7,1,5,0)
        SET_CREATURE_PROPERTY(TIME_MAGE,NO_CORPSE_ROTTING,0)
        QUICK_OBJECTIVE(13,"A foul Mage has betrayed our cause, becareful Heroes!")
            IF(PLAYER_GOOD,TIME_MAGE == 0)
                ADD_TO_FLAG(PLAYER_GOOD,FLAG2,-1)
                ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,TIME_MAGE,-4,1,10,700)
                ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,BARBARIAN,-4,1,9,500)
                ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,BARBARIAN,-4,1,9,500)
                ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,-4,1,6,200)
                ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,-4,1,6,200)
                ADD_CREATURE_TO_LEVEL(PLAYER1,WIZARD,-7,1,5,0)
                SET_CREATURE_PROPERTY(TIME_MAGE,NO_CORPSE_ROTTING,0)
                QUICK_OBJECTIVE(21,"A foul Mage has betrayed our cause, becareful Heroes!")
            ENDIF
    ENDIF
ENDIF
REM End of KNIGHT AND MAGE BETRAYAL AND ESCAPE -----------------------------------------------------------------------------------

REM XXX Library doesn't exist by player0
REM IF(PLAYER0,RESEARCH > 0)
REM  SET_TIMER(PLAYER_GOOD,TIMER1)
REM ENDIF

REM XXX PLAYER0 reinforcements

REM XXX VICTORY CONDITION XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
IF(PLAYER_GOOD, DUNGEON_DESTROYED >= 1)
	
    QUICK_OBJECTIVE(17,"The ruinous creatures have been expelled from this land. However, the traitor lord has escaped but you have no time to pursue him.")

    QUICK_INFORMATION(18,"Your advisors insist that you must escort the Princess now that her position is compromised. Take her West hero, she must sail to safety!")
        WIN_GAME
ENDIF

REM XXX HELPS, TIPS AND REMINDERS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

REM Anger = defines if a creature betrays 'join the enemy' Anger job
REM Minions can't throw Grenades, Wind requires the user to not be immune to Gas (Vampires, Wizard, Fairy)

REM XXX DRAGON Configuration Examples.
REM SET_CREATURE_CONFIGURATION(DRAGON,Health,1800)
REM SET_CREATURE_CONFIGURATION(DRAGON,Strength,100)
REM SET_CREATURE_CONFIGURATION(DRAGON,Armour,120)
REM SET_CREATURE_CONFIGURATION(DRAGON,Luck,36)
REM SET_CREATURE_CONFIGURATION(DRAGON,Recovery,15)
REM SET_CREATURE_CONFIGURATION(DRAGON,HungerRate,16000)
REM SET_CREATURE_CONFIGURATION(DRAGON,HungerFill,2)
REM SET_CREATURE_CONFIGURATION(DRAGON,LairSize,1)
REM SET_CREATURE_CONFIGURATION(DRAGON,BaseSpeed,64)
REM SET_CREATURE_CONFIGURATION(DRAGON,AttackPreference,MELEE)
REM SET_CREATURE_CONFIGURATION(DRAGON,Pay,700)

REM XXX Editable creature SPELL examples
REM SET_CREATURE_INSTANCE(DRAGON,1,FLAME_BREATH,1)
REM SET_CREATURE_INSTANCE(DRAGON,2,SWING_WEAPON_FIST,1)
REM SET_CREATURE_INSTANCE(DRAGON,3,HEAL,2)
REM SET_CREATURE_INSTANCE(DRAGON,4,REBOUND,4)
REM SET_CREATURE_INSTANCE(DRAGON,7,FREEZE,7)
REM SET_CREATURE_INSTANCE(DRAGON,10,HAILSTORM,10)

REM XXX Editable creature JOB examples
REM SET_CREATURE_CONFIGURATION(DRAGON,PrimaryJobs,FIGHT)
REM SET_CREATURE_CONFIGURATION(DRAGON,SecondaryJobs,EXPLORE,TEMPLE_PRAY)
REM SET_CREATURE_CONFIGURATION(DRAGON,NotDoJobs,SCAVENGE)

REM XXX Editabe immunities
REM SET_CREATURE_PROPERTY(HORNY,NO_IMPRISONMENT,1)
REM SET_CREATURE_PROPERTY(HORNY,IMMUNE_TO_BOULDER,1)