#textdomain wesnoth-ei

#define SCENARIO_TURN_LIMIT
20 #enddef

[scenario]
    id=06a_Undead_Crossing
    name= _ "Undead Crossing"
    map_file=06a_Undead_Crossing.map
    turns={SCENARIO_TURN_LIMIT}
    next_scenario=07a_Capturing_the_Ogres
    victory_when_enemies_defeated=no

    {SCENARIO_MUSIC       battle.ogg}
    {EXTRA_SCENARIO_MUSIC casualties_of_war.ogg}

    {DEFAULT_SCHEDULE}

    [story]
        [part]
            story=_ "In the west, where the Great River is deep and wide, the few crossings are known by all and heavily guarded. Hoping to evade detection, Gweddry and his band made for one of the numerous eastern fords instead..."
            music=silence.ogg
        [/part]
    [/story]
    {EI_TRACK {JOURNEY_06A_NEW} }

    # wmllint: validate-off
    [side]
        side=1
        controller=human
        {GOLD 180 165 150}
        team_name=good
        user_team_name= _ "Wesnothians"
        {FLAG_VARIANT loyalist}

        # wmllint: recognize Gweddry
        {CHARACTER_STATS_GWEDDRY}
    [/side]
    # wmllint: validate-on

    {STARTING_VILLAGES 1 7}

    [side]
        side=2
        type=Necromancer
        id=Mal-un-Karad
        #po: male
        name= _ "Mal-un-Karad"
        canrecruit=yes
        controller=ai
        [modifications]
            {TRAIT_STRONG}
            {TRAIT_QUICK}
        [/modifications]
        recruit=Vampire Bat,Ghost,Wraith,Walking Corpse,Soulless
        {GOLD 40 120 200}
        {INCOME -3 1 5}
        team_name=undead
        user_team_name=_"Undead"
        {FLAG_VARIANT undead}

        {LOYAL_UNIT 2 ({ON_DIFFICULTY "Walking Corpse" "Skeleton"        "Revenant"})     30 5} {GUARDIAN}
        {LOYAL_UNIT 2 ({ON_DIFFICULTY "Walking Corpse" "Skeleton"        "Revenant"})     22 10} {GUARDIAN}
        {LOYAL_UNIT 2 ({ON_DIFFICULTY "Walking Corpse" "Skeleton Archer" "Bone Shooter"}) 31 10} {GUARDIAN}
    [/side]
    {RECRUIT_UNIT_VARIATIONS 2 "Walking Corpse" serpent,serpent,serpent,serpent}
    {RECRUIT_UNIT_VARIATIONS 2 "Soulless" serpent,serpent,serpent,serpent}
    {LIMIT_CONTEMPORANEOUS_RECRUITS 2 (Vampire Bat) 2}
    {LIMIT_CONTEMPORANEOUS_RECRUITS 2 (Ghost) 3}
    {LIMIT_CONTEMPORANEOUS_RECRUITS 2 (Wraith) 1}
    {STARTING_VILLAGES 2 7}
    {SILENTLY_LIMIT_LEADER_MOVES 2 3}

    # when undead army has been whittled down, pull back to the central island
    [event]
        name=die
        first_time_only=no
        [filter]
            side=2
        [/filter]
        [filter_condition]
            [have_unit]
                side=2
                count={ON_DIFFICULTY 0-6 0-8 0-10}
            [/have_unit]
        [/filter_condition]
        [fire_event]
            name=undead_retreat
        [/fire_event]
    [/event]
    [event]
        name=undead_retreat
        [message]
            speaker=Mal-un-Karad
            message= _ "Fine, you can have the south shore! I’m going to stay nice and safe in my castle."
        [/message]
        [set_recruit]
            side=2
            recruit=Skeleton,Skeleton Archer,Revenant,Bone Shooter
        [/set_recruit]
        {RESET_SIDE_AI (2) defensive -2 2}

        {MODIFY_SIDE_AI (2) ({GOAL_LOCATION 99 (x,y=26,10)})}
        {MODIFY_SIDE_AI (2) ({GOAL_LOCATION 99 (x,y=28,9)})}
        {MODIFY_SIDE_AI (2) ({GOAL_LOCATION 99 (x,y=29,9)})}
        {MODIFY_SIDE_AI (2) ({GOAL_LOCATION 99 (x,y=26,8)})}
        {MODIFY_SIDE_AI (2) ({GOAL_LOCATION 55 (x,y=27,8)})}
    [/event]

    [side]
        no_leader=yes
        side=3
        controller=null
        team_name=undead
        user_team_name=_"Monsters"
        hidden=yes
    [/side]

    [side]
        no_leader=yes
        side=4
        controller=null
        team_name=good,undead
        user_team_name=_"Northern Alliance"
        hidden=yes
        [ai]
            ai_algorithm=idle_ai
        [/ai]
    [/side]

    [event]
        name=prestart

        [objectives]
            side=1
            [objective]
                description= _ "Defeat Mal-un-Karad"
                condition=win
                [show_if]
                    [have_unit]
                        id=Mal-un-Karad
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Rescue Dolburras before he drowns"
                condition=win
                {BONUS_OBJECTIVE_CAPTION}
                [show_if]
                    [have_unit]
                        id=Dolburras
                        side=4
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Death of Gweddry, Dacyn, or Owaec"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

            [note]
                description= _ "Dolburras will take damage every turn until freed."
                [show_if]
                    [have_unit]
                        id=Dolburras
                        side=4
                    [/have_unit]
                [/show_if]
            [/note]

            [gold_carryover]
                bonus=yes
                carryover_percentage=40
            [/gold_carryover]
        [/objectives]

        [unit]
            #po: male
            name= _ "Dolburras"
            id=Dolburras
            side=4
            type=Dwarvish Steelclad
            x,y=18,6
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]
        [item]
            x,y=18,6
            halo=items/cage.png
        [/item]

        {NAMED_LOYAL_UNIT 2 (Banebow) 19 6 "dolburras_jailer" ""}
        [+unit]
            max_moves=0
        [/unit]
    [/event]

    [event]
        name=start
        {RECALL Dacyn}
        {RECALL Owaec}
        {RECALL Addogin}
        {RECALL Terraent}
        {RECALL_XY (Hahid al-Ali) 8 21} # for elixir
        [message]
            speaker=Dacyn
            message= _ "We have done well to avoid conflict with the undead thus far. It is time to turn northward, toward our goal."
        [/message]
        [message]
            speaker=Owaec
            message= _ "You still have yet to explain more about this goal."
        [/message]
        [message]
            speaker=Gweddry
            message= _ "Wait, look, a small force of undead have already fortified this ford. We will have to fight them to cross the Great River."
        [/message]
        [message]
            speaker=Dolburras
            #po: he's being held captive by a Banebow
            message= _ "Let me out ’o this cage ye bag-o-bones! When the Alliance hears abo— <b>glug</b>"
        [/message]
        [fire_event]
            name=side 1 turn end
        [/fire_event]
        [message]
            speaker=Mal-un-Karad
            message= _ "Hahahaha! This dwarf is too short to keep his head out of the water. I wonder how long he’ll last?"
        [/message]
        [message]
            speaker=Owaec
            message= _ "The undead are torturing that dwarf for sport! This shall not stand; we must rescue him before he drowns!"
        [/message]

        [message]
            speaker=Hahid al-Ali
            message= _ "Ho ho, you know what you need? My patented* elixir of water breathing! <span color='#BCB088' size='x-small'><i>*not patented</i></span>"
        [/message]
        [message]
            speaker=Hahid al-Ali
            message= _ "One drink from this shimmering blue vial and you’ll move at full speed* through swamps and shallow water! <span color='#BCB088' size='x-small'><i>*less effective on cavalry</i></span>"
        [/message]
        [event]
            name=buy_elixir
            [gold]
                side=1
                amount=-10
            [/gold]
            [sound]
                name=gold.ogg
            [/sound]
            [message]
                speaker=Hahid al-Ali
                message= _ "Pleasure doing business with you!"
            [/message]
            {ELIXIR_OF_WATER_BREATHING 9 22}
        [/event]
        [event]
            name=ignore_elixir
            [message]
                speaker=Hahid al-Ali
                message= _ "Suit yourself; more for me!"
            [/message]
            {GIVE_WATER_BREATHING 8 21 ()}
        [/event]
        [message]
            speaker=Hahid al-Ali
            message= _ "Supplies are limited so <span strikethrough='true'>call</span> buy now! <i>(elixirs only last for 1 scenario)</i>"
            [option]
                label= _ "Buy the elixir (10 gold)."
                [command]
                    [do_command]
                        [fire_event]
                            raise=buy_elixir
                        [/fire_event]
                    [/do_command]
                [/command]
            [/option]
            [option]
                label= _ "Leave the elixir for Hahid."
                [command]
                    [do_command]
                        [fire_event]
                            raise=ignore_elixir
                        [/fire_event]
                    [/do_command]
                [/command]
            [/option]
        [/message]
    [/event]

    [event]
        name=side 1 turn 1 end
        [message]
            speaker=Mal-un-Karad
            message= _ "I don’t know how you Wesnothians got here, but don’t even think about crossing here unless you want to become fish bait!"
        [/message]
    [/event]

    # dwarf takes damage every turn
    [event]
        name=side 1 turn end
        first_time_only=no
        [if]
            {VARIABLE_CONDITIONAL dolburras_rescued not_equals yes}
            [then]
                [harm_unit]
                    [filter]
                        id=Dolburras
                    [/filter]

                    amount={ON_DIFFICULTY 4 4 4} # rest healing is disabled
                    animate=yes
                    fire_event=yes
                [/harm_unit]
                {MODIFY_UNIT id=Dolburras status.slowed yes}
                {MODIFY_UNIT id=Dolburras resting no}
            [/then]
        [/if]
    [/event]

    [event]
        name=last breath

        [filter]
            id=Dolburras
        [/filter]

        [if]
            {VARIABLE_CONDITIONAL dolburras_rescued not_equals yes}
            [then]
                [message]
                    speaker=Dolburras
                    message= _ "Glug... glug..."
                [/message]
                [remove_item]
                    x,y=18,6
                [/remove_item]
                {MODIFY_UNIT (type=Banebow) max_moves 5}

                # kill immediately so we can spawn corpse
                {KILL id=Dolburras ANIMATE=yes FIRE_EVENT=yes}
                [sound]
                    name=zombie-attack.wav
                [/sound]

                {GENERIC_UNIT 2 (Walking Corpse) 18 6} {VARIATION dwarf}

                [message]
                    speaker=Owaec
                    message= _ "I have failed in my duty to protect the helpless. I weep at his passing."
                [/message]
            [/then]
        [/if]
    [/event]

    # dwarf is rescued
    [event]
        name=die

        [filter]
            id=dolburras_jailer
        [/filter]

        [if]
            [have_unit]
                id=Dolburras
            [/have_unit]

            [then]
                [remove_item]
                    x,y=18,6
                [/remove_item]
                {VARIABLE dolburras_rescued yes}
                [message]
                    speaker=Dolburras
                    #po: "Many thanks to you! Feels go to be finally breathing properly again."
                    message= _ "Many thanks ta ye! Feels good ta be finally breathin’ proper again."
                [/message]
                [message]
                    speaker=Gweddry
                    message= _ "How did you come to be captured by these undead?"
                [/message]
                [message]
                    speaker=Dolburras
                    #po: "Ran into a whole blasted army of them marching from the Swamp of Dread. I think they're headed for Knalga! Someone ought to invade them for a change."
                    message= _ "Ran into a whole blasted army of ’em marchin’ from the Swamp o’ Dread. I think they be headed for Knalga! Someone oughta invade them for a change."
                [/message]
                [message]
                    speaker=Owaec
                    message= _ "By the Clans! Do these undead mean to conquer all the world?"
                [/message]
                [message]
                    speaker=Gweddry
                    message= _ "Dolburras, we are men of the King of Wesnoth, seeking the power to destroy these foul undead. Will you join us in our quest?"
                [/message]
                [message]
                    speaker=Dolburras
                    #po: "Can't hardly go back to Knalga with all of the undead about! Yes, I'll join you."
                    message= _ "Kinna hardly go back ta Knalga with all them undead about! Aye, I’ll join ye."
                [/message]
                {MODIFY_UNIT (side=4) side 1}
            [/then]
        [/if]
    [/event]

    [event]
        name=spawn creatures

        [message]
            speaker=Mal-un-Karad
            # po: "Wake" doesn’t mean "raise undead" here. The reinforcements are sea creatures, they're alive but hidden underwater.
            message= _ "Time to wake my reinforcements!"
            scroll=yes
        [/message]
        [animate_unit]
            [filter]
                id=Mal-un-Karad
            [/filter]
            flag=attack
            hits=no
            [primary_attack]
                range=ranged
                type=arcane
            [/primary_attack]
        [/animate_unit]

        [modify_side]
            side=3
            controller=ai
            hidden=no
        [/modify_side]
        {RESET_SIDE_AI (3) defensive 0.8 0.25}
        {MODIFY_SIDE_AI (3) ({GOAL_LOCATION 99 (x,y=18-34,11-13)})}

        [sound]
            name=squishy-hit.wav
        [/sound]
        {GENERIC_UNIT 3 (Caribe) 30 8} {ANIMATE}
        [sound]
            name=squishy-hit.wav
        [/sound]
        {GENERIC_UNIT 3 (Caribe) 31 9} {ANIMATE}
        [sound]
            name=squishy-hit.wav
        [/sound]
        {GENERIC_UNIT 3 (Nibbler) 32 8} {ANIMATE}
#ifndef EASY
        [sound]
            name=squishy-hit.wav
        [/sound]
        {GENERIC_UNIT 3 (Hunter Caribe) 27 9} {ANIMATE}
        [sound]
            name=squishy-hit.wav
        [/sound]
        {GENERIC_UNIT 3 (Nibbler) 26 9} {ANIMATE}

        [sound]
            name=squishy-hit.wav
        [/sound]
        {GENERIC_UNIT 3 (Caribe) 24 6} {ANIMATE}
        [sound]
            name=squishy-hit.wav
        [/sound]
        {GENERIC_UNIT 3 (Nibbler) 23 7} {ANIMATE}
        [sound]
            name=squishy-hit.wav
        [/sound]
        {GENERIC_UNIT 3 (Nibbler) 24 5} {ANIMATE}
#endif
#ifdef HARD
        [sound]
            name=squishy-hit.wav
        [/sound]
        {GENERIC_UNIT 3 (Hunter Caribe) 28 6} {ANIMATE}
        [sound]
            name=squishy-hit.wav
        [/sound]
        {GENERIC_UNIT 3 (Caribe) 27 6} {ANIMATE}
        [sound]
            name=squishy-hit.wav
        [/sound]
        {GENERIC_UNIT 3 (Nibbler) 29 6} {ANIMATE}
        [sound]
            name=squishy-hit.wav
        [/sound]
        {GENERIC_UNIT 3 (Nibbler) 28 5 } {ANIMATE}
#endif

        [message]
            speaker=Gweddry
            message= _ "In addition to summoning undead, this sorcerer has learned to command swarms of carnivorous fish!"
        [/message]
        [message]
            speaker=Dacyn
            message= _ "A clever plan. The fish gnaw away flesh, leaving the skeletons ready for reanimation. They will make our crossing more difficult."
        [/message]
    [/event]

    [event]
        name=turn 8
        [fire_event]
            name=spawn creatures
        [/fire_event]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            [filter_location]
                [filter]
                    id=Mal-un-Karad
                [/filter]

                radius=3
            [/filter_location]
        [/filter]
        [fire_event]
            name=spawn creatures
        [/fire_event]
    [/event]

    [event]
        name=last breath

        [filter]
            id=Mal-un-Karad
        [/filter]

        [message]
            speaker=unit
            message= _ "No! I thought I’d be safe here..."
        [/message]
    [/event]

    # victory is only when Dolburras is saved/dead and Mal-un-Karad is dead
    [event]
        name=die

        [filter]
            id=Mal-un-Karad
        [/filter]

        [if]
            [have_unit]
                x,y=18,6
                id=Dolburras
                side=4
            [/have_unit]

            [then]
                [set_achievement]
                    content_for=eastern_invasion
                    id=ei_S06a
                [/set_achievement]
                # only get the achievement if Dolburras is still alive when you kill Mal-un-Karad
                [show_objectives]
                [/show_objectives]
            [/then]
            [else]
                [fire_event]
                    name=victory
                [/fire_event]
            [/else]
        [/if]
    [/event]
    [event]
        name=die

        [filter]
            id=Dolburras
        [/filter]

        [if]
            [have_unit]
                id=Mal-un-Karad
            [/have_unit]

            [then]
                [show_objectives]
                [/show_objectives]
            [/then]
            [else]
                [fire_event]
                    name=victory
                [/fire_event]
            [/else]
        [/if]
    [/event]
    [event]
        name=die

        [filter]
            id=dolburras_jailer
        [/filter]

        [if]
            [have_unit]
                id=Mal-un-Karad
            [/have_unit]

            [then]
                [show_objectives]
                [/show_objectives]
            [/then]
            [else]
                [fire_event]
                    name=victory
                [/fire_event]
            [/else]
        [/if]
    [/event]

    [event]
        name=victory
        [message]
            speaker=Dacyn
            message= _ "If we intend to save Wesnoth, we must press onward into the mountains. Let us be off."
        [/message]
        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]

    [event]
        name=side 1 turn {SCENARIO_TURN_LIMIT} end
        {GENERIC_UNIT 2 (Spectre) 47 23} {ANIMATE}
        {GENERIC_UNIT 2 (Ghost)   45 23} {ANIMATE}
        {GENERIC_UNIT 2 (Ghost)   44 23} {ANIMATE}
        {GENERIC_UNIT 2 (Wraith)  45 24} {ANIMATE}
        {GENERIC_UNIT 2 (Spectre) 47 21} {ANIMATE}
        {GENERIC_UNIT 2 (Wraith)  46 21} {ANIMATE}
        {GENERIC_UNIT 2 (Ghost)   42 24} {ANIMATE}
        {NAMED_UNIT   2 (Dark Sorcerer) 47 24 "Mel Wylyn" _"Mel Wylyn" ()} {ANIMATE}
        [+unit]
            gender=female
        [/unit]

        [message]
            speaker=Mal-un-Karad
            #po: male Necromancer to female Dark Sorcerer
            message= _ "What took you so long? We were supposed to change shifts days ago!"
        [/message]
        [message]
            speaker=Mel Wylyn
            #po: female Dark Sorcerer to male Necromancer
            message= _ "Aw, I’ve missed out on the fun! But look at it this way, now they stand no chance against the two of us."
        [/message]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    {FOREIGN_DEFEAT}

    {HERODEATH_GWEDDRY}
    {HERODEATH_DACYN}
    {HERODEATH_OWAEC}
    {HERODEATH_ADDOGIN}
    {HERODEATH_TERRAENT}
    {HERODEATH_GRUG}
    {HERODEATH_DOLBURRAS}
    {HERODEATH_HAHID}
[/scenario]

#undef SCENARIO_TURN_LIMIT
