#textdomain wesnoth-ei
#define SCENARIO_TURN_LIMIT
15 #enddef
[scenario]
    id=07b_Ogre_Crossing
    name= _ "Ogre Crossing"
    map_file=07b_Ogre_Crossing.map
    turns={SCENARIO_TURN_LIMIT}
    next_scenario=08_Xenophobia

    {DEFAULT_SCHEDULE}

    {SCENARIO_MUSIC breaking_the_chains.ogg}

    [story]
        [part]
            #po: Delfador's Memoirs was around 160 years ago, DiD was around 240 years ago.
            story=_ "The Ford of Parthyn is second only to Abez in its notoriety. It was here where Iliah-Malal’s ghostly army first wrought its terror, only to be routed by the legendary Delfador. It was here where Malin Keshar cast aside his humanity and began delving into the dark arts. And it was here where Gweddry and his men attempted their escape from Wesnoth and Mal-Ravanal’s undead hordes into the wild northlands."
            music=silence.ogg
            {EI_BIGMAP}
        [/part]
    [/story]
    {EI_TRACK {JOURNEY_07B_NEW} }

    # wmllint: validate-off
    [side]
        side=1
        controller=human
        {GOLD 160 150 140}
        team_name=good
        user_team_name= _ "Wesnothians"
        {FLAG_VARIANT loyalist}
        # wmllint: recognize Gweddry
        {CHARACTER_STATS_GWEDDRY}
    [/side]
    # wmllint: validate-on

    [side]
        type=Ogre
        id=Grug
        name= _ "Grug"
        unrenamable=yes
        side=2
        canrecruit=yes
        facing=sw
        controller=ai
        recruit=Young Ogre,Ogre
        team_name=good
        user_team_name=_"Ogres"
        gold=0
        income=-2
        [modifications]
            {TRAIT_QUICK}
            [object]
                duration=forever
                [effect]
                    apply_to=new_advancement

                    [filter]
                        type=Great Ogre
                    [/filter]

                    replace=yes
                    types=Ancient Ogre
                [/effect]
            [/object]
        [/modifications]
        [ai]
            grouping=no
            [goal]
                name=target
                [criteria]
                    side=3
                [/criteria]
                value=100
            [/goal]
            recruitment_pattern=fighter
            {NO_SCOUTS}
        [/ai]

        # scale with difficulty, so that we die more-or-less equally fast
        {GENERIC_UNIT 2 (Young Ogre) 28 2} {GUARDIAN}
        {GENERIC_UNIT 2 (Young Ogre) 29 6} {GUARDIAN}
        {GENERIC_UNIT 2 (Young Ogre) 28 12}
        {GENERIC_UNIT 2 (Young Ogre) 27 10}
#ifndef EASY
        {GENERIC_UNIT 2 (Young Ogre) 27 2}
        {GENERIC_UNIT 2 (Young Ogre) 23 7}
#endif
#ifdef HARD
        {GENERIC_UNIT 2 (Ogre) 24 5}
#endif
    [/side]
    {SILENTLY_LIMIT_MOVES 2 (side=2) 4} # so they're a little less aggressive
    {SILENTLY_LIMIT_LEADER_MOVES 2 1}

    [side]
        side=3
        type=Saurian Ambusher
        id=Izziasch
        name= _ "Izziasch"
        canrecruit=yes
        [modifications]
            {TRAIT_QUICK}
            {TRAIT_INTELLIGENT}
        [/modifications]
        controller=ai
        recruit=Saurian Skirmisher,Saurian Ambusher,Saurian Augur
        team_name=saurians
        user_team_name=_"Saurians"
        {GOLD 20 60 100}
        {INCOME 5 12 19}
        {FLAG_VARIANT6 ragged}

        {GENERIC_UNIT 3 (Saurian Skirmisher) 8 8}
        {GENERIC_UNIT 3 (Saurian Ambusher) 6 5}
        {GENERIC_UNIT 3 (Saurian Augur) 5 5}

        {GENERIC_UNIT 3 (Nibbler) 13 16} # not intended to be a real threat, but they do make it risky to run 1 guy ahead all alone
        {GENERIC_UNIT 3 (Nibbler) 16 13}
        {GENERIC_UNIT 3 (Nibbler) 18 14}
    [/side]
    {LIMIT_CONTEMPORANEOUS_RECRUITS 3 "Saurian Ambusher" 2}
    {STARTING_VILLAGES_AREA 3 5 6 3}
    {SILENTLY_LIMIT_LEADER_MOVES 3 1}
    [event]
        name=prestart
        [micro_ai]
            side=3
            ai_type=zone_guardian
            action=add
            [filter]
                type=Nibbler,Caribe,Hunter Caribe
            [/filter]
            [filter_location]
                x=8-22
                y=14-16
            [/filter_location]
        [/micro_ai]
    [/event]

#define UNDEAD_AI_STUFF
    no_leader=yes
    controller=ai
    recruit="" # no recruits by default
    hidden=yes
    gold=0
    income=-2
    [ai]
        aggression=0.9
        grouping=no
        {NO_SCOUTS}
    [/ai]
    team_name=undead
    user_team_name=_"Undead"
    {FLAG_VARIANT undead}
#enddef
    [side]
        side=4
        {UNDEAD_AI_STUFF}
    [/side]
    [side]
        color=teal
        side=5
        {UNDEAD_AI_STUFF}
    [/side]
    {SILENTLY_LIMIT_LEADER_MOVES 5 3}
    [side]
        color=brightorange
        side=6
        {UNDEAD_AI_STUFF}
    [/side]
    {SILENTLY_LIMIT_LEADER_MOVES 6 3}

    [side]
        color=brown
        side=7
        team_name=good
        controller=ai
        hidden=yes
        no_leader=yes
    [/side]

    [event]
        name=prestart

        {SET_LABEL 12 23 ( _ "Parthyn Guardpost")}
        {PLACE_IMAGE scenery/gore-3.png 11 23}
        {PLACE_IMAGE scenery/blood-trail-1.png 15 24}

        [objectives]
            side=1
            [objective]
                description= _ "Defeat Izziasch"
                condition=win
            [/objective]
            [objective]
                description= _ "Reach the north shore before Grug dies"
                condition=win
                {BONUS_OBJECTIVE_CAPTION}
                [show_if]
                    [have_unit]
                        id=Grug
                        side=2
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Death of Gweddry, Dacyn, or Owaec"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

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

    [event]
        name=start
        {RECALL_XY (Dacyn) 22 22}
        {RECALL_XY (Owaec) 22 23}
        {RECALL_XY (Addogin) 23 22}
        {RECALL_XY (Hahid al-Ali) 23 22}
        {RECALL_XY (Terraent) 23 22}

        #
        # if any undead leaders are alive, Gweddry warns the player
        #
        [if]
            {VARIABLE_CONDITIONAL ghast_leader.length greater_than 0}
            [or]
                {VARIABLE_CONDITIONAL Mal_Talar.length    greater_than 0}
            [/or]

            [or]
                {VARIABLE_CONDITIONAL Mal_Mana.length     greater_than 0}
            [/or]

            [or]
                {VARIABLE_CONDITIONAL Naken_alvak.length  greater_than 0}
            [/or]

            [then]
                [message]
                    speaker=Gweddry
                    message= _ "And so we come to the Great River, northern border of Wesnoth. It will take some time for our men to cross; the undead will doubtless send their forces to harry us."
                [/message]
            [/then]

            [else]
                [message]
                    speaker=Gweddry
                    #po: the player killed all four undead leaders during S06b
                    message= _ "And so we come to the Great River, northern border of Wesnoth. It will take some time for our men to cross, but fortunately we are not being pursued."
                [/message]
            [/else]
        [/if]

        #
        # introduce the ogres
        #
        {SCROLL_TO 99 0}
        [message]
            speaker=Owaec
            #po: This is the first time the protagonists have seen ogres; the routes through the campaign go through exactly one of S07a or S07b.
            message= _ "Lo, on yonder shore lies a camp of ogres! I’ve heard them to be dimwitted, but friendly enough."
            scroll=no
        [/message]
        [message]
            speaker=Dacyn
            message= _ "<span size='small'><i>Not unlike yourself?</i></span> Ogres have served the Crown in the past. Perhaps these ones can help us, either willingly or as slaves. But those saurians will definitely attack before that happens."
        [/message]
        [message]
            speaker=Grug
            message= _ "Lizard, Grug say leave!"
        [/message]
        [message]
            speaker=Izziasch
            message= _ "Get out of my way! There are ssskeletons in my ssswamp... we’re leaving and you sshould too."
        [/message]
        [message]
            speaker=Grug
            message= _ "Lizard dumb! You die now!"
        [/message]
        [message]
            speaker=Gweddry
            message= _ "If we can reach the ogres in time, we may be able to convince them to aid us. But first we need to cross the river."
        [/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!"
        [/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 22 21}
        [/event]
        [event]
            name=ignore_elixir
            [message]
                speaker=Hahid al-Ali
                message= _ "Suit yourself; more for me!"
            [/message]
            {GIVE_WATER_BREATHING 23 22 ()}
        [/event]
        [message]
            speaker=Hahid al-Ali
            message= _ "Supplies are limited so <span strikethrough='true'>call now</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]

    #
    # Yannic brings a plague staff
    #
    [event]
        name=side 1 turn end

        [filter_condition]
            {VARIABLE_CONDITIONAL Yannic.length greater_than 0}
        [/filter_condition]

        [move_unit_fake]
            x=10,12,18,20,20
            y=35,32,31,29,25
            side=7
            type=Horseman
        [/move_unit_fake]
        {NAMED_NOTRAIT_UNIT 7 (Horseman) 20 25 "Tarek" _"Tarek"} {FACING ne} # reappears in S16
        [+unit]
            [modifications]
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]
        [+unit]
            [modifications]
                {TRAIT_QUICK}
            [/modifications]
        [/unit]

        [message]
            speaker=Tarek
            #po: It’s a plague staff, giving both a plague attack and the ability to recruit animal walking corpses, but not human walking corpses.
            #po: The speaker is a horseman, a unit type that’s always male.
            message= _ "Hail, Owaec and company! We retreat from Soradoc, but Yannic sent me to bring a prize we took from one of the necromancers you slew. The temple healers have blessed it so that it may be used safely."
        [/message]
        [message]
            speaker=Dacyn
            #po: About the plague staff.
            message= _ "Fascinating... I’ve never had the chance to examine one of these up close before."
        [/message]
        [message]
            speaker=Owaec
            #po: Speaking to Tarek, a male horseman, about the plague staff.
            message= _ "Our thanks! You are a fair rider, yet you bring a foul boon. I will not wield such a dark artifact, though I shall not begrudge its use by my companions."
        [/message]
        {PLACE_ITEM_PLAGUE_STAFF 20 25}

        {KILL id=Tarek}
        [move_unit_fake]
            x=20,20,18,12,10
            y=25,29,31,32,35
            side=7
            type=Horseman
        [/move_unit_fake]
    [/event]

    [event]
        name=scary_music
        {INCIDENTAL_MUSIC cry_from_elensefar.ogg}
    [/event]

    #--------------------
    # UNDEAD FIRST WAVE
    #--------------------
    # let them move (barely) and attack, since they're far away from gweddry and we want to disincentivize spawncamping
    [event]
        name=side 4 turn 2

        # spawn the ghast leader
        [if]
            {VARIABLE_CONDITIONAL ghast_leader.length greater_than 0}
            [then]
                {GENERIC_UNIT 4 {ON_DIFFICULTY "Walking Corpse" "Soulless" "Soulless"  } 9 35}  {TEAM_COLOR_OVERRIDE x,y=9,35 green}  {MOVE_UNIT x,y=9,35 11 34}
                {GENERIC_UNIT 4 {ON_DIFFICULTY "Soulless"       "Ghoul"    "Ghoul"     } 9 35}  {TEAM_COLOR_OVERRIDE x,y=9,35 green}  {MOVE_UNIT x,y=9,35 10 34}
                {GENERIC_UNIT 4 {ON_DIFFICULTY "Walking Corpse" "Soulless" "Soulless"  } 9 35}  {TEAM_COLOR_OVERRIDE x,y=9,35 green}  {MOVE_UNIT x,y=9,35 11 33}
                {GENERIC_UNIT 4 {ON_DIFFICULTY "Ghoul"          "Ghoul"    "Necrophage"} 9 35}  {TEAM_COLOR_OVERRIDE x,y=9,35 green}  {MOVE_UNIT x,y=9,35 10 31}
                {GENERIC_UNIT 4 {ON_DIFFICULTY "Soulless"       "Soulless" "Soulless"  } 9 35}  {TEAM_COLOR_OVERRIDE x,y=9,35 green}  {MOVE_UNIT x,y=9,35  9 31}
                {GENERIC_UNIT 4 {ON_DIFFICULTY "Ghoul"          "Ghoul"    "Necrophage"} 9 35}  {TEAM_COLOR_OVERRIDE x,y=9,35 green}  {MOVE_UNIT x,y=9,35  8 33}

                {UNSTORE_AND_RECALL ghast_leader ghast_leader 9 35}
                {TEAM_COLOR_OVERRIDE x,y=9,35 green}
                [modify_unit]
                    [filter]
                        id=ghast_leader
                    [/filter]

                    side=4
                    canrecruit=no
                    [object]
                        [effect]
                            apply_to=overlay
                            add=misc/leader-crown.png
                        [/effect]
                    [/object]
                    max_hitpoints=71 # up from 65; we can imagine he fed on some of yannic's soldiers
                    hitpoints=71
                [/modify_unit]

                [message]
                    speaker=ghast_leader
                    message= _ "Gruhhhh...."
                [/message]
                [fire_event]
                    name=scary_music
                [/fire_event]
            [/then]
        [/if]

        # spawn the fleshy leader
        [if]
            {VARIABLE_CONDITIONAL Mal_Talar.length greater_than 0}
            [then]
                {GENERIC_UNIT 4 {ON_DIFFICULTY "Walking Corpse" "Dark Adept" "Dark Adept"} 22 35}  {TEAM_COLOR_OVERRIDE x,y=22,35 purple}  {MOVE_UNIT x,y=22,35 24 34}
                {GENERIC_UNIT 4 {ON_DIFFICULTY "Soulless"       "Ghoul"      "Ghoul"     } 22 35}  {TEAM_COLOR_OVERRIDE x,y=22,35 purple}  {MOVE_UNIT x,y=22,35 24 33}
                {GENERIC_UNIT 4 {ON_DIFFICULTY "Walking Corpse" "Soulless"   "Soulless"  } 22 35}  {TEAM_COLOR_OVERRIDE x,y=22,35 purple}  {MOVE_UNIT x,y=22,35 23 34}
                {GENERIC_UNIT 4 {ON_DIFFICULTY "Soulless"       "Soulless"   "Soulless"  } 22 35}  {TEAM_COLOR_OVERRIDE x,y=22,35 purple}  {MOVE_UNIT x,y=22,35 21 33}
                {GENERIC_UNIT 4 {ON_DIFFICULTY "Walking Corpse" "Dark Adept" "Dark Adept"} 22 35}  {TEAM_COLOR_OVERRIDE x,y=22,35 purple}  {MOVE_UNIT x,y=22,35 20 33}
                {GENERIC_UNIT 4 {ON_DIFFICULTY "Dark Adept"     "Dark Adept" "Dark Adept"} 22 35}  {TEAM_COLOR_OVERRIDE x,y=22,35 purple}  {MOVE_UNIT x,y=22,35 21 35}

                {UNSTORE_AND_RECALL Mal_Talar Mal-Talar 22 35}
                {TEAM_COLOR_OVERRIDE x,y=22,35 purple}
                [modify_unit]
                    [filter]
                        id=Mal-Talar
                    [/filter]

                    side=4
                    canrecruit=no # he should charge straight in
                    [object]
                        [effect]
                            apply_to=overlay
                            add=misc/leader-crown.png
                        [/effect]
                    [/object]
                [/modify_unit]
                [if]
                    {VARIABLE_CONDITIONAL talar_dead not_equals yes}
                    [then]
                        [message]
                            speaker="Mal-Talar"
                            #po: This is a reference to S01 and S02.
                            #po: Because of renaming fallbacks, this line must fit both:
                            #po: "Mal-Talar stayed outside the tunnel entrance", and
                            #po: "Mal-Talar was the main pursuer in S02".
                            message= _ "You won’t escape me again! This time there are no tunnels for you to hide in!"
                        [/message]
                    [/then]

                    [else]
                        [message]
                            speaker="Mal-Talar"
                            #po: Name visible to the player is "Mal-Bakral", because Mal-Talar died in S01
                            #po: The line must fit even if the pursuer in S02 was also renamed "Mal-Bakral"
                            message= _ "There is no escape from me!"
                        [/message]
                    [/else]
                [/if]
                [fire_event]
                    name=scary_music
                [/fire_event]
            [/then]
        [/if]

        # Gweddry explains whether there will be more undead or not
        [if]
            [have_unit]
                side=4
            [/have_unit]

            [then]
                [if]
                    {VARIABLE_CONDITIONAL Mal_Mana.length    greater_than 0}
                    [or]
                        {VARIABLE_CONDITIONAL Naken_alvak.length greater_than 0}
                    [/or]

                    [then]
                        [message]
                            speaker=Gweddry
                            message= _ "The first of our pursuers have arrived! We must make haste to cross before more dangerous undead arrive."
                        [/message]
                    [/then]

                    [else]
                        [message]
                            speaker=Gweddry
                            message= _ "Our undead pursuers have arrived! Fortunately, their other leaders have been defeated. This is all we will have to face."
                        [/message]
                    [/else]
                [/if]
            [/then]
        [/if]

        {CLEAR_VARIABLE ghast_leader}
        {CLEAR_VARIABLE Mal_Talar}

        # let them attack to prevent spawncamping, but limit movement
        {VARIABLE limit_moves_4 yes}
    [/event]
    [event]
        name=side 4 turn refresh

        [filter_condition]
            {VARIABLE_CONDITIONAL limit_moves_4 equals yes}
        [/filter_condition]

        {MODIFY_UNIT side=4 moves 2}
        {CLEAR_VARIABLE limit_moves_4}
    [/event]

    #--------------------
    # UNDEAD SECOND WAVE
    #--------------------
    # let them move (barely) and attack, since they're far away from gweddry and we want to disincentivize spawncamping
    [event]
        name=side 4 turn 6

        # spawn the chocobone leader
        [if]
            {VARIABLE_CONDITIONAL Naken_alvak.length greater_than 0}
            [then]
                {GENERIC_UNIT 6 {ON_DIFFICULTY "Chocobone"  "Chocobone"  "Chocobone" } 9 35}            {MOVE_UNIT x,y=9,35 11 34}
                {GENERIC_UNIT 6 {ON_DIFFICULTY "Banebow"    "Banebow"    "Banebow"   } 9 35} {GUARDIAN} {MOVE_UNIT x,y=9,35 10 34}
                {GENERIC_UNIT 6 {ON_DIFFICULTY "Deathblade" "Chocobone"  "Chocobone" } 9 35} {GUARDIAN} {MOVE_UNIT x,y=9,35 11 33}
                {GENERIC_UNIT 6 {ON_DIFFICULTY "Skeleton"   "Deathblade" "Deathblade"} 9 35} {GUARDIAN} {MOVE_UNIT x,y=9,35 10 31}
                {GENERIC_UNIT 6 {ON_DIFFICULTY "Skeleton"   "Chocobone"  "Chocobone" } 9 35}            {MOVE_UNIT x,y=9,35  9 31}
                {GENERIC_UNIT 6 {ON_DIFFICULTY "Revenant"   "Revenant"   "Revenant"  } 9 35} {GUARDIAN} {MOVE_UNIT x,y=9,35  8 34}

                {UNSTORE_AND_RECALL Naken_alvak Naken-alvak 10 35}
                [set_extra_recruit]
                    id=Naken-alvak
                    extra_recruit=Deathblade,Chocobone
                [/set_extra_recruit]
                [modify_side]
                    side=6
                    gold=50
                    income={ON_DIFFICULTY 5 12 19}
                    hidden=no
                [/modify_side]
                [delay]
                    time=150
                [/delay]

                {MODIFY_TERRAIN Ker  10  35}
                [redraw]
                [/redraw]

                [delay]
                    time=150
                [/delay]

                {MODIFY_TERRAIN Cer  10  36}
                [redraw]
                [/redraw]

                [delay]
                    time=150
                [/delay]

                {MODIFY_TERRAIN Cer  11  36}
                [redraw]
                [/redraw]

                [delay]
                    time=150
                [/delay]

                {MODIFY_TERRAIN Cer  11  35}
                [redraw]
                [/redraw]

                [message]
                    speaker=Naken-alvak
                    message= _ "Found you... Bleed you..."
                [/message]
                [fire_event]
                    name=scary_music
                [/fire_event]
            [/then]
        [/if]

        # spawn the bats leader
        [if]
            {VARIABLE_CONDITIONAL Mal_Mana.length greater_than 0}
            [then]
                {GENERIC_UNIT 5 {ON_DIFFICULTY "Vampire Bat" "Vampire Bat" "Vampire Bat"} 22 35}            {MOVE_UNIT x,y=22,35 24 34}
                {GENERIC_UNIT 5 {ON_DIFFICULTY "Dread Bat"   "Dread Bat"   "Dread Bat"  } 22 35} {GUARDIAN} {MOVE_UNIT x,y=22,35 24 33}
                {GENERIC_UNIT 5 {ON_DIFFICULTY "Ghost"       "Ghost"       "Ghost"      } 22 35} {GUARDIAN} {MOVE_UNIT x,y=22,35 23 34}
                {GENERIC_UNIT 5 {ON_DIFFICULTY "Vampire Bat" "Blood Bat"   "Blood Bat"  } 22 35} {GUARDIAN} {MOVE_UNIT x,y=22,35 21 33}
                {GENERIC_UNIT 5 {ON_DIFFICULTY "Vampire Bat" "Vampire Bat" "Blood Bat"  } 22 35}            {MOVE_UNIT x,y=22,35 20 33}
                {GENERIC_UNIT 5 {ON_DIFFICULTY "Wraith"      "Wraith"      "Wraith"     } 22 35} {GUARDIAN} {MOVE_UNIT x,y=22,35 21 35}

                {UNSTORE_AND_RECALL Mal_Mana Mal-Mana 22 35}
                [set_extra_recruit]
                    id=Mal-Mana
                    extra_recruit=Vampire Bat,Blood Bat,Ghost
                [/set_extra_recruit]
                [modify_side]
                    side=5
                    gold=50
                    income={ON_DIFFICULTY 5 12 19}
                    hidden=no
                [/modify_side]
                [delay]
                    time=150
                [/delay]

                {MODIFY_TERRAIN Ker  22  35}
                [redraw]
                [/redraw]

                [delay]
                    time=150
                [/delay]

                {MODIFY_TERRAIN Cer  21  36}
                [redraw]
                [/redraw]

                [delay]
                    time=150
                [/delay]

                {MODIFY_TERRAIN Cer  22  36}
                [redraw]
                [/redraw]

                [delay]
                    time=150
                [/delay]

                {MODIFY_TERRAIN Cer  23  36}
                [redraw]
                [/redraw]

                [delay]
                    time=150
                [/delay]

                {MODIFY_TERRAIN Cer  21  35}
                [redraw]
                [/redraw]

                [delay]
                    time=150
                [/delay]

                {MODIFY_TERRAIN Cer  22  34}
                [redraw]
                [/redraw]

                [message]
                    speaker=Mal-Mana
                    message= _ "Don’t think you can get away so easily!"
                [/message]
                [fire_event]
                    name=scary_music
                [/fire_event]
            [/then]
        [/if]

        {CLEAR_VARIABLE Naken_alvak}
        {CLEAR_VARIABLE Mal_Mana}

        # let them attack to prevent spawncamping, but limit movement
        {VARIABLE limit_moves_56 yes}
    [/event]
    [event]
        name=side 5 turn refresh

        [filter_condition]
            {VARIABLE_CONDITIONAL limit_moves_56 equals yes}
        [/filter_condition]

        {MODIFY_UNIT side=5 moves 1}
    [/event]
    [event]
        name=side 6 turn refresh

        [filter_condition]
            {VARIABLE_CONDITIONAL limit_moves_56 equals yes}
        [/filter_condition]

        {MODIFY_UNIT side=6 moves 1}
        {CLEAR_VARIABLE limit_moves_56}
    [/event]

    #--------------------
    # GRUG DIES
    #--------------------
    [event]
        name=die

        [filter]
            id=Grug
            side=2
        [/filter]

        [message]
            speaker=Izziasch
            message= _ "Now to deal with these humansss!"
        [/message]
    [/event]

    #--------------------
    # GWEDDRY MEETS GRUG
    #--------------------
    [event]
        name=moveto
        [filter]
            side=1
            x=1,  2,  3,   4,   5,   6,   7,   8,   9,   10,  11,  12,  13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29
            y=0-9,0-9,0-10,0-10,0-10,0-10,0-10,0-10,0-11,0-10,0-11,0-10,0-11,0-11,0-11,0-11,0-11,0-11,0-11,0-10,0-11,0-11,0-12,0-11,0-12,0-11,0-12,0-12,0-13
            [not]
                trait=undead
            [/not]
        [/filter]

        [message]
            speaker=Grug
            #po: one of the player's units has reached the north side of the river, triggering this conversation
            message= _ "You who? Fight lizard?"
        [/message]
        [message]
            speaker=unit
            message= _ "Err, yes, we’re here to fight the lizards."
        [/message]
        [message]
            speaker=Gweddry
            message= _ "If we help you fight your enemies, will you come with us and help fight our enemies?"
        [/message]
        [message]
            speaker=Grug
            message= _ "Mmmm... Grug think..."
        [/message]

        [delay]
            time=3000
        [/delay]

        [message]
            speaker=Grug
            message= _ "... Grug head hurt. Grug say join you."
        [/message]

        [capture_village]
            owner_side=2
            side=1
        [/capture_village]
        [modify_unit]
            [filter]
                side=2
            [/filter]

            side=1
            moves=$($this_unit.max_moves)
            attacks_left=1
            {TEAM_COLOR_OVERRIDE () purple}
        [/modify_unit]
        [modify_unit]
            [filter]
                id=Grug
            [/filter]

            canrecruit=no
            {TRAIT_LOYAL}
        [/modify_unit]

        [show_objectives]
        [/show_objectives]
    [/event]

    [event]
        name=prestart
        {VARIABLE leader_kills 0}
    [/event]
    [event]
        name=last breath
        first_time_only=no

        [filter]
            id=Mal-Mana,Mal-Talar,ghast_leader,Naken-alvak,Izziasch
        [/filter]

        {VARIABLE_OP leader_kills add 1}
    [/event]

    [event]
        name=last breath

        [filter]
            id=Izziasch
        [/filter]

        [message]
            speaker=Izziasch
            message= _ "Curssessss!"
        [/message]
        {KILL id=Izziasch}
        [if]
            [have_unit]
                side=1
                race=ogre
                count=2-99
            [/have_unit]
            # if we have more ogres than just Grug, Dacyn explains their cheaper recall
            [then]
                [message]
                    speaker=Owaec
                    #po: crossed the river
                    message= _ "Good, we have safely crossed! And we have gained the service of several ogres as well."
                [/message]
                [message]
                    speaker=Dacyn
                    message= _ "Ogres are unskilled fighters but much cheaper to equip than our other soldiers, and thus <i><b>cost much less gold to recall</b></i>."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Owaec
                    #po: crossed the river
                    message= _ "Good, we have safely crossed!"
                [/message]
            [/else]
        [/if]

        [if]
            {VARIABLE_CONDITIONAL leader_kills equals 5}
            [then]
                [set_achievement]
                    content_for=eastern_invasion
                    id=ei_S07b
                [/set_achievement]
            [/then]
        [/if]
        {CLEAR_VARIABLE leader_kills,saved_Garnad}
        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]

    [event]
        name=side 1 turn {SCENARIO_TURN_LIMIT} end
        [fire_event]
            name=time over
        [/fire_event]
    [/event]
    [event]
        name=time over
        {GENERIC_UNIT 6 (Revenant)        1 2} {ANIMATE}
        {GENERIC_UNIT 6 (Banebow)         1 1} {ANIMATE}
        {GENERIC_UNIT 6 (Skeleton)        3 1} {ANIMATE}
        {GENERIC_UNIT 6 (Skeleton Archer) 4 1} {ANIMATE}
        {GENERIC_UNIT 6 (Bone Shooter)    4 1} {ANIMATE}
        {GENERIC_UNIT 6 (Draug)           1 4} {ANIMATE}
        {GENERIC_UNIT 6 (Skeleton)        1 3} {ANIMATE}
        {GENERIC_UNIT 6 (Bone Shooter)    2 6} {ANIMATE}
        {GENERIC_UNIT 6 (Skeleton)        3 4} {ANIMATE}
        [message]
            speaker=Izziasch
            #po: "they" meaning the undead, not the player's troops
            message= _ "Cursessss! They’ve caught usss!"
        [/message]
        [message]
            speaker=Dacyn
            message= _ "We are caught as well..."
        [/message]
    [/event]

    [event]
        name=last breath

        [filter]
            id=Grug
        [/filter]

        [message]
            speaker=Grug
            message= _ "Hurt... grarrgghh..." # wmllint: no spellcheck
        [/message]
    [/event]

    {ENEMYDEATHS_SORADOC}
    {FOREIGN_DEFEAT}

    {HERODEATH_GWEDDRY}
    {HERODEATH_DACYN}
    {HERODEATH_OWAEC}
    {HERODEATH_ADDOGIN}
    {HERODEATH_HAHID}
    {HERODEATH_TERRAENT}
    #     {HERODEATH_GRUG} # don't have Gweddry say "he was not one of us, yet [...]"
    {HERODEATH_DOLBURRAS}
    {HERODEATH_HAHID}
[/scenario]

#undef SCENARIO_TURN_LIMIT
