#textdomain wesnoth-thot
[scenario]
    name=_"Invaders"
    id="05_Invaders"
    next_scenario="06_High_Pass"
    victory_when_enemies_defeated=yes

    # This scenario is the Attack of the Fuzzy-Wuzzies. The player
    # will be seriously outnumbered, but careful defensive
    # maneuvering and use of veterans can save the day.

    map_data="{@campaigns/The_Hammer_of_Thursagan/maps/invaders.map}"

    {DEFAULT_SCHEDULE}
    {DEFAULT_MUSIC_PLAYLIST}

    turns=40	# BALANCE

    [label]
        x,y=22,21
        text=_"Ruined Castle"
    [/label]

    [story]
        [part]
            background=maps/wesnoth.png
            story= _ "The Alliance's road ended at the troll bridge. East of it lay only the wildlands."
        [/part]
    [/story]

    [side]
        type="Dwarvish Fighter"
        description="Aiglondur"
        user_description=_"Aiglondur"
        canrecruit="1"
        side="1"
        controller="human"
        team_name="northern_alliance"
        fog="no"
        shroud="no"
        recruit="Dwarvish Fighter,Dwarvish Thunderer,Dwarvish Guardsman"
        {GOLD 100 80 60}	# BALANCE
    [/side]

    [side]
        type=Orcish Warlord
        description=Tan-Malgar
        user_description= _ "Tan-Malgar"
        profile=portraits/James_Woo/orc-warlord3.png
        side=2
        canrecruit=yes
        recruit=Orcish Archer, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Pillager, Goblin Spearman

        {GOLD 220 260 300}	# BALANCE
        team_name=orcs
        [ai]
            {NO_SCOUTS}
            recruitment_ignore_bad_movement=yes
            recruitment_pattern=scout,fighter,fighter,archer
            {ATTACK_DEPTH 4 5 5}
        [/ai]
        [ai]
            time_of_day=dusk,first_watch,second_watch
            aggression=0.75
            caution=0.0
            grouping=no
        [/ai]
    [/side]

    [side]
        type=Orcish Warlord
        description=Tan-Grolak
        user_description= _ "Tan-Grolak"
        profile=portraits/James_Woo/orc-warlord5.png
        side=3
        canrecruit=yes
#ifdef EASY
        recruit=Orcish Archer, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Pillager, Goblin Spearman
#endif

#ifdef NORMAL
        recruit=Orcish Archer, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Orcish Warrior, Goblin Pillager, Goblin Spearman
#endif

#ifdef HARD
        recruit=Orcish Archer, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Orcish Warrior, Goblin Knight, Goblin Pillager, Orcish Slayer, Goblin Spearman, Goblin Impaler
#endif

        {GOLD 180 220 360}	# BALANCE
        team_name=orcs
        [ai]
            {NO_SCOUTS}
            recruitment_ignore_bad_movement=yes
            recruitment_pattern=scout,fighter,fighter,archer
            {ATTACK_DEPTH 4 5 5}
        [/ai]
        [ai]
            time_of_day=dusk,first_watch,second_watch
            aggression=0.75
            caution=0.0
            grouping=no
        [/ai]
        {INCOME 4 8 12}
    [/side]

    [side]
        type=Orcish Warlord
        description="Tan-Uthkar"
        user_description= _ "Tan-Uthkar"
        profile=portraits/James_Woo/orc-warlord2.png
        side=4
        canrecruit=yes
        recruit=Orcish Archer, Orcish Grunt, Wolf Rider, Orcish Warrior, Goblin Spearman
        {GOLD 180 220 360}	# BALANCE
        team_name=orcs
        [ai]
            {NO_SCOUTS}
            recruitment_ignore_bad_movement=yes
            recruitment_pattern=scout,fighter,fighter,archer
            {ATTACK_DEPTH 4 5 5}
        [/ai]
        [ai]
            time_of_day=dusk,first_watch,second_watch
            aggression=0.75
            caution=0.0
            grouping=no
        [/ai]
    [/side]

    {@campaigns/The_Hammer_of_Thursagan/utils/herodeaths.cfg}
    {@campaigns/The_Hammer_of_Thursagan/utils/macros.cfg}

    [side]
        # The bandit indigenes
        side=5
        no_leader=yes
        [ai]
            grouping=offensive
            village_value=4
        [/ai]
    [/side]

    # Here is the code for popping up random bandits on village captures.
    [event]
        name=capture
        first_time_only=no
        [if]
            [variable]
                name=unit.side
                numerical_equals=5
            [/variable]
            [then]
                {CLEAR_VARIABLE cleared_$x1|_$y1|_village}
            [/then]
            [else]
                [if]
                    [variable]
                        name=cleared_$x1|_$y1|_village
                        not_equals=yes
                    [/variable]
                    [then]
                        [set_variable]
                            name=cleared_$x1|_$y1|_village
                            value=yes
                        [/set_variable]
                        # Compute the number of indigs that will pop up
                        [if]
                            [variable]
                                name=unit.side
                                numerical_equals=1
                            [/variable]
                            [then]
                                # The bandit villagers hate dwarves...
                                [set_variable]
                                    name=indigs
                                    random=0..2
                                [/set_variable]
                            [/then]
                            [else]
                                # ...but they hate orcs much worse.
                                [set_variable]
                                    name=indigs
                                    random=2..5
                                [/set_variable]
                            [/else]
                        [/if]
                        # Now place the indigs
                        [while]
                            [variable]
                                name=indigs
                                greater_than=0
                            [/variable]
                            [do]
                                [store_locations]
                                    [filter_adjacent_location]
                                        x,y=$x1,$y1
                                    [/filter_adjacent_location]

                                    [not]
                                        [filter]
                                        [/filter]
                                    [/not]

                                    variable=possible_indig_locations
                                [/store_locations]

                                [if]
                                    [variable]
                                        name=possible_indig_locations.length
                                        greater_than=0
                                    [/variable]
                                    [then]
                                        {VARIABLE_OP random_location_index random 1..$possible_indig_locations.length}
                                        [set_variable]
                                            name=random_location_index
                                            add=-1
                                        [/set_variable]
                                        {RANDOM (Footpad,Thief,Thug)}
                                        [unit]
                                            type=$random
                                            side=5
                                            x,y=$possible_indig_locations[$random_location_index].x,$possible_indig_locations[$random_location_index].y
                                            generate_description=yes
                                            random_traits=yes
                                        [/unit]
                                    [/then]
                                [/if]
                                [set_variable]
                                    name=indigs
                                    add=-1
                                [/set_variable]
                            [/do]
                        [/while]
                        {CLEAR_VARIABLE indigs}
                        # Perform appropriate notifications
                        [if]
                            [variable]
                                name=possible_indig_locations.length
                                greater_than=0
                            [/variable]
                            [then]
                                [message]
                                    speaker=unit
                                    message= _ "The villagers are attacking us!"
                                [/message]
                                [if]
                                    [variable]
                                        name=indigs_sighted
                                        equals=0
                                    [/variable]
                                    [then]
                                        [message]
                                            speaker=Aiglondur
                                            message= _ "Aye, it's still bandit country, right enough."
                                        [/message]
                                    [/then]
                                [/if]
                                [set_variable]
                                    name=indigs_sighted
                                    add=1
                                [/set_variable]
                            [/then]
                            [else]
                                [if]
                                    [variable]
                                        name=indigs_sighted
                                        greater_than=0
                                    [/variable]
                                    [then]
                                        [message]
                                            speaker=unit
                                            message= _ "No bandits in this village."
                                        [/message]
                                    [/then]
                                [/if]
                            [/else]
                        [/if]
                        {CLEAR_VARIABLE possible_indig_locations}
                    [/then]
                [/if]
            [/else]
        [/if]
    [/event]

    [event]
        name="prestart"
        [role]
            type=Dwarvish Steelclad,Dwarvish Thunderguard,Dwarvish Fighter,Dwarvish Thunderer
            [not]
                description=Aiglondur
            [/not]
            role=Scout
        [/role]
    [/event]

    [event]
        name="start"

        [recall]
            description="Angarthing"
        [/recall]

        [recall]
            role=Scout
        [/recall]

        [set_variable]
            name=indigs_sighted
            value=0
        [/set_variable]

        [message]
            description="Aiglondur"
            message=_"Stay alert, everyone, and keep together. This is bandit country...more than likely where Gothras and his gang came from."
        [/message]
        [message]
            role="Scout"
            message=_"Nae sign o' bandits I can see, captain -- but there are three muckle hosts of orcs off to our east."
        [/message]
        [message]
            description="Aiglondur"
            message=_"What's this?  Large orcish war-bands so close to the Alliance's border?  That can only mean trouble."
        [/message]
        [message]
            description="Tan-Malgar"
            message=_"Well, boys, we were planning to invade the Northern Alliance anyway...these dwarves should make a tasty appetizer."
        [/message]
        [message]
            description="Tan-Grolak"
            message=_"Yeah, boss. Anything to get away from those masked ones..."
        [/message]
        [message]
            description="Tan-Malgar"
            message=_"Be silent. We are orc warriors; we do not flee foes."
        [/message]
        [message]
            description="Tan-Uthkar"
            message=_"But, given a choice, we fight the weaker foe first."
        [/message]

        [objectives]
            side="1"
            silent="no"
            [objective]
                description=_"Defeat all enemies"
                condition="win"
            [/objective]
            [objective]
                description=_"Death of Aiglondur"
                condition="lose"
            [/objective]
            [objective]
                description=_"Death of Angarthing"
                condition="lose"
            [/objective]
            [objective]
                description=_"Time runs out"
                condition="lose"
            [/objective]
        [/objectives]
    [/event]
[/scenario]
