REM ****************************************************************************
REM  Campaigns Consolidation Project for KeeperFX strategy game.
REM ****************************************************************************
REM  Script for Level Hearth
REM  Campaign: New game plus
REM  Authors:  based on Bullfrog script
REM            KeeperFX CCP Team
REM            Loobinex
REM  Date:     17 Dec 1996 - 24 Aug 2020
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)

REM Flags used:
REM   PLAYER_GOOD,FLAG0 - Continuous spawning of parties FIRST-FOURTH; 0-spawn; 1-stop spawning. 
REM Timers used:
REM   PLAYER_GOOD,TIMER1 - Counter for continuous spawning of party FIRST
REM   PLAYER_GOOD,TIMER2 - Counter for continuous spawning of party SECOND
REM   PLAYER_GOOD,TIMER3 - Counter for continuous spawning of party THIRD
REM   PLAYER_GOOD,TIMER4 - Counter for continuous spawning of party FOURTH
REM   PLAYER0,TIMER1 - Starts counting after first wave of heroes (parties FIRST-FOURTH) are killed
REM   PLAYER0,TIMER2 - Starts counting after Lord of the Land appearance

SET_GENERATE_SPEED(400)

START_MONEY(PLAYER0,10000)

MAX_CREATURES(PLAYER0,30)

ADD_CREATURE_TO_POOL(DEMONSPAWN,20)
ADD_CREATURE_TO_POOL(DARK_MISTRESS,20)
ADD_CREATURE_TO_POOL(SORCEROR,30)
ADD_CREATURE_TO_POOL(TROLL,20)
ADD_CREATURE_TO_POOL(BILE_DEMON,10)
ADD_CREATURE_TO_POOL(HELL_HOUND,30)
ADD_CREATURE_TO_POOL(DRAGON,15)
ADD_CREATURE_TO_POOL(ORC,15)

REM	Creature availability
CREATURE_AVAILABLE(PLAYER0,TROLL,1,0)
CREATURE_AVAILABLE(PLAYER0,DEMONSPAWN,1,0)
CREATURE_AVAILABLE(PLAYER0,DARK_MISTRESS,1,0)
CREATURE_AVAILABLE(PLAYER0,SORCEROR,1,0)
CREATURE_AVAILABLE(PLAYER0,BILE_DEMON,1,0)
CREATURE_AVAILABLE(PLAYER0,HELL_HOUND,1,0)
CREATURE_AVAILABLE(PLAYER0,DRAGON,1,0)
CREATURE_AVAILABLE(PLAYER0,ORC,1,0)

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,1)
ROOM_AVAILABLE(ALL_PLAYERS,BARRACKS,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,GUARD_POST,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,BRIDGE,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,PRISON,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,SCAVENGER,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,TORTURE,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,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CALL_TO_ARMS,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HEAL_CREATURE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SPEED,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_LIGHTNING,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_PROTECT,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CONCEAL,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_DISEASE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CAVE_IN,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CHICKEN,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HOLD_AUDIENCE,1,0)

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

CREATE_PARTY(FIRST)
	ADD_TO_PARTY(FIRST,BARBARIAN,2,100,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(FIRST,GIANT,2,100,ATTACK_ENEMIES,0)

CREATE_PARTY(SECOND)
	ADD_TO_PARTY(SECOND,MONK,3,100,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(SECOND,MONK,3,100,ATTACK_ENEMIES,0)

CREATE_PARTY(THIRD)
	ADD_TO_PARTY(THIRD,ARCHER,4,100,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(THIRD,BARBARIAN,4,100,ATTACK_ENEMIES,0)

CREATE_PARTY(FOURTH)
	ADD_TO_PARTY(FOURTH,WIZARD,4,100,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(FOURTH,GIANT,4,100,ATTACK_ENEMIES,0)

CREATE_PARTY(FIFTH)
	ADD_TO_PARTY(FIFTH,WIZARD,5,100,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(FIFTH,WIZARD,5,150,ATTACK_ENEMIES,0)

CREATE_PARTY(SIXTH)
	ADD_TO_PARTY(SIXTH,MONK,6,100,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(SIXTH,MONK,6,100,ATTACK_ENEMIES,0)

CREATE_PARTY(SEVENTH)
	ADD_TO_PARTY(SEVENTH,FAIRY,6,100,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(SEVENTH,FAIRY,6,100,ATTACK_ENEMIES,0)

CREATE_PARTY(EIGHTH)
	ADD_TO_PARTY(EIGHTH,WITCH,8,100,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(EIGHTH,WITCH,8,100,ATTACK_ENEMIES,0)

CREATE_PARTY(LANDLORD)
	ADD_TO_PARTY(LANDLORD,KNIGHT,6,1000,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(LANDLORD,ARCHER,6,50,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(LANDLORD,BARBARIAN,6,50,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(LANDLORD,MONK,6,50,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(LANDLORD,FAIRY,8,50,ATTACK_ENEMIES,0)

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

REM "If lands had legs this one would be on its knees. Its desperate inhabitants are preparing a full scale attack on your dungeon..."
DISPLAY_OBJECTIVE(105,ALL_PLAYERS)

REM Spawn continuously the FIRST party
IF(PLAYER_GOOD,GAME_TURN >= 1000)
	SET_TIMER(PLAYER_GOOD,TIMER1)
ENDIF

IF(PLAYER_GOOD,FLAG0 == 0)
	IF(PLAYER_GOOD,TIMER1 > 1750)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FIRST,3,1)
		NEXT_COMMAND_REUSABLE
		SET_TIMER(PLAYER_GOOD,TIMER1)
	ENDIF
ENDIF

REM Spawn continuously the SECOND party
IF(PLAYER_GOOD,GAME_TURN >= 1750)
	SET_TIMER(PLAYER_GOOD,TIMER2)
ENDIF

IF(PLAYER_GOOD,FLAG0 == 0)
	IF(PLAYER_GOOD,TIMER2 > 2250)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SECOND,1,1)
		NEXT_COMMAND_REUSABLE
		SET_TIMER(PLAYER_GOOD,TIMER2)
	ENDIF
ENDIF

REM Spawn continuously the THIRD party
IF(PLAYER_GOOD,GAME_TURN >= 2500)
	SET_TIMER(PLAYER_GOOD,TIMER3)
ENDIF

IF(PLAYER_GOOD,FLAG0 == 0)
	IF(PLAYER_GOOD,TIMER3 > 2750)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,THIRD,2,1)
		NEXT_COMMAND_REUSABLE
		SET_TIMER(PLAYER_GOOD,TIMER3)
	ENDIF
ENDIF

REM Spawn continuously the FOURTH party
IF(PLAYER_GOOD,GAME_TURN >= 3250)
	SET_TIMER(PLAYER_GOOD,TIMER4)
ENDIF

IF(PLAYER_GOOD,FLAG0 == 0)
	IF(PLAYER_GOOD,TIMER4 > 3500)
		NEXT_COMMAND_REUSABLE
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FOURTH,4,1)
		NEXT_COMMAND_REUSABLE
		SET_TIMER(PLAYER_GOOD,TIMER4)
	ENDIF
ENDIF

REM Stop spawning continous parties after a given amount of turns
IF(PLAYER_GOOD,GAME_TURN >= 13000)
	SET_FLAG(PLAYER_GOOD,FLAG0,1)
	IF_CONTROLS(PLAYER_GOOD,TOTAL_CREATURES <= 0)
		REM "Your annihilation of the first wave has met with the approval of a pack of demons from the fifth plane of hell..."
		DISPLAY_OBJECTIVE(102,PLAYER0)
		SET_TIMER(PLAYER0,TIMER1)
		ROOM_AVAILABLE(ALL_PLAYERS,BRIDGE,0,0)
		TUTORIAL_FLASH_BUTTON(18,60)
	ENDIF
ENDIF

REM Extra parties for player when he goes after specials
IF(PLAYER0,BRIDGE >= 6)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FIFTH,DRAWFROM(1,2,3),1)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SIXTH,DRAWFROM(1,2,3),1)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SEVENTH,DRAWFROM(1,2,3),1)
ENDIF

REM Start a second wave
IF(PLAYER0,TIMER1 >= 3000)
	REM "The enemy are upon us. I'm just telling you in case you were having a doze."
	DISPLAY_OBJECTIVE(103,ALL_PLAYERS)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FIFTH,DRAWFROM(1,2,3,4),1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SIXTH,DRAWFROM(1,2,3,4),1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SEVENTH,DRAWFROM(1,2,3,4),1)
ENDIF

IF(PLAYER0,TIMER1 >= 4000)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,EIGHTH,DRAWFROM(2,4),1)
ENDIF

IF(PLAYER0,TIMER1 >= 4500)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,LANDLORD,DRAWFROM(2,4),1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,THIRD,DRAWFROM(2,4),1)
	ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FOURTH,DRAWFROM(2,4),1)
	SET_TIMER(PLAYER0,TIMER2)
ENDIF

IF(PLAYER0,TIMER2 >= 200)
	IF_CONTROLS(PLAYER_GOOD,TOTAL_CREATURES <= 0)
		REM "All the heroes are dead, which is as it should be. This land and all its spoils are yours. May I suggest that you waste everything?"
		DISPLAY_OBJECTIVE(104,ALL_PLAYERS)
		WIN_GAME
	ENDIF
ENDIF

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