REM	Shao-Lin Temple
REM	v1 by dayokay Mar 1998
REM	v2 by dayokay Feb 2025
REM	credit to ben_lp for the freeze and Hailstorm traps included

LEVEL_VERSION(1)

SET_PLAYER_COLOR(PLAYER3,PURPLE)

REVEAL_MAP_RECT(PLAYER0,40,20,80,40)
REVEAL_MAP_RECT(PLAYER0,198,134,30,14)

SET_GENERATE_SPEED(600)

SET_CREATURE_INSTANCE(WIZARD,7,TELEPORT,7)
ADD_CREATURE_TO_LEVEL(PLAYER3,WIZARD,PLAYER3,4,6,400)

START_MONEY(PLAYER0,5000)
START_MONEY(PLAYER3,25000)
START_MONEY(PLAYER2,200000)
START_MONEY(PLAYER1,200000)

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

NEW_TRAP_TYPE(FREEZE)
NEW_OBJECT_TYPE(WRKBOX_FREEZE)
SET_OBJECT_CONFIGURATION(WRKBOX_FREEZE,Genre,WORKSHOPBOX)
SET_OBJECT_CONFIGURATION(WRKBOX_FREEZE,AnimationID,114)
SET_OBJECT_CONFIGURATION(WRKBOX_FREEZE,AnimationSpeed,256)
SET_OBJECT_CONFIGURATION(WRKBOX_FREEZE,MaximumSize,300)
SET_OBJECT_CONFIGURATION(WRKBOX_FREEZE,DestroyOnLava,1)
SET_OBJECT_CONFIGURATION(WRKBOX_FREEZE,MapIcon,531)
SET_OBJECT_CONFIGURATION(WRKBOX_FREEZE,Properties,CHOWNED_ON_ROOM_CLAIM)

NEW_TRAP_TYPE(HAILSTORM)
NEW_OBJECT_TYPE(WRKBOX_HAILSTORM)
SET_OBJECT_CONFIGURATION(WRKBOX_HAILSTORM,Genre,WORKSHOPBOX)
SET_OBJECT_CONFIGURATION(WRKBOX_HAILSTORM,AnimationID,114)
SET_OBJECT_CONFIGURATION(WRKBOX_HAILSTORM,AnimationSpeed,256)
SET_OBJECT_CONFIGURATION(WRKBOX_HAILSTORM,MaximumSize,300)
SET_OBJECT_CONFIGURATION(WRKBOX_HAILSTORM,DestroyOnLava,1)
SET_OBJECT_CONFIGURATION(WRKBOX_HAILSTORM,MapIcon,531)
SET_OBJECT_CONFIGURATION(WRKBOX_HAILSTORM,Properties,CHOWNED_ON_ROOM_CLAIM)

REM # Freeze Trap Configuration.
SET_TRAP_CONFIGURATION(FREEZE,NameTextID,982)
SET_TRAP_CONFIGURATION(FREEZE,TooltipTextID,982)
SET_TRAP_CONFIGURATION(FREEZE,SymbolSprites,523,406)
SET_TRAP_CONFIGURATION(FREEZE,PointerSprites,160)
SET_TRAP_CONFIGURATION(FREEZE,PanelTabIndex,5)
SET_TRAP_CONFIGURATION(FREEZE,Crate,WRKBOX_FREEZE)
SET_TRAP_CONFIGURATION(FREEZE,ManufactureLevel,0)
SET_TRAP_CONFIGURATION(FREEZE,ManufactureRequired,10000)
SET_TRAP_CONFIGURATION(FREEZE,Shots,16)
SET_TRAP_CONFIGURATION(FREEZE,TimeBetweenShots,750)
SET_TRAP_CONFIGURATION(FREEZE,SellingValue,1000)
SET_TRAP_CONFIGURATION(FREEZE,Model,845)
SET_TRAP_CONFIGURATION(FREEZE,ModelSize,256)
SET_TRAP_CONFIGURATION(FREEZE,AnimationSpeed,256)
SET_TRAP_CONFIGURATION(FREEZE,TriggerType,2)
SET_TRAP_CONFIGURATION(FREEZE,ActivationType,5)
SET_TRAP_CONFIGURATION(FREEZE,EffectType,3)
SET_TRAP_CONFIGURATION(FREEZE,Hidden,0)
SET_TRAP_CONFIGURATION(FREEZE,Slappable,0)
SET_TRAP_CONFIGURATION(FREEZE,Destructible,0)
SET_TRAP_CONFIGURATION(FREEZE,Unstable,0)
SET_TRAP_CONFIGURATION(FREEZE,PlaceOnBridge,1)
SET_TRAP_CONFIGURATION(FREEZE,Health,128)
SET_TRAP_CONFIGURATION(FREEZE,ThingSize,128,256)
SET_TRAP_CONFIGURATION(FREEZE,HitType,4)

REM # Hailstorm Trap Configuration.
SET_TRAP_CONFIGURATION(HAILSTORM,NameTextID,244)
SET_TRAP_CONFIGURATION(HAILSTORM,TooltipTextID,244)
SET_TRAP_CONFIGURATION(HAILSTORM,SymbolSprites,384,442)
SET_TRAP_CONFIGURATION(HAILSTORM,PointerSprites,161)
SET_TRAP_CONFIGURATION(HAILSTORM,PanelTabIndex,6)
SET_TRAP_CONFIGURATION(HAILSTORM,Crate,WRKBOX_HAILSTORM)
SET_TRAP_CONFIGURATION(HAILSTORM,ManufactureLevel,0)
SET_TRAP_CONFIGURATION(HAILSTORM,ManufactureRequired,10000)
SET_TRAP_CONFIGURATION(HAILSTORM,Shots,100)
SET_TRAP_CONFIGURATION(HAILSTORM,TimeBetweenShots,120)
SET_TRAP_CONFIGURATION(HAILSTORM,SellingValue,1000)
SET_TRAP_CONFIGURATION(HAILSTORM,Model,845)
SET_TRAP_CONFIGURATION(HAILSTORM,ModelSize,256)
SET_TRAP_CONFIGURATION(HAILSTORM,AnimationSpeed,256)
SET_TRAP_CONFIGURATION(HAILSTORM,TriggerType,3)
SET_TRAP_CONFIGURATION(HAILSTORM,ActivationType,5)
SET_TRAP_CONFIGURATION(HAILSTORM,EffectType,13)
SET_TRAP_CONFIGURATION(HAILSTORM,Hidden,0)
SET_TRAP_CONFIGURATION(HAILSTORM,Slappable,0)
SET_TRAP_CONFIGURATION(HAILSTORM,Destructible,1)
SET_TRAP_CONFIGURATION(HAILSTORM,Unstable,2)
SET_TRAP_CONFIGURATION(HAILSTORM,PlaceOnBridge,1)
SET_TRAP_CONFIGURATION(HAILSTORM,Health,128)
SET_TRAP_CONFIGURATION(HAILSTORM,ThingSize,128,256)
SET_TRAP_CONFIGURATION(HAILSTORM,HitType,4)


QUICK_OBJECTIVE(1,"Evil monks have betrayed the Shao-Lin Temple to your rivals. Heroes will attempt to retrieve it, but there are many devious parties who covet the Giant Temple. It should be yours oh devious one!" ,PLAYER0)
REM	DISPLAY_OBJECTIVE(X,PLAYER0)

IF(PLAYER0, TOTAL_CREATURES >3)
	ADD_CREATURE_TO_LEVEL(PLAYER0,WIZARD,PLAYER0,1,6,400)
	QUICK_OBJECTIVE(13,"You have assistance Master. You have sight of the enemy dungeons and some demonic traps to assist you in this quest." ,PLAYER0)
	REM	DISPLAY_OBJECTIVE(X,PLAYER0)
	QUICK_INFORMATION(20, "An unusually talented wizard has joined you in your noble quest. Treat him well.", PLAYER0)
	ADD_CREATURE_TO_LEVEL(PLAYER3,MAIDEN,PLAYER3,1,4,1000)
ENDIF

ALLY_PLAYERS(PLAYER1,PLAYER2,1)

COMPUTER_PLAYER(PLAYER1,2)
COMPUTER_PLAYER(PLAYER2,1)
COMPUTER_PLAYER(PLAYER3,10)

CREATURE_AVAILABLE(ALL_PLAYERS,SKELETON,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,VAMPIRE,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,BILE_DEMON,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,SORCEROR,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,DARK_MISTRESS,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,DEMONSPAWN,1,0)
CREATURE_AVAILABLE(ALL_PLAYERS,DRAGON,1,1)
CREATURE_AVAILABLE(ALL_PLAYERS,TROLL,1,0)
CREATURE_AVAILABLE(PLAYER3,ORC,1,1)

ADD_CREATURE_TO_POOL(SKELETON,30)
ADD_CREATURE_TO_POOL(ORC,10)
ADD_CREATURE_TO_POOL(BILE_DEMON,20)
ADD_CREATURE_TO_POOL(SORCEROR,50)
ADD_CREATURE_TO_POOL(DARK_MISTRESS,8)
ADD_CREATURE_TO_POOL(DEMONSPAWN,40)
ADD_CREATURE_TO_POOL(DRAGON,30)
ADD_CREATURE_TO_POOL(TROLL,40)

MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SPEED,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_PROTECT,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_DESTROY_WALLS,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HAND,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SLAP,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CONCEAL,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_POSSESS,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_IMP,1,1)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_SIGHT,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HEAL_CREATURE,1,0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_CALL_TO_ARMS,1,0)


ROOM_AVAILABLE(ALL_PLAYERS,GRAVEYARD,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,ENTRANCE,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,TRAINING,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,BARRACKS,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,TREASURE,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,WORKSHOP,1,0)
ROOM_AVAILABLE(ALL_PLAYERS,GARDEN,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,RESEARCH,1,1)
ROOM_AVAILABLE(PLAYER0,LAIR,1,0)
ROOM_AVAILABLE(PLAYER1,LAIR,1,1)
ROOM_AVAILABLE(PLAYER2,LAIR,1,1)
ROOM_AVAILABLE(PLAYER3,LAIR,1,1)
ROOM_AVAILABLE(ALL_PLAYERS,PRISON,1,0)

ROOM_AVAILABLE(ALL_PLAYERS,TORTURE,1,0)

IF(PLAYER0,PRISON > 0)
    ROOM_AVAILABLE(PLAYER0,BRIDGE,1,0)
    ROOM_AVAILABLE(PLAYER0,GUARD_POST,1,0)
ENDIF

IF(PLAYER3,PRISON > 0)
    ROOM_AVAILABLE(PLAYER3,BRIDGE,1,0)
    ROOM_AVAILABLE(PLAYER3,GUARD_POST,1,0)
ENDIF

IF(PLAYER2,PRISON > 0)
    ROOM_AVAILABLE(PLAYER1,BRIDGE,1,0)
    ROOM_AVAILABLE(PLAYER1,GUARD_POST,1,0)
    ROOM_AVAILABLE(PLAYER2,BRIDGE,1,0)
    ROOM_AVAILABLE(PLAYER2,GUARD_POST,1,0)
ENDIF

TRAP_AVAILABLE(PLAYER1,BOULDER,1,0)
TRAP_AVAILABLE(PLAYER1,LIGHTNING,1,0)
TRAP_AVAILABLE(PLAYER2,BOULDER,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,LIGHTNING,1,0)
TRAP_AVAILABLE(PLAYER3,BOULDER,1,0)
TRAP_AVAILABLE(PLAYER3,LIGHTNING,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,POISON_GAS,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,FREEZE,1,3)
TRAP_AVAILABLE(ALL_PLAYERS,HAILSTORM,1,3)

DOOR_AVAILABLE(ALL_PLAYERS,BRACED,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,MAGIC,1,0)

CREATE_PARTY(NEWPARTY)
    ADD_TO_PARTY(NEWPARTY,AVATAR,8,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(NEWPARTY,MONK,8,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(NEWPARTY,MONK,8,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(NEWPARTY,MONK,8,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(NEWPARTY,MONK,10,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(NEWPARTY,SAMURAI,8,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(NEWPARTY,SAMURAI,8,500,ATTACK_ENEMIES,0)

CREATE_PARTY(ENDGAME)
    ADD_TO_PARTY(ENDGAME,SAMURAI,8,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ENDGAME,SAMURAI,10,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(ENDGAME,WIZARD,9,500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(ENDGAME,WIZARD,9,500,ATTACK_ENEMIES,0)
	ADD_TO_PARTY(ENDGAME,IMP,9,500,ATTACK_ENEMIES,0)

CREATE_PARTY(NUISANCE)
    ADD_TO_PARTY(NUISANCE, GIANT,3,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(NUISANCE, GIANT,2,500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(NUISANCE, MONK,3,500,ATTACK_ENEMIES,0)

IF(PLAYER1,DUNGEON_DESTROYED == 1)
	IF(PLAYER0, FLAG3 ==0)
		ALLY_PLAYERS(PLAYER2,PLAYER3,1)
		ALLY_PLAYERS(PLAYER_GOOD,PLAYER2,1)
		QUICK_OBJECTIVE(2,"Heroes have destroyed one of your enemies, but made peace with another. This is a complex realm master, where allegiances are unstable." ,PLAYER0)
		REM	DISPLAY_OBJECTIVE(X,PLAYER0)
		SET_FLAG(PLAYER0, FLAG3, 1)
	ENDIF
ENDIF

IF(PLAYER2,DUNGEON_DESTROYED == 1)
	IF(PLAYER0, FLAG3 ==0)
		ALLY_PLAYERS(PLAYER1,PLAYER3,1)
		ALLY_PLAYERS(PLAYER_GOOD,PLAYER1,1)
		QUICK_OBJECTIVE(3,"Heroes have destroyed one of your enemies, but made peace with another. This is a complex realm master, where allegiances are unstable." ,PLAYER0)
		REM	DISPLAY_OBJECTIVE(X,PLAYER0)
		SET_FLAG(PLAYER0, FLAG3, 1)
	ENDIF
ENDIF

IF(PLAYER3, TOTAL_CREATURES > 14)
	IF(PLAYER0, TOTAL_CREATURES > 14)
		SET_FLAG(PLAYER0, FLAG2, 1)
	ENDIF
ENDIF

IF(PLAYER0,FLAG2 == 1)
	SET_TIMER(PLAYER0, TIMER2)	
	IF(PLAYER0, TIMER2 >1000)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,NUISANCE,PLAYER3,1)
		QUICK_OBJECTIVE(9,"Hero scout parties are being sent to test the opposition Keeper. You'd best be on your guard!" ,PLAYER3)
		REM	DISPLAY_OBJECTIVE(X,PLAYER3)
		IF(PLAYER0, TIMER2 >2000)
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,NUISANCE,1,2)
			QUICK_OBJECTIVE(10,"More scouts! You will be next Keeper, for sure" ,PLAYER2)
			REM	DISPLAY_OBJECTIVE(X,PLAYER2)
			IF(PLAYER0, TIMER2 >3000)
				QUICK_OBJECTIVE(11,"Here they come!" ,2)
				REM	DISPLAY_OBJECTIVE(X,2)
				ADD_PARTY_TO_LEVEL(PLAYER_GOOD,NUISANCE,2,1)
			ENDIF
		ENDIF
	ENDIF
ENDIF

IF(PLAYER3,BATTLES_LOST > 6)
	IF_CONTROLS(PLAYER3,TOTAL_CREATURES <6)
		ALLY_PLAYERS(PLAYER1,PLAYER3,1)
		ALLY_PLAYERS(PLAYER2,PLAYER3,1)
		ALLY_PLAYERS(PLAYER_GOOD,PLAYER3,1)
		QUICK_OBJECTIVE(4,"Alliances shift quickly in this land Master, and not to your advantage! You must make your move at the right time. The Western Keeper has been severely weakened." ,PLAYER3)
		REM	DISPLAY_OBJECTIVE(X,PLAYER3)
	ENDIF
ENDIF

IF(PLAYER3, TOTAL_CREATURES > 24)
	SET_FLAG(PLAYER0, FLAG1, 1)
ENDIF

IF(PLAYER1, TOTAL_CREATURES > 24)
	SET_FLAG(PLAYER0, FLAG1, 1)
ENDIF

IF(PLAYER2, TOTAL_CREATURES > 24)
	SET_FLAG(PLAYER0, FLAG1, 1)
ENDIF

IF(PLAYER0,FLAG2 == 1)
REM	QUICK_OBJECTIVE(18,"Flag 2 - creatures at 14 has triggered." ,PLAYER0)
IF(PLAYER0,FLAG1 == 1)
	REM	QUICK_OBJECTIVE(19,"Flag 1 - creatures at 24 has triggered." ,PLAYER0)
	SET_TIMER(PLAYER0, TIMER1)
	IF(PLAYER0, TIMER1 >11000)
		QUICK_OBJECTIVE(14,"The Heroes and their new allies have begun their attack Keeper. Follow events closely to allow you to time your own attack to your maximum advantage. " ,ALL_PLAYERS)
		REM	DISPLAY_OBJECTIVE(X,PLAYER0)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,NEWPARTY,1,1)
		ADD_PARTY_TO_LEVEL(PLAYER_GOOD,ENDGAME,PLAYER3,1)
		ALLY_PLAYERS(DRAWFROM(PLAYER1,PLAYER2),PLAYER_GOOD,1)
		IF(PLAYER0, TIMER1 >13000)
			ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER3,NUISANCE,PLAYER3,DUNGEON,0,10,600)
			ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER1,NUISANCE,1,DUNGEON,0,10,600)
			ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER2,NUISANCE,1,DUNGEON,0,10,600)
			MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HAND,0,0)
			QUICK_OBJECTIVE(15,"What dark magic is this? You have lost control of your minions Master! This may signify an imminent attack? Your minions will fix this shortly I hope, or you are destined for defeat." ,ALL_PLAYERS)
			REM	DISPLAY_OBJECTIVE(X,PLAYER0)
		ENDIF
	ENDIF
ENDIF
ENDIF

IF(PLAYER0, TIMER1>15000)
	MAGIC_AVAILABLE(ALL_PLAYERS,POWER_HAND,1,1)
	QUICK_OBJECTIVE(24,"Your Magicians have restored your power Master. Let's hope it's not too late. To battle!!" ,PLAYER0)
ENDIF



IF(PLAYER0,ALL_DUNGEONS_DESTROYED == 1)
    IF(PLAYER_GOOD,TOTAL_CREATURES < 1)
	IF(PLAYER0, TEMPLE > 40)
        	QUICK_OBJECTIVE(7,"This land and the precious temple are returned to your tender care Keeper! Be sure not to lose them again. " ,PLAYER0)
		REM	DISPLAY_OBJECTIVE(X,PLAYER0)
        	WIN_GAME
	ENDIF
    ENDIF
ENDIF

HEART_LOST_QUICK_OBJECTIVE(8,"You have proved yourself unworthy and disappointed the Gods Keeper. You are dismissed. Now no-one will care whether you attacked too early or too late.",PLAYER0)


