#textdomain wesnoth-sotbe

#define NOT_SAFE_LOCATIONS
    x=1-18, 19,   20-38
    y=12-43,13-43,12-43
#enddef

[scenario]
    id="Saving_Inarix"
    name= _ "Saving Inarix"
    map_data="{campaigns/Son_Of_The_Black_Eye/maps/Prestim.map}"
    turns=16

    {AFTERNOON}
    {DUSK}
    {FIRST_WATCH}
    {SECOND_WATCH}
    {DAWN}
    {MORNING}

    next_scenario="Clash_of_armies"

    {SCENARIO_MUSIC "vengeful.ogg"}
    {EXTRA_SCENARIO_MUSIC "breaking_the_chains.ogg"}

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Destroy the southern part of the bridge"
                condition=win
            [/objective]
            [objective]
                description= _ "In order to recruit saurians later on, bring Inarix and at least four saurians to safety"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Kapou'e"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Grüü"
                condition=lose
            [/objective]
            [objective]
                description= _ "Turns run out"
                condition=lose
            [/objective]

            note= _ "Note: whoever detonates the bridge will die.
"+{EARLY_FINISH_BONUS_NOTE}+{NEW_GOLD_CARRYOVER_NOTE_40}
        [/objectives]
    [/event]

    [side]
        type=Orcish Leader
        id="Kapou'e"
        name= _ "Kapou'e"
        side=1
        canrecruit=yes
        controller=human
        recruit= Wolf Rider, Orcish Grunt, Troll Whelp, Orcish Archer
        team_name=Kapoue
        user_team_name=_ "Kapou'e"
        gold=200
        {BLACK_FLAG}
    [/side]

    {STARTING_VILLAGES 1 10}
    {STARTING_VILLAGES_AREA 1 5 5 4}
    {STARTING_VILLAGES_AREA 1 35 5 4}

    [side]
        type=Elvish Champion
        id=Thelarion
        name= _ "Thelarion"
        side=2
        canrecruit=yes
        facing=sw
        [ai]
            aggression=1.0
            recruitment_pattern=scout, scout, fighter, fighter, fighter, healer, archer
            [target]
                type=Saurian
                value=50
            [/target]
        [/ai]
        recruit=Elvish Fighter, Elvish Archer, Elvish Shaman, Elvish Scout
        team_name=villains
        user_team_name=_"Villains"
        {GOLD 200 250 300}
    [/side]

    {STARTING_VILLAGES 2 13}

    [side]
        type=Dwarvish Steelclad
        id=Darstang
        name= _ "Darstang"
        side=3
        canrecruit=yes
        [ai]
            recruitment_pattern=scout, fighter, fighter, fighter, mixed fighter
            aggression=1.0
            villages_per_scout=10
            [target]
                type=Saurian
                value=50
            [/target]
        [/ai]
        recruit=Dwarvish Fighter, Dwarvish Thunderer, Footpad, Bandit
        team_name=villains
        user_team_name=_"Villains"
        {GOLD 200 250 300}
    [/side]

    {STARTING_VILLAGES 3 13}

    [story]
        [part]
            show_title=yes
            {TO_SAVING_INARIX}
        [/part]
    [/story]

    [event]
        name=prestart
        [unit]
            type="Orcish Slayer"
            id="Plonk"
            name= _ "Plonk"
            x=20
            y=4
            random_traits=no
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
        [/unit]

        {NAMED_UNIT 1 (Watch Tower) 30 5 (Eastern Tower) (_"Eastern Tower") (upkeep=free)}
        {NAMED_UNIT 1 (Watch Tower) 10 4 (Western Tower) (_"Western Tower") (upkeep=free)}
        {NAMED_UNIT 1 (Watch Tower) 19 5 (Southern Tower) (_"Southern Tower") (upkeep=free)}
        {GENERIC_UNIT 2 "Elvish Fighter" 19 11} {GUARDIAN}
        {GENERIC_UNIT 2 "Elvish Fighter" 19 12} {GUARDIAN}
        {GENERIC_UNIT 2 "Elvish Archer" 20 11} {GUARDIAN}
        {GENERIC_UNIT 2 "Elvish Archer" 18 11} {GUARDIAN}

        [unit]
            type=Dwarvish Guardsman
            side=3
            x=17
            y=15
            generate_name=yes
            ai_special=guardian
        [/unit]
        [unit]
            type=Dwarvish Guardsman
            side=3
            x=21
            y=15
            generate_name=yes
            ai_special=guardian
            facing=sw
        [/unit]

        [item]
            x,y=21,13
            image=items/barrel-floating.png
        [/item]
    [/event]

    [event]
        name=start

        [recall]
            id=Grüü
        [/recall]
        # wmllint: recognize Grüü
        [recall]
            id=Jetto
        [/recall]

        [message]
            speaker="Plonk"
            message= _ "Reinforcements, at last! Whoever you are, you are welcome in Prestim! The fortified bridge over the Bork river was taken this morning by a small commando of elves, we have already tried to assault it twice without success."
        [/message]
        [message]
            speaker="Grüü"
            message= _ "Ah! They are no match against my hammer."
        [/message]
        [message]
            speaker="Plonk"
            message= _ "There is worse; our scouts report that our saurian allies led by Inarix are still trapped on the other side of the river some miles away. They won't be able to cross the river."
        [/message]
        [message]
            speaker="Plonk"
            message= _ "Elves and dwarves have joined humans against us and have set up camp nearby. Humans will arrive soon. We must destroy the southern bridge on the river."
        [/message]
        [message]
            speaker="Kapou'e"
            message= _ "If Inarix falls prey to those humans then we won't be able to count on their help in this struggle. We must do something!"
            image=portraits/kapoue-angry.png
        [/message]
        [message]
            speaker="Grüü"
            message= _ "I know what we must do. Kill elves and help Inarix cross."
        [/message]
        [message]
            speaker="Plonk"
            message= _ "It won't be that easy! Our enemies are well entrenched."
        [/message]
        [message]
            speaker="Plonk"
            message= _ "We can sabotage the southern bridge to slow them down. When the bulk of the saurians have crossed, someone needs to go and light the barrel of oil we have set up beside the bridge to destroy it. Any warriors trapped on the bridge or on the other side of the river will perish!"
        [/message]

        {HIGHLIGHT_IMAGE 21 13 items/barrel-floating.png ()}

        [message]
            speaker=Thelarion
            message= _ "Hey look, that tribe of orcs that destroyed my enclave in the Silent Forest have reinforced Prestim. It is time to avenge the death of our fallen kin my friends - get them!"
        [/message]
        [message]
            speaker="Kapou'e"
            message= _ "Ahhh, it's 'the Prince' from the Silent Forest. Unfortunately, I don't think we can deal with him now, we have to focus on saving Inarix."
        [/message]
    [/event]

    [event]
        name=turn 4

        [unit]
            type=Saurian Ambusher
            id=Inarix
            name= _ "Inarix"
            side=1
            random_traits=no
            profile=portraits/inarix.png
            x=8
            y=42
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
        [/unit]

        {GENERIC_UNIT 1 "Saurian Skirmisher" 8 42}
        {GENERIC_UNIT 1 "Saurian Skirmisher" 8 42}
        {GENERIC_UNIT 1 "Saurian Skirmisher" 8 42}
        {GENERIC_UNIT 1 "Saurian Augur"      8 42}
        {GENERIC_UNIT 1 "Saurian Augur"      8 42}
        {GENERIC_UNIT 1 "Saurian Augur"      8 42}
        {GENERIC_UNIT 1 "Saurian Skirmisher" 8 42}
        {GENERIC_UNIT 1 "Saurian Skirmisher" 8 42}
        {GENERIC_UNIT 1 "Saurian Skirmisher" 8 42}

        [message]
            speaker="Inarix"
            message= _ "Hurry-hurry, friends. Lanbec'h and his kind are right on our tails, we must reach Prestim quickly."
        [/message]
    [/event]

    [event]
        name=bridge explode

        [store_locations]
            x=18,18,18,19,19,20,20,20
            y=12,13,14,13,14,12,13,14

            variable=exploding_hexes
        [/store_locations]

        [removeitem]
            x,y=21,13
        [/removeitem]

        [item]
            x,y=21,13
            halo=projectiles/fire-burst-small-1.png:50,projectiles/fire-burst-small-2.png:50,projectiles/fire-burst-small-3.png:50,projectiles/fire-burst-small-4.png:50,projectiles/fire-burst-small-5.png:50,projectiles/fire-burst-small-6.png:50,projectiles/fire-burst-small-7.png:50,projectiles/fire-burst-small-8.png:50,misc/blank-hex.png:1000000
        [/item]

        [kill]
            x,y=21,13
            animate=yes
            fire_event=yes
        [/kill]

        {FOREACH exploding_hexes i}
            [sound]
                name=explosion.ogg
            [/sound]

            [item]
                x,y=$exploding_hexes[$i].x,$exploding_hexes[$i].y
                halo=projectiles/fire-burst-small-1.png:50,projectiles/fire-burst-small-2.png:50,projectiles/fire-burst-small-3.png:50,projectiles/fire-burst-small-4.png:50,projectiles/fire-burst-small-5.png:50,projectiles/fire-burst-small-6.png:50,projectiles/fire-burst-small-7.png:50,projectiles/fire-burst-small-8.png:50,misc/blank-hex.png:1000000
            [/item]

            [kill]
                x,y=$exploding_hexes[$i].x,$exploding_hexes[$i].y
                animate=yes
                fire_event=yes
            [/kill]

            [terrain]
                x,y=$exploding_hexes[$i].x,$exploding_hexes[$i].y
                terrain=Ww
            [/terrain]

            [redraw]
            [/redraw]
        {NEXT i}

        [kill]
            side=1
            x=1-38
            y=15-43
            animate=no
            fire_event=yes
        [/kill]

        {CLEAR_VARIABLE exploding_hexes}
    [/event]

    [event]
        name=moveto
        first_time_only=no

        [filter]
            x,y=21,13
            id="Kapou'e"
        [/filter]

        [message]
            speaker="Kapou'e"
            message= _ "Bah! I'm not going to blow myself to bits!"
        [/message]

        [allow_undo]
        [/allow_undo]
    [/event]

    [event]
        name=moveto
        first_time_only=no

        [filter]
            x,y=21,13
            id=Grüü
        [/filter]

        [message]
            speaker="Kapou'e"
            message= _ "Grüü, stay away from that thing! I still have a use for you!"
            image=portraits/kapoue-angry.png
        [/message]

        [message]
            speaker="Grüü"
            # wmllint: local spelling OK
            message= _ "Uh... OK, Chief!"
        [/message]

        [allow_undo]
        [/allow_undo]
    [/event]

    [event]
        name=moveto
        first_time_only=no

        [filter]
            x,y=21,13
            id=Inarix
        [/filter]

        [message]
            speaker="Inarix"
            message= _ "I'm not going to do it!"
        [/message]

        [allow_undo]
        [/allow_undo]
    [/event]

    [event]
        name=moveto
        first_time_only=no

        [filter]
            side=1
            x,y=21,13

            [not]
                id="Kapou'e"
            [/not]

            [not]
                id=Grüü
            [/not]

            [not]
                id=Inarix
            [/not]
        [/filter]

        [if]
            [have_unit]
                id="Kapou'e"
                {NOT_SAFE_LOCATIONS}
            [/have_unit]

            [then]
                [message]
                    speaker="Kapou'e"
                    message= _ "Get away from there you idiot, I'm still over here!"
                    image=portraits/kapoue-angry.png
                [/message]
            [/then]
        [/if]

        [if]
            [have_unit]
                id=Grüü
                {NOT_SAFE_LOCATIONS}
            [/have_unit]

            [then]
                [message]
                    speaker="Grüü"
                    message= _ "Hey, don't light it up, I'm not safe!"
                [/message]
            [/then]
        [/if]

        [allow_undo]
        [/allow_undo]
    [/event]

    [event]
        name=moveto
        first_time_only=no

        [filter]
            side=1
            x,y=21,13

            [not]
                id="Kapou'e"
            [/not]

            [not]
                id=Grüü
            [/not]

            [not]
                id=Inarix
            [/not]
        [/filter]

        [if]
            [have_unit]
                id="Kapou'e"
                {NOT_SAFE_LOCATIONS}

                [or]
                    id=Grüü
                    {NOT_SAFE_LOCATIONS}
                [/or]
            [/have_unit]

            [then]
            [/then]

            [else]
                [if]
                    [variable]
                        name=turn_number
                        less_than=4
                    [/variable]

                    [then]
                        [message]
                            speaker="Grüü"
                            message= _ "Chief, we can't be blowing the bridge before Inarix is here, can we?"
                        [/message]
                    [/then]

                    [else]
                        [if]
                            [have_unit]
                                id=Inarix
                                {NOT_SAFE_LOCATIONS}
                            [/have_unit]

                            [then]
                                {VARIABLE unit_detonating_says _"Chief, Inarix hasn't yet made it across! Are you really sure you want to do this?"}
                            [/then]

                            [else]
                                {VARIABLE unit_detonating_says _"I'm ready, Chief!"}
                            [/else]
                        [/if]

                        [message]
                            speaker=unit
                            message=$unit_detonating_says

                            [option]
                                message= _ "Let her blow!"

                                [command]
                                    [message]
                                        speaker="Grüü"
                                        message= _ "Bye bye, $unit.name|!"
                                    [/message]

                                    [if]
                                        [have_unit]
                                            id=Inarix
                                            {NOT_SAFE_LOCATIONS}
                                        [/have_unit]

                                        [then]
                                            [message]
                                                speaker=Inarix
                                                message= _ "Damn you, Son of the Black-Eye! You'll pay for this!"
                                            [/message]

                                            {VARIABLE inarix_abandoned yes}
                                            {VARIABLE got_saurians no}
                                        [/then]

                                        [else]
                                            [message]
                                                side=1
                                                {NOT_SAFE_LOCATIONS}
                                                [not]
                                                    x,y=21,13
                                                [/not]
                                                message= _ "No, wait!"
                                            [/message]
                                        [/else]
                                    [/if]

                                    [message]
                                        speaker=unit
                                        message= _ "Aaaaaaaargh!"
                                    [/message]

                                    [fire_event]
                                        name=bridge explode
                                    [/fire_event]

                                    [endlevel]
                                        result=victory
                                        bonus=yes
                                        {NEW_GOLD_CARRYOVER 40}
                                    [/endlevel]
                                [/command]
                            [/option]

                            [option]
                                message= _ "Wait a moment."

                                [command]
                                    [message]
                                        speaker=unit
                                        message= _ " *phew*"
                                    [/message]
                                [/command]
                            [/option]
                        [/message]
                    [/else]
                [/if]
            [/else]
        [/if]

        [allow_undo]
        [/allow_undo]
    [/event]

    [event]
        name=die
        first_time_only=no

        [filter]
            side=1
            race=lizard

            [not]
                id=Inarix
            [/not]
        [/filter]

        [store_unit]
            [filter]
                side=1
                race=lizard

                [not]
                    id=Inarix
                [/not]
            [/filter]

            kill=no
            variable=stored_saurians
        [/store_unit]

        [if]
            [variable]
                name=stored_saurians.length
                less_than=5
            [/variable]

            [variable]
                name=got_saurians
                not_equals=no
            [/variable]

            [then]
                [message]
                    speaker="Kapou'e"
                    message= _ "Blast it! The saurians have had too many casualties in order for them to be of any real help to us. We won't be able to recruit them in the future."
                [/message]

                {VARIABLE got_saurians no}
            [/then]
        [/if]

        {CLEAR_VARIABLE stored_saurians}
    [/event]

    [event]
        name=turn 8
        [message]
            speaker=Thelarion
            message= _ "This has taken too much time, we should send all of our troops and send these creatures back to hell."
        [/message]
        [message]
            speaker=Darstang
            message= _ "It won't be said that Elves were braver than us, everyone attack!"
        [/message]
        [modify_side]
            side=2
            gold=400
        [/modify_side]
        [modify_side]
            side=3
            gold=400
        [/modify_side]
    [/event]

    [event]
        name=time over

        [unit]
            type="General"
            id="Earl Lanbec'h"
            name= _ "Earl Lanbec'h"
            profile=portraits/lanbech.png
            side=2
            x=8
            y=42
            random_traits=no
        [/unit]
        {GENERIC_UNIT 2 "Heavy Infantryman" 8 42}
        {GENERIC_UNIT 2 "Heavy Infantryman" 8 42}
        {GENERIC_UNIT 2 "Heavy Infantryman" 8 42}
        {GENERIC_UNIT 2 "Heavy Infantryman" 8 42}
        {GENERIC_UNIT 2 "Heavy Infantryman" 8 42}
        {GENERIC_UNIT 2 "Heavy Infantryman" 8 42}
        {GENERIC_UNIT 2 "Heavy Infantryman" 8 42}
        [message]
            speaker="Earl Lanbec'h"
            message= _ "At them! Rip them to the last!"
        [/message]
        [message]
            speaker="Kapou'e"
            message= _ "It is too late, we are defeated."
        [/message]
    [/event]

    [event]
        name=victory

        [if]
            [variable]
                name=got_saurians
                not_equals=no
            [/variable]

            [then]
                [allow_recruit]
                    side=1
                    type=Saurian Skirmisher,Saurian Augur
                [/allow_recruit]
            [/then]
        [/if]

        [if]
            [variable]
                name=inarix_abandoned
                equals=yes
            [/variable]

            [then]
                [kill]
                    race=lizard
                    fire_event=no
                    animate=no
                [/kill]
            [/then]
        [/if]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Thelarion
        [/filter]
        [message]
            speaker=unit
            message= _ "The green earth will curse you for this..."
        [/message]
        {VARIABLE thelarion_dead yes}
    [/event]

    [event]
        name=last breath
        [filter]
            id=Darstang
        [/filter]
        [message]
            speaker=unit
            message= _ "Curse you, foul orc!"
        [/message]
        {VARIABLE darstang_dead yes}
    [/event]

    {@campaigns/Son_Of_The_Black_Eye/utils/deaths.cfg}
[/scenario]
