#textdomain wesnoth-dm
[scenario]
    id=15_Save_the_King
    name= _ "Save the King"
    {MEMOIRS_MAP 15_Save_the_King.map}
    next_scenario=16_Dark_Sky_Over_Weldyn
    {TURNS 33 30 27}
    {DEFAULT_SCHEDULE}

    {INTRO_AND_SCENARIO_MUSIC loyalists.ogg vengeful.ogg}
    {EXTRA_SCENARIO_MUSIC the_dangerous_symphony.ogg}
    {EXTRA_SCENARIO_MUSIC the_city_falls.ogg}
    {EXTRA_SCENARIO_MUSIC northerners.ogg}

    [story]
        [part]
            show_title=yes
            story= _ "Following Delfador, the elves moved to unite with the Wesnothian forces and meet Zorlan head-on..."
            {DM_BIGMAP}
            {KALENZ_STAGE3}
        [/part]
        [part]
            story= _ "but the King was in an unenviable position..."
        [/part]
    [/story]

    #wmllint: validate-off
    [side]
        side=1
        controller=human
        recruit={ELVES}
        {GOLD 175 150 125}
        save_id=Player
        team_name=allies
        user_team_name= _ "Loyalists"
        side_name= _ "Delfador"
        {FLAG_VARIANT long}
        [leader]
            {YOUNG_DELFADOR}
        [/leader]
        [unit]
            {KALENZ}
            placement=leader
        [/unit]
        [unit]
            {CHANTAL}
            placement=leader
        [/unit]
    [/side]

    [side]
        side=2
        controller=ai
        recruit=Heavy Infantryman, Spearman, Bowman, Cavalryman, Horseman, Mage, Royal Guard, Shock Trooper, Swordsman
        {GOLD 600 500 400}
        {INCOME 0 0 0}
        team_name=allies
        user_team_name= _ "Loyalists"
        {FLAG_VARIANT loyalist}
        [leader]
            {GARARD_II}
            facing=nw
        [/leader]
        [ai]
            passive_leader=yes
            [goal]
                name=protect_unit
                [criteria]
                    id="Garard II"
                [/criteria]
                value=20
            [/goal]
            [avoid]
                [not]
                    x,y=14,22
                    radius=5
                [/not]
            [/avoid]
        [/ai]
    [/side]

    [side]
        side=3
        controller=ai
#ifdef EASY
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Pillager, Goblin Knight, Goblin Spearman
#endif
#ifdef NORMAL
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Knight, Orcish Slayer, Goblin Pillager, Goblin Spearman
#endif
#ifdef HARD
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Orcish Warrior, Goblin Knight, Goblin Pillager, Orcish Slayer, Goblin Spearman
#endif
        {GOLD 180 240 300}
        team_name=enemies
        user_team_name= _ "Pillagers"
        {FLAG_VARIANT6 ragged}
        # wmllint: who ZORLAN is Zorlan
        [leader]
            {ZORLAN}
            facing=sw
        [/leader]
    [/side]

    [side]
        side=4
        controller=ai
#ifdef EASY
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Pillager, Goblin Knight, Goblin Spearman
#endif
#ifdef NORMAL
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Knight, Orcish Slayer, Goblin Pillager, Goblin Spearman
#endif
#ifdef HARD
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Orcish Warrior, Goblin Knight, Goblin Pillager, Orcish Slayer, Goblin Spearman
#endif
        {GOLD 80 120 160}
        {INCOME 4 6 8}
        team_name=enemies
        user_team_name= _ "Pillagers"
        {FLAG_VARIANT6 ragged}
        [leader]
            id="T'bhan"
            name=_ "T’bhan"
            type=Orcish Warrior
            facing=ne
        [/leader]
    [/side]

    [side]
        side=5
        controller=ai
#ifdef EASY
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Pillager, Goblin Knight, Goblin Spearman
#endif
#ifdef NORMAL
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Knight, Orcish Slayer, Goblin Pillager, Goblin Spearman
#endif
#ifdef HARD
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Orcish Warrior, Goblin Knight, Goblin Pillager, Orcish Slayer, Goblin Spearman
#endif
        {GOLD 80 120 160}
        {INCOME 4 6 8}
        team_name=enemies
        user_team_name= _ "Pillagers"
        {FLAG_VARIANT6 ragged}
        [leader]
            id=Qgthun
            name=_ "Qgthun"
            type=Orcish Warrior
            facing=nw
        [/leader]
    [/side]

    [side]
        side=6
        controller=ai
#ifdef EASY
        recruit=Troll Whelp
#endif
#ifdef NORMAL
        recruit=Troll Whelp,Troll,Troll Rocklobber
#endif
#ifdef HARD
        recruit=Troll Whelp,Troll,Troll Warrior,Troll Rocklobber
#endif
        {GOLD 120 180 240}
        team_name=enemies
        user_team_name= _ "Pillagers"
        {FLAG_VARIANT6 ragged}
        [leader]
            id=Trgrau
            name=_ "Trgrau"
            type={ON_DIFFICULTY (Troll Hero) (Great Troll) (Great Troll)}
            facing=sw
        [/leader]
    [/side]
    #wmllint: validate-on

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Defeat all enemy leaders"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Kalenz"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Delfador"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Chantal"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Garard II"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

            [gold_carryover]
                bonus=yes
                carryover_percentage=80
            [/gold_carryover]
        [/objectives]
        {RECALL Clogrin}
        {RECALL Droni}
        {RECALL Artos}
        {RECALL Theorsten}
        {RECALL Igler}
        {RECALL Larsin}
        {RECALL Glen}
        {RECALL Aldrin}
        {MODIFY_UNIT (side=1) facing se}
    [/event]

    [event]
        name=start

        [message]
            speaker=Delfador
            message= _ "It appears we have arrived just in time! The King stands at bay, surrounded by the enemy."
        [/message]
        [message]
            speaker=Chantal
            message= _ "I fear we may be too late. This new warlord must have united every orcish tribe north of the Great River. Look at their army, it is vast!"
        [/message]
        [message]
            speaker=Zorlan
            message= _ "Elves! I heard you have been looking for me! But you will save neither the human prince, nor yourselves."
        [/message]
        [message]
            speaker=Kalenz
            message= _ "We must destroy this warlord now, before his power grows any greater!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "Agreed, but we must make haste, for the King is hard-pressed."
        [/message]
    [/event]

    # The king usually takes care of the first wave of orcs by himself.
    # They need a second wave for the player to help with.
    # Since this event uses the player's turn, the orcs will not be
    # able to use their gold until the following turn.
    [event]
        name=turn {ON_DIFFICULTY 10 9 8}
        [gold]
            side=4
            {QUANTITY amount 140 230 320}
        [/gold]
        [gold]
            side=5
            {QUANTITY amount 120 210 300}
        [/gold]
    [/event]

    # Extra help for Garard in case Delf and Kalenz are a bit late but only once
    [event]
        name=moveto
        [filter]
            side=3,4,5,6
            x=12-17
            y=20-24
        [/filter]

        [message]
            speaker=Garard II
            message= _ "The enemy is drawing near. My personal guards must join the fight. We can only hope help arrives soon."
        [/message]
#define TRAITS_STRONG_RESILIENT
    [modifications]
        {TRAIT_STRONG}
        {TRAIT_RESILIENT}
    [/modifications]
#enddef
        [move_unit_fake]
            type=Royal Guard
            side=2
            x=12,12
            y=19,20
        [/move_unit_fake]
        {NAMED_UNIT 2 (Royal Guard) 12 20 Adamar _"Adamar" ({TRAITS_STRONG_RESILIENT})} {FACING sw}
        [move_unit_fake]
            type=Royal Guard
            side=2
            x=16,17
            y=23,24
        [/move_unit_fake]
        {NAMED_UNIT 2 (Royal Guard) 17 24 Mitbreen _"Mitbreen" ({TRAITS_STRONG_RESILIENT})} {FACING sw}
        [move_unit_fake]
            type=Iron Mauler
            side=2
            x=12,12
            y=19,20,21,22,23
        [/move_unit_fake]
        {NAMED_UNIT 2 (Iron Mauler) 12 23 Ronduger _"Ronduger" ({TRAITS_STRONG_RESILIENT})} {FACING sw}
#undef TRAITS_STRONG_RESILIENT
        {SCROLL_TO 12 20} # is this really needed?
        [message]
            speaker=Adamar
            message= _ "For the King!"
        [/message]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Zorlan
        [/filter]
        [message]
            speaker=Zorlan
            message=_ "Argh! It can’t be, beaten by these swine!"
        [/message]
    [/event]

    [event]
        name=victory
        [message]
            speaker=Kalenz
            message= _ "Victory!"
        [/message]
        [message]
            speaker=Garard II
            message= _ "Delfador! And you, elvish friends! The Kingdom of Wesnoth is in your debt today!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "My King, this is Kalenz, High Lord of the Elves."
        [/message]
        [message]
            speaker=Garard II
            message= _ "You will be forever welcome in the court of Wesnoth."
        [/message]
        [message]
            speaker=Kalenz
            message= _ "We look forward to fighting beside you to defeat those threats that remain."
        [/message]
        [message]
            speaker=Delfador
            message= _ "Your Majesty, we have more urgent matters. Leollyn sent me on a mission to find out why the dead are restless. A foul necromancer has opened a portal to the Land of the Dead. It must be closed at all costs, and I am afraid my skills may be insufficient for that task."
        [/message]
        [message]
            speaker=Kalenz
            message= _ "Delfador, our weapons are weak against the undead, but perhaps we have other help to give you. Centuries ago, the great mage Crelanu entrusted to us a book of lore and perilous secrets that took him his entire life to gather."
        [/message]
        [message]
            speaker=Kalenz
            message= _ "Crelanu charged us with guarding this book until someone worthy of it should arrive. We believe you are the one, Delfador. The book may help you find a way to close the portal."
        [/message]
        [message]
            speaker=Delfador
            message= _ "Friends, your words do me greater honor than I perhaps deserve. I am not sure I am worthy of this charge."
        [/message]
        [message]
            speaker=Kalenz
            message= _ "You may have some doubts, but Chantal and I are sure of your quality. But be warned: there is a curse on this book. Crelanu fairly warned us that his arts would bring much woe down upon us. And so it proved, though at the time we had no other choice. The victories you win with it may cost you as dearly."
        [/message]
        [message]
            speaker=Delfador
            message= _ "Curse or no, we must close the portal soon, or else we are all doomed."
        [/message]
        [message]
            speaker=Kalenz
            message= _ "This is a decision you will have to make. If we fight the undead without the book’s help, it will be an honor to fight by your side, no matter what the outcome."
        [/message]
        [message]
            speaker=Delfador
            message= _ "I think I, too, have no choice but to accept the book. I cannot allow the sure death of many humans and elves for fear of the curse."
        [/message]
        [message]
            speaker=Chantal
            message= _ "Then here it is, Delfador. May it help you bring a swift end to the undead menace. And may it cost you less than it has cost us..."
        [/message]
        [message]
            speaker=Delfador
            message= _ "Thank you, friends. May we meet again in happier times. Now I must make haste, for I need to study the book and prepare for battle with the undead."
        [/message]

        {ELVES_DEPART}
    [/event]

    {MEMOIRS_DEATHS}
    # wmllint: unwho GARARD_II
    # wmllint: unwho ZORLAN
[/scenario]
