REM -------------------------------------------------------------------------------------------------------------------------------------------
REM Undead Keeper
REM Elysium
REM Made by Duke Ragereaver
REM	updated for pot file by dayokay (Nov2020)
REM -------------------------------------------------------------------------------------------------------------------------------------------

START_MONEY(PLAYER0,39500)

COMPUTER_PLAYER(PLAYER1,8)
COMPUTER_PLAYER(PLAYER2,8)
COMPUTER_PLAYER(PLAYER3,8)

ALLY_PLAYERS(PLAYER0,PLAYER1)
ALLY_PLAYERS(PLAYER0,PLAYER2)
ALLY_PLAYERS(PLAYER0,PLAYER3)
ALLY_PLAYERS(PLAYER1,PLAYER3)
ALLY_PLAYERS(PLAYER2,PLAYER3)
ALLY_PLAYERS(PLAYER1,PLAYER2)

SET_CREATURE_HEALTH(VAMPIRE,3250)
SET_CREATURE_STRENGTH(VAMPIRE,175)
SET_CREATURE_ARMOUR(VAMPIRE,150)

SET_CREATURE_HEALTH(AVATAR,3250)
SET_CREATURE_ARMOUR(AVATAR,150)

SET_CREATURE_HEALTH(SPIDER,550)
SET_CREATURE_HEALTH(GHOST,400)
SET_CREATURE_HEALTH(SKELETON,650)

REM -------------------------------------------------------------------------------------------------------------------------------------------

CREATE_PARTY(BOULDER_FAIL)
    ADD_TO_PARTY(BOULDER_FAIL,GIANT,6,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(BOULDER_FAIL,GIANT,6,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(BOULDER_FAIL,ARCHER,4,0,DEFEND_PARTY,0)
    ADD_TO_PARTY(BOULDER_FAIL,ARCHER,4,0,DEFEND_PARTY,0)

CREATE_PARTY(DEFENDERS_ONE)
    ADD_TO_PARTY(DEFENDERS_ONE,GIANT,7,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DEFENDERS_ONE,GIANT,7,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DEFENDERS_ONE,BARBARIAN,7,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DEFENDERS_ONE,BARBARIAN,7,0,ATTACK_ENEMIES,0)

CREATE_PARTY(DEFENDERS_TWO)
    ADD_TO_PARTY(DEFENDERS_TWO,THIEF,7,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DEFENDERS_TWO,THIEF,7,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DEFENDERS_TWO,ARCHER,7,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DEFENDERS_TWO,ARCHER,7,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DEFENDERS_TWO,DWARFA,7,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DEFENDERS_TWO,THIEF,7,0,ATTACK_ENEMIES,0)

CREATE_PARTY(SKELETONS)
    ADD_TO_PARTY(SKELETONS,SKELETON,8,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SKELETONS,SKELETON,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SKELETONS,SKELETON,6,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SKELETONS,SKELETON,6,0,ATTACK_ENEMIES,0)

CREATE_PARTY(GHOSTS)
    ADD_TO_PARTY(GHOSTS,GHOST,8,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(GHOSTS,GHOST,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(GHOSTS,GHOST,6,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(GHOSTS,GHOST,6,0,ATTACK_ENEMIES,0)

CREATE_PARTY(SPIDERS)
    ADD_TO_PARTY(SPIDERS,SPIDER,8,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SPIDERS,SPIDER,10,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SPIDERS,SPIDER,6,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(SPIDERS,SPIDER,6,0,ATTACK_ENEMIES,0)

CREATE_PARTY(LAST_STAND)
    ADD_TO_PARTY(LAST_STAND,SORCEROR,7,0,DEFEND_PARTY,0)
    ADD_TO_PARTY(LAST_STAND,WIZARD,8,0,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(LAST_STAND,ARCHER,6,0,DEFEND_PARTY,0)
    ADD_TO_PARTY(LAST_STAND,GIANT,6,0,DEFEND_PARTY,0)
    ADD_TO_PARTY(LAST_STAND,SAMURAI,9,0,DEFEND_PARTY,0)

REM -------------------------------------------------------------------------------------------------------------------------------------------

REM	QUICK_OBJECTIVE(0,"The Ancient Spirits of Intregity, Valor and Justice keep this realm protected with their ancient magic. They just missed one tiny detail, the elderly Vampire Lord Jedidiah was burried here long ago by those same spirits and is in slumber, awake him! For that, you will need some power structures with the Heroes protecting them, find and secure them. The Heroes will not hesitate to destroy them if nessesary so keep your eyes on the rascals.",PLAYER0)
DISPLAY_OBJECTIVE(40,PLAYER0)

REM Beginning

IF_ACTION_POINT(2,PLAYER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,-1,1,4,0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,-2,1,3,0)
ENDIF

IF_ACTION_POINT(3,PLAYER0)
    SET_FLAG(PLAYER1,FLAG0,1)
    REM	QUICK_OBJECTIVE(3,"You have reached and secured one of the power structures. Remember, the goal is to secure them, NOT destroy them!",PLAYER0)
	DISPLAY_OBJECTIVE(41,3)
ENDIF

IF_ACTION_POINT(4,PLAYER0)
    SET_FLAG(PLAYER2,FLAG0,1)
    REM	QUICK_OBJECTIVE(3,"You have reached and secured one of the power structures. Remember, the goal is to secure them, NOT destroy them!",PLAYER0)
	DISPLAY_OBJECTIVE(41,4)
ENDIF

IF_ACTION_POINT(5,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,BOULDER_FAIL,6,1)
ENDIF

IF_ACTION_POINT(7,PLAYER0)
    SET_FLAG(PLAYER3,FLAG0,1)
    REM	QUICK_OBJECTIVE(3,"You have reached and secured one of the power structures. Remember, the goal is to secure them, NOT destroy them!",PLAYER0)
	DISPLAY_OBJECTIVE(41,7)
ENDIF

IF(PLAYER1,FLAG0 == 1)
    IF(PLAYER2,FLAG0 == 1)
        IF(PLAYER3,FLAG0 == 1)
            ADD_CREATURE_TO_LEVEL(PLAYER0,VAMPIRE,1,1,10,9001)
			REM	QUICK_OBJECTIVE(1,"Jeddiah has awakened and is very eager on vengeance on those had imprisoned him, lead on. Your forces will gradually appear as the battle progresses... as do some special allies...",PLAYER0)
			DISPLAY_OBJECTIVE(42,PLAYER0)
        ENDIF
    ENDIF
ENDIF

REM Endgame

IF_ACTION_POINT(8,PLAYER0)
    SET_TIMER(PLAYER_GOOD,TIMER0)
    ADD_PARTY_TO_LEVEL(PLAYER2,GHOSTS,8,1)
ENDIF

IF(PLAYER_GOOD,TIMER0 >= 550)
    ADD_PARTY_TO_LEVEL(PLAYER3,SPIDERS,8,1)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DEFENDERS_ONE,-3,1)
ENDIF

IF(PLAYER_GOOD,TIMER0 >= 1000)
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DEFENDERS_TWO,-3,1)
    ADD_PARTY_TO_LEVEL(PLAYER1,SKELETONS,8,1)
ENDIF

IF_ACTION_POINT(9,PLAYER0)
    SET_FLAG(PLAYER1,FLAG1,1)
    REM	QUICK_OBJECTIVE(4,"More reinforcements are on the way to assist you.",PLAYER0)
	DISPLAY_OBJECTIVE(43,9)
ENDIF

IF_ACTION_POINT(10,PLAYER0)
    SET_FLAG(PLAYER2,FLAG1,1)
    REM	QUICK_OBJECTIVE(4,"More reinforcements are on the way to assist you.",PLAYER0)
	DISPLAY_OBJECTIVE(43,10)
ENDIF

IF_ACTION_POINT(11,PLAYER0)
    SET_FLAG(PLAYER3,FLAG1,1)
    REM	QUICK_OBJECTIVE(4,"More reinforcements are on the way to assist you.",PLAYER0)
	DISPLAY_OBJECTIVE(43,11)
ENDIF

IF_ACTION_POINT(12,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER2,GHOSTS,-4,1)
    ADD_PARTY_TO_LEVEL(PLAYER3,SPIDERS,-5,1)
    ADD_PARTY_TO_LEVEL(PLAYER1,SKELETONS,12,2)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,SAMURAI,14,2,6,0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,SAMURAI,13,1,7,0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,14,2,6,0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,13,1,7,0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,MONK,13,3,6,0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,BARBARIAN,13,2,6,0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,14,6,4,0)
ENDIF

IF_ACTION_POINT(15,PLAYER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,THIEF,-8,3,5,0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,ARCHER,-9,1,8,0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,BARBARIAN,-6,2,8,0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,GIANT,-7,2,6,0)
ENDIF

IF_ACTION_POINT(16,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER2,GHOSTS,16,1)
ENDIF

IF_ACTION_POINT(17,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER3,SPIDERS,17,1)
ENDIF

IF_ACTION_POINT(18,PLAYER0)
    ADD_PARTY_TO_LEVEL(PLAYER1,SKELETONS,18,1)
ENDIF

IF(PLAYER_GOOD,GHOST == 0)
    TUTORIAL_FLASH_BUTTON(13,PLAYER0)
    MAGIC_AVAILABLE(PLAYER0,POWER_DESTROY_WALLS,1,1)
    REM	QUICK_OBJECTIVE(2,"Use this spell to break down the walls and destroy the remaining opposition!",PLAYER0)
	DISPLAY_OBJECTIVE(44,PLAYER0)
ENDIF

REM The gang, part 1

IF_ACTION_POINT(19,PLAYER0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,AVATAR,PLAYER_GOOD,1,10,0)
    ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,GIANT,-10,6,6,0)
ADD_PARTY_TO_LEVEL(PLAYER1,SKELETONS,21,1)
    ADD_CREATURE_TO_LEVEL(PLAYER1,KNIGHT,20,1,10,0)
    ADD_CREATURE_TO_LEVEL(PLAYER2,KNIGHT,21,1,10,0)
    ADD_CREATURE_TO_LEVEL(PLAYER3,WIZARD,22,1,10,0)
    SET_FLAG(PLAYER_GOOD,FLAG0,1)
ENDIF

IF(PLAYER_GOOD,FLAG0 == 1)
    SET_TIMER(PLAYER_GOOD,TIMER1)
ENDIF

IF_ACTION_POINT(19,PLAYER0)
    IF(PLAYER1,FLAG1 == 1)
        SET_TIMER(PLAYER1,TIMER1)
    ENDIF
ENDIF

IF_ACTION_POINT(19,PLAYER0)
    IF(PLAYER2,FLAG1 == 1)
        SET_TIMER(PLAYER2,TIMER1)
    ENDIF
ENDIF

IF_ACTION_POINT(19,PLAYER0)
    IF(PLAYER3,FLAG1 == 1)
        SET_TIMER(PLAYER3,TIMER1)
    ENDIF
ENDIF

IF(PLAYER_GOOD,DUNGEON_DESTROYED == 0)
    IF(PLAYER_GOOD,TOTAL_CREATURES <= 20)
        IF(PLAYER_GOOD,TIMER1 > 1350)
            NEXT_COMMAND_REUSABLE
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,LAST_STAND,-10,1)
            NEXT_COMMAND_REUSABLE
            SET_TIMER(PLAYER_GOOD,TIMER1)
        ENDIF
    ENDIF
ENDIF

REM The gang, part 2

IF(PLAYER1,TOTAL_CREATURES <= 20)
    IF(PLAYER1,TIMER1 > 450)
        ADD_CREATURE_TO_LEVEL(PLAYER2,DRAGON,22,1,10,0)
        NEXT_COMMAND_REUSABLE
        ADD_CREATURE_TO_LEVEL(PLAYER1,SKELETON,20,1,8,0)
        NEXT_COMMAND_REUSABLE
        SET_TIMER(PLAYER1,TIMER1)
    ENDIF
ENDIF

IF(PLAYER2,TOTAL_CREATURES <= 20)
    IF(PLAYER2,TIMER1 > 650)
        ADD_CREATURE_TO_LEVEL(PLAYER1,SORCEROR,20,1,10,0)
        NEXT_COMMAND_REUSABLE
        ADD_CREATURE_TO_LEVEL(PLAYER2,GHOST,21,1,8,0)
        NEXT_COMMAND_REUSABLE
        SET_TIMER(PLAYER2,TIMER1)
    ENDIF
ENDIF

IF(PLAYER3,TOTAL_CREATURES <= 20)
    IF(PLAYER3,TIMER1 > 950)
ADD_CREATURE_TO_LEVEL(PLAYER3,THIEF,22,1,10,0)
        NEXT_COMMAND_REUSABLE
        ADD_CREATURE_TO_LEVEL(PLAYER3,SPIDER,22,1,8,0)
        NEXT_COMMAND_REUSABLE
        SET_TIMER(PLAYER3,TIMER1)
    ENDIF
ENDIF

IF(PLAYER_GOOD,AVATAR == 0)
    IF(PLAYER_GOOD,FLAG0 == 1)
        REM	QUICK_OBJECTIVE(5,"The enemies of darkness and death have been shown no mercy... as it should be.... well done...",PLAYER0)
		DISPLAY_OBJECTIVE(45,PLAYER0)
        WIN_GAME
    ENDIF
ENDIF

REM -------------------------------------------------------------------------------------------------------------------------------------------

IF(PLAYER1,DUNGEON_DESTROYED == 1)
    LOSE_GAME
ENDIF

IF(PLAYER2,DUNGEON_DESTROYED == 1)
    LOSE_GAME
ENDIF

IF(PLAYER3,DUNGEON_DESTROYED == 1)
    LOSE_GAME
ENDIF

IF(PLAYER0,TOTAL_CREATURES == 0)
    LOSE_GAME
ENDIF
