#textdomain wesnoth-did
[scenario]
    id=Orc_war
    next_scenario=Return_to_Parthyn

    name=_ "Orc War"
    map_data="{campaigns/Descent_Into_Darkness/maps/Orc_war.map}"
    turns=30

    victory_when_enemies_defeated=yes
    {VICTORY_AND_DEFEAT_MUSIC}

    {STORY_ORC_WAR}

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

    [side]
        side=1
        controller=human
        type=Apprentice Mage
        description=Malin Keshar
        user_description=_ "Malin Keshar"
        unrenamable=yes
        canrecruit=yes
        recruit=Walking Corpse,Vampire Bat,Ghost,Ghoul,Skeleton Archer,Skeleton,Dark Adept DiD
        fog=no
        shroud=no
        gold=200
    [/side]

    [side]
        side=2
        controller=ai
        team_name=orcs
        type=Orcish Warlord
        description=Borth
        user_description=_ "Borth"
        profile=portraits/James_Woo/orc-warlord2.png
        canrecruit=yes
        recruit=Goblin Spearman,Orcish Archer,Orcish Crossbowman,Wolf Rider,Orcish Grunt,Goblin Knight,Orcish Warrior,Troll Whelp
        {GOLD 110 130 150}
        {INCOME 0 3 6}
        fog=no
        shroud=no
        [ai]
            villages_per_scout=8
            village_value=0.5
            [target]
                description=Malin Keshar
                value=1
            [/target]
            [target]
                description=Darken Volk
                value=1
            [/target]
        [/ai]
    [/side]

    {STARTING_VILLAGES 2 10}

    [side]
        side=3
        controller=ai
        team_name=orcs
        type=Orcish Slurbow
        description="P'Gareth"
        user_description=_ "P'Gareth"
        profile=portraits/James_Woo/orc-warlord2.png
        canrecruit=yes
        recruit=Orcish Archer,Orcish Crossbowman,Goblin Pillager,Orcish Grunt,Orcish Assassin
        {GOLD 110 130 150}
        {INCOME 0 3 6}
        fog=no
        shroud=no
        [ai]
            scout_village_targetting=2
            village_value=0.5
            [target]
                description=Malin Keshar
                value=1
            [/target]
            [target]
                description=Darken Volk
                value=1
            [/target]
        [/ai]
    [/side]

    [side]
        side=4
        controller=ai
        team_name=orcs
        type=Orcish Warlord
        description="K'Vark"
        user_description=_ "K'Vark"
        profile=portraits/James_Woo/orc-warlord2.png
        canrecruit=yes
        recruit=Orcish Archer,Orcish Crossbowman,Troll Whelp,Wolf Rider,Orcish Grunt
        {GOLD 110 130 150}
        {INCOME 0 3 6}
        fog=no
        shroud=no
        [ai]
            villages_per_scout=6
            village_value=0.5
            [target]
                description=Malin Keshar
                value=1
            [/target]
            [target]
                description=Darken Volk
                value=1
            [/target]
        [/ai]
    [/side]

    {STARTING_VILLAGES 4 8}

    [event]
        name=prestart

        # {SCATTER_IMAGE (terrain=Gg) 3 scenery/oak-leaning.png}
        # {SCATTER_IMAGE (terrain=Gs^Fp) 6 scenery/pine2.png}

        [music]
            name=battle.ogg
        [/music]

        [objectives]
            side=1
            [objective]
                condition=win
                description=_ "Kill the orc leaders"
            [/objective]
            [objective]
                condition=lose
                description=_ "Death of Malin Keshar"
            [/objective]
            [objective]
                condition=lose
                description=_ "Death of Darken Volk"
            [/objective]
        [/objectives]

        [recall]
            description=Darken Volk
        [/recall]

        {VARIABLE orc_leaders_killed 0}
    [/event]

    [event]
        name=start
        {DIALOGUE_OW_START}

        # Set orc villages

        {SET_VILLAGE 3 3 29}
        {SET_VILLAGE 3 7 33}
        {SET_VILLAGE 3 5 25}
        {SET_VILLAGE 3 17 28}
        {SET_VILLAGE 4 22 30}
        {SET_VILLAGE 4 20 33}
    [/event]

    # In-scenario events

    # Defeat Conditions
    {MALIN_DEATH}
    {VOLK_DEATH}
    {TIME_OUT_LOSE}

    # Victory Condition
    [event]
        name=die
        first_time_only=no
        [filter]
            canrecruit=yes
            [not]
                side=1
            [/not]
        [/filter]
        {VARIABLE_OP orc_leaders_killed add 1}
        [if]
            [variable]
                name=orc_leaders_killed
                numerical_equals=2
            [/variable]
            [then]
                {CLEAR_VARIABLE orc_leaders_killed}
                [endlevel]
                    bonus=yes
                    result=victory
                [/endlevel]
            [/then]
        [/if]
    [/event]

    [event]
        name=victory
        [if]
            [have_unit]
                side=2
                canrecruit=yes
            [/have_unit]
            [then]
                {VARIABLE orc_leader_side 2}
                {MOVE_UNIT (side=2
                canrecruit=yes) 13 1}
            [/then]
            [else]
                [if]
                    [have_unit]
                        side=3
                        canrecruit=yes
                    [/have_unit]
                    [then]
                        {VARIABLE orc_leader_side 3}
                        {MOVE_UNIT (side=3
                        canrecruit=yes) 1 31}
                    [/then]
                    [else]
                        # must have side 4 leader left
                        {VARIABLE orc_leader_side 4}
                        {MOVE_UNIT (side=4
                        canrecruit=yes) 40 34}
                    [/else]
                [/if]
            [/else]
        [/if]

        # Store the 3rd orc leader for use in Return to Parthyn
        [store_unit]
            [filter]
                canrecruit=yes
                side=$orc_leader_side
            [/filter]
            variable=orc_leader_store
            kill=yes
        [/store_unit]
        {CLEAR_VARIABLE orc_leader_side}
        {DIALOGUE_OW_END}
        # Heal Darken Volk and store him for his return in A Small Favor
        [object]
            silent=yes
            [filter]
                description=Darken Volk
            [/filter]
            [effect]
                apply_to=hitpoints
                heal_full=yes
            [/effect]
        [/object]
        [store_unit]
            [filter]
                description=Darken Volk
            [/filter]
            variable=darken_volk_store
            kill=yes
        [/store_unit]
    [/event]

    {@campaigns/Descent_Into_Darkness/utils/global-events.cfg}
[/scenario]
