#textdomain wesnoth-ai

[test]
    id=wolves
    name= _ "Wolves"
    next_scenario=micro_ai_test

    map_data="{ai/micro_ais/maps/animals.map}"

    {DEFAULT_SCHEDULE}
    turns=unlimited
    victory_when_enemies_defeated=no

    [side]
        side=1
        controller=human
        suppress_end_turn_confirmation=yes
        hidden=no
        name=Rutburt
        id=Rutburt
        type=Outlaw
        max_moves=99
        side=1
        persistent=no

        team_name=humans
        user_team_name= _ "Humans"

        canrecruit=yes
        recruit=Ruffian,Footpad,Thug,Poacher
        gold=0
    [/side]

    [side]
        side=2
        controller=ai
        no_leader=yes
        defeat_condition=no_units_left
        persistent=no

        team_name=wolves
        user_team_name= _ "team_name^Wolves"

        gold=0
        income=-2
    [/side]

    [side]
        side=3
        controller=ai
        no_leader=yes
        defeat_condition=no_units_left
        persistent=no

        team_name=wolves3
        user_team_name= _ "More Wolves"

        gold=0
        income=-3
    [/side]

    [side]  # This side is only here because we need one persistent side for the game to go on
        side=4
        controller=null
        persistent=yes
        save_id=Grnk
        hidden=yes
    [/side]

    # Put all the units and markers out there
    [event]
        name=prestart

        {VARIABLE scenario_name wolves}

        {SCATTER_UNITS 11 "Wolf" 1 (
            x=1-30
            y=1-33
        ) (
            side=2
            random_traits=yes
        )}

        {SCATTER_UNITS 10 "Wolf" 1 (
            x=25-57
            y=1-33
        ) (
            side=3
            random_traits=yes
        )}

        # The right-click menu items
        [set_menu_item]
            id=m01_end_wolves
            description= _ "End Scenario"
            image=items/ring-red.png~CROP(26,26,20,20)
            [show_if]
                {VARIABLE_CONDITIONAL scenario_name equals wolves}
            [/show_if]
            [command]
                [message]
                    speaker=narrator
                    image=wesnoth-icon.png
                    message= _ "Well, that was that."
                [/message]

                # So that game goes on to next scenario
                [modify_side]
                    side=4
                    controller=human
                [/modify_side]

                [endlevel]
                    result=victory
                    bonus=no
                    carryover_percentage=0
                    carryover_report=no
                    linger_mode=no
                [/endlevel]
            [/command]
        [/set_menu_item]
        [set_menu_item]
            id=m02_new_peasant
            description= _ "Place Side 1 Peasant"
            image=units/human-peasants/peasant.png~CROP(23,18,24,24)
            [show_if]
                {VARIABLE_CONDITIONAL scenario_name equals wolves}
            [/show_if]
            [command]
                {GENERIC_UNIT 1 Peasant $x1 $y1}
            [/command]
        [/set_menu_item]
        [set_menu_item]
            id=m03_new_wolf2
            description= _ "Place Side 2 Wolf"
            image=units/monsters/wolf.png~CROP(40,29,24,24)
            [show_if]
                {VARIABLE_CONDITIONAL scenario_name equals wolves}
            [/show_if]
            [command]
                {GENERIC_UNIT 2 Wolf $x1 $y1}
            [/command]
        [/set_menu_item]
        [set_menu_item]
            id=m04_new_wolf3
            description= _ "Place Side 3 Wolf"
            image=units/monsters/wolf.png~CROP(40,29,24,24)
            [show_if]
                {VARIABLE_CONDITIONAL scenario_name equals wolves}
            [/show_if]
            [command]
                {GENERIC_UNIT 3 Wolf $x1 $y1}
            [/command]
        [/set_menu_item]
        [set_menu_item]
            id=m05_kill_unit
            description= _ "Kill Unit under Cursor"
            image=items/potion-poison.png~CROP(24,29,24,24)
            [show_if]
                {VARIABLE_CONDITIONAL scenario_name equals wolves}
            [/show_if]
            [command]
                [kill]
                    x,y=$x1,$y1
                [/kill]
            [/command]
        [/set_menu_item]

        # Set up the wolves_multipacks micro AI for side 2
        [micro_ai]
            side=2
            ai_type=wolves_multipacks
            action=add

            show_pack_number=yes
            pack_size=4
        [/micro_ai]

        # Set up the wolves_multipacks micro AI for side 3
        [micro_ai]
            side=3
            ai_type=wolves_multipacks
            action=add

            show_pack_number=yes
        [/micro_ai]
    [/event]

    [event]
        name=start

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "This scenario features a different kind of wolf behavior from 'Animals'. First, there can be an arbitrary number of wolf packs and the pack size on each side is a free parameter (set to 3 for Side 2 and 4 for Side 3 in this scenario). At the beginning of the scenario, close wolves are grouped into packs in a semi-methodical way. Wolves of the same pack begin by joining each other on the map. After that, they stay together until only one wolf is left, which then tries to join up with an incomplete pack or with other single wolves. Individual wolves entering the map during the scenario behave in that way as well.

Second, wolves do not actively hunt here. For the most part they just wander (often long distance). However, the pack ferociously (and without regard for its own health) attacks any enemy units that come into range, as long as that does not mean separating the pack by more than a few hexes. Staying together, or joining with a new wolf assigned to the pack, is the only thing that takes priority over satisfying the wolves' thirst for blood.

To emphasize which wolf belongs to which pack, the pack number will be displayed below each wolf in this scenario once the AI takes control of a side the first time."
        [/message]

        [message]
            speaker=narrator
            caption= _ "Question for the Player"
            image=wesnoth-icon.png
            # wmllint: unbalanced-on
            message= _ "It is possible to include a human-controlled Side 1, so that the action stops once every turn for looking around (or for messing with things in debug mode). In human-controlled mode, several options are available through the right-click menu, such as adding additional wolves to either side, taking wolves off the map, adding peasants to the human-controlled side or ending the scenario. This enables easy exploring of the wolf AI behavior under different circumstances.

Note that the leader of the human-controlled side, Rutburt, can move 99 hexes per turn, so that it is always possible to keep him out of harm's way.

Also note that the wolves AI is coded as a Micro AI. A Micro AI can be added and adapted to the need of a scenario easily using only WML and the [micro_ai] tag. Check out the <span color='#00A000'>Micro AI wiki page</span> at https://wiki.wesnoth.org/Micro_AIs for more information." # wmllint: no spellcheck
            # wmllint: unbalanced-off
            [option]
                label= _ "<span font='16'>I'll just watch the two wolf sides.</span>"
                [command]
                    [end_turn]
                    [/end_turn]
                    [event]
                        name=side 2 turn
                        [modify_side]
                            side=1
                            controller=null
                            hidden=yes
                        [/modify_side]
                        [kill]
                            side=1
                        [/kill]
                    [/event]
                [/command]
            [/option]
            [option]
                label= _ "<span font='16'>I want to have control of Side 1.</span>"
            [/option]
        [/message]

        [objectives]
            side=1
            summary= _ "Watch the wolves move around and fight each other"
            [objective]
                description= _ "No wolves left on one side"
                condition=win
            [/objective]
            [objective]
                description= _ "Use right-click option"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Rutburt"
                condition=lose
            [/objective]
            [note]
                description= _ "Check out the right-click menu options for additional actions"
            [/note]
        [/objectives]
    [/event]

    # Stop if this was the last death on this side
    [event]
        name=die
        first_time_only=no

        [if]
            [not]
                [have_unit]
                    count=1-9999
                    side=$unit.side
                [/have_unit]
            [/not]
            [then]
                [message]
                    speaker=narrator
                    image=wesnoth-icon.png
                    message= _ "Well, that was that."
                [/message]

                # So that game goes on to next scenario
                [modify_side]
                    side=4
                    controller=human
                [/modify_side]

                [endlevel]
                    result=victory
                    bonus=no
                    carryover_percentage=0
                    carryover_report=no
                    linger_mode=no
                [/endlevel]
            [/then]
        [/if]
    [/event]
[/test]
