#textdomain wesnoth-tutorial

# wmlscope: set export=no

# wmllint: no-syntax-rewrite
# wmllint: directory spelling quintain

{./utils.cfg}

#define TARGET_HEX X Y
    {VARIABLE target_hex.x {X}}
    {VARIABLE target_hex.y {Y}}
    {VARIABLE target_hex.is_set yes}
#enddef

#define NO_TARGET_HEX
    {VARIABLE target_hex.is_set no}
#enddef

#define STUDENT_START_LOC
    9,6
#enddef
#define MARKER_LOC
    12,5
#enddef
#define DELFADOR_LOC
    13,6
#enddef
#define QUINTAIN_LOC
    13,5
#enddef
#define VILLAGE_LOC
    11,7
#enddef
#define KEEP_LOC
    9,6
#enddef
#define CONTINUE_MSG
    _ "
<big>Click a mouse button or press spacebar to continue...</big>"
    # Note: we would not like the user to "press any key" (for example, Esc)
#enddef

[tutorial]
    id=tutorial
    #po: Hello translators! Tutorial is meant to be a bit funny at the start,
    #po: welcoming new players. Please keep the friendly fun feeling!
    #po: Any questions email rusty@rustcorp.com.au!"
    name=_ "Wesnoth Tutorial"
    map_data="usage=map
border_size=1

    Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds,   Gg,    Gg,    Ww,    Ww,   Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds
    Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds,   Gg,    Gg,    Ww,    Ww,   Gg^Ve,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds
    Gs^Fds,   Gs^Fds,   Gs^Fds,   Gg,    Gg,    Gg,    Gg,    Gg,    Ww,    Ww,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds
    Gs^Fds,   Gs^Fds,   Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Ww,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gs^Fds,   Gs^Fds
    Gs^Fds,   Gs^Fds,   Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Ww,    Ww,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gs^Fds,   Gs^Fds
    Gs^Fds,   Gs^Fds,  Gg^Ve,    Gs^Fds,   Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,  Ww^Bw/,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg
    Gs^Fds,   Gs^Fds,   Gs^Fds,   Gg,    Gg,    Gg,    Gg,    Gg,    Gg,  1 Kh,    Ch,    Ww,    Ww,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg
    Gs^Fds,   Gs^Fds,   Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Ch,    Gg,   Gg^Ve,  Ww^Bw/,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg
    Gs^Fds,   Gs^Fds,   Gg,   Gg^Ve,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Ww,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gs^Fds,   Gs^Fds
    Gs^Fds,   Gs^Fds,   Gs^Fds,   Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Ww,    Ww,    Gg,    Gg,    Gg,    Gg,    Gg,    Gs^Fds,   Gs^Fds
    Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds,   Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Ww,    Gg,    Gg,    Gg,    Gg,    Gs^Fds,   Gs^Fds,   Gs^Fds
    Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds,   Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Ww,    Gg,    Gg,    Gg,    Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds
    Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds,   Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Gg,    Ww,    Gg,    Gg,    Gg,    Gs^Fds,   Gs^Fds,   Gs^Fds,   Gs^Fds
"
    turns=12
    {DEFAULT_MUSIC_PLAYLIST}
    [music]
        name=elf-land.ogg
        play_once=yes
    [/music]
    next_scenario=2_Tutorial

    {DEFAULT_SCHEDULE}

    victory_when_enemies_defeated=no

    [side]
        type=Fighter
        id=student
        name=_"Konrad"
        profile=portraits/konrad.png
        current_player=_"Konrad"
        canrecruit=yes
        side=1
        controller=human
    [/side]
    #! -- No leader means NO DESCRIPTIONS. Period.
    [side]
        no_leader=yes
        side=2
        controller=ai
        [ai]
            passive_leader=no
            caution=0
            aggression=5
            [target]
                id=student
                value=10
            [/target]
            [target]
                id=Delfador
                value=.1
            [/target]
        [/ai]
    [/side]

    [side]
        no_leader=yes
        side=3
        team_name=1
        controller=null
    [/side]

    [event]
        name=prestart
        [store_locations]
            variable=student_loc
            [filter]
                id=student
            [/filter]
        [/store_locations]

        [hide_unit]
            x=$student_loc.x
            y=$student_loc.y
        [/hide_unit]

        {CLEAR_VARIABLE student_loc}

        [unit]
            id=Delfador
            name=_ "Delfador"
            type=Elder Mage
            profile=portraits/delfador.png
            x,y=13,6
            side=3
            {IS_HERO}
        [/unit]
        {LABEL ( _ "Delfador") (13,6)}

        [objectives]
            side=1
            summary=_ "You will learn the basics of:
Movement
Attacking
Healing
Recruiting"
            [objective]
                description=_ "Destroy a fierce enemy"
                condition=win
            [/objective]
            [objective]
                description=_ "Get yourself killed"
                condition=lose
            [/objective]
        [/objectives]

        {VARIABLE student_hp 32}
    [/event]

    [event]
        name=start
        [message]
            speaker=narrator
            message=_"Who would you like to play?"
            [option]
                message="&" + "units/konrad-fighter.png" + "=" + _"Konrad"  # wmllint: no spellcheck
                [command]
                    {VARIABLE student _"Konrad"}
                    {VARIABLE gender male}
                [/command]
            [/option]
            [option]
                message="&" + "units/human-princess.png" + "=" + _"Li'sar"  # wmllint: no spellcheck
                [command]
                    {VARIABLE student _"Li'sar"}
                    {VARIABLE gender female}
                    [kill]
                        id=student
                        fire_event=no
                        animate=no
                    [/kill]
                    [unit]
                        type=Fighteress
                        side=1
                        x,y={STUDENT_START_LOC}
                        profile=portraits/lisar.png
                        id=student
                        name= _"Li'sar"
                        canrecruit=yes
                    [/unit]
                    [redraw][/redraw]
                [/command]
            [/option]
        [/message]

        [unhide_unit][/unhide_unit]
        {LABEL $student {STUDENT_START_LOC}}
        [redraw][/redraw]

#wmlindent: start ignoring
        {GENDER ([message]
                speaker=narrator
                message=_ "<big>Welcome to Wesnoth!</big>" +
                        _ "
For this tutorial, you are playing Konrad. " +
                        _ "You are standing in the keep, and your mentor Delfador is on the east side of the river." +
                        {CONTINUE_MSG}
        [/message]) ([message]
                speaker=narrator
                message=_ "<big>Welcome to Wesnoth!</big>" +
                        _ "
For this tutorial, you are playing Li'sar. " +
                        _ "You are standing in the keep, and your mentor Delfador is on the east side of the river." +
                        {CONTINUE_MSG}
        [/message])}

        {GENDER ({PRINT (_"Left click on Konrad")})
                ({PRINT (_"Left click on Li'sar")})}
#wmlindent: stop ignoring
    [/event]

    [event]
        name=select
        [filter]
            side=1
        [/filter]

        {UNLABEL {STUDENT_START_LOC}}
        {CLEAR_PRINT}

        [redraw][/redraw]
#wmlindent: start ignoring
        {GENDER ([message]
                speaker=narrator
#wmllint: display on
                message=_ "<big>You have selected Konrad.</big>
The places he can move to are highlighted." +
                        {CONTINUE_MSG}
#wmllint: display off
        [/message]) ([message]
                speaker=narrator
#wmllint: display on
                message=_ "<big>You have selected Li'sar.</big>
The places she can move to are highlighted." +
                        {CONTINUE_MSG}
#wmllint: display off
        [/message])}
#wmlindent: stop ignoring
        {LABEL (_ "HERE") {MARKER_LOC}}
        [redraw][/redraw]

#wmlindent: start ignoring
        {GENDER ([message]
                speaker=narrator
                message=_ "Move Konrad next to Delfador by clicking on the tile marked 'HERE'." +
                {CONTINUE_MSG}
        [/message]) ([message]
                speaker=narrator
                message=_ "Move Li'sar next to Delfador by clicking on the tile marked 'HERE'." +
                {CONTINUE_MSG}
        [/message])}
#wmlindent: stop ignoring
        {TARGET_HEX 12 5}
        {PRINT (_"Left click on tile labeled HERE")}
    [/event]

    # General catch for them moving to the wrong place.
    [event]
        name=moveto
        first_time_only=no
        [allow_undo][/allow_undo]
        [filter]
            side=1
            [filter_location]
                [not]
                    find_in=target_hex
                [/not]
            [/filter_location]
        [/filter]
        [if]
            [variable]
                name=target_hex.is_set
                boolean_equals=yes
            [/variable]
            [then]
                [redraw][/redraw]
                [message]
                    speaker=narrator
                    #wmllint: display on
                    message=_ "<big>Oops!</big>
You moved to the wrong place! After this message, you can press 'u' to undo, then try again." +
                    {CONTINUE_MSG}
                    #wmllint: display off
                [/message]
            [/then]
        [/if]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            x,y={MARKER_LOC}
        [/filter]

        {CLEAR_PRINT}
        {UNLABEL {MARKER_LOC}}
        {UNLABEL {DELFADOR_LOC}}
        {NO_TARGET_HEX}
        [redraw][/redraw]
        [message]
            id=student
            message=_ "Good morning, Delfador! Is it time to attack things?"
        [/message]
        [message]
            id=Delfador
            message=_ "Um, well..."
        [/message]
        [message]
            id=student
            message=_ "Have you found an orc for me to fight, huh? A troll?"
        [/message]
        [message]
            id=Delfador
            message=_ "Quiet! I will summon an enemy for you..."
        [/message]
        [scroll_to_unit]
            id=Delfador
        [/scroll_to_unit]
        [sound]
            name=lightning.ogg
        [/sound]
        [colour_adjust]
            red=100
            green=100
            blue=100
        [/colour_adjust]
        [delay]
            time=10
        [/delay]
        [colour_adjust]
            red=0
            green=0
            blue=0
        [/colour_adjust]
        [unit]
            id=Quintain
            type=Quintain
            ai_special="guardian"
            x,y={QUINTAIN_LOC}
            side=2
        [/unit]
        {LABEL (_"Quintain") {QUINTAIN_LOC}}
        [redraw][/redraw]
        [message]
            id=Delfador
            message=_ "... this quintain!"
        [/message]
        [message]
            id=student
            message=_ "A quintain? You want me to pretend to fight a dummy?"
        [/message]
        [message]
            id=Delfador
            message=_ "Child, you have 32 hitpoints and a sword. I'm fairly sure you'll win."
        [/message]
#wmlindent: start ignoring
        {GENDER ([message]
                speaker=narrator
                message=_ "To attack the quintain, first select the attacker (Konrad) then the target (the quintain). You will see an attack description. When you click OK, Konrad will attack." +
        {CONTINUE_MSG}
        [/message]) ([message]
                speaker=narrator
                # wmllint: local spelling OK
                message=_ "To attack the quintain, first select the attacker (Li'sar) then the target (the quintain). You will see an attack description. When you click OK, Li'sar will attack." +
        {CONTINUE_MSG}
        [/message])}
#wmlindent: stop ignoring
        {MODIFY_UNIT id=student moves 0}
        [event]
            name=select
            [filter]
                side=1
            [/filter]

            {PRINT (_"Click on the quintain to attack it")}
        [/event]

#wmlindent: start ignoring
        {GENDER ({PRINT (_"Left click on Konrad")})
                ({PRINT (_"Left click on Li'sar")})}
#wmlindent: stop ignoring
    [/event]

    # We track student's hitpoints so Delfador can explain them.
    [event]
        name=attacker_hits
        first_time_only=no
        [filter_second]
            id=student
        [/filter_second]
        {VARIABLE_OP student_hp add -3}
    [/event]

    [event]
        name=defender_hits
        first_time_only=no
        [filter]
            id=student
        [/filter]
        {VARIABLE_OP student_hp add -3}
    [/event]

    [event]
        name=attack_end

        {CLEAR_PRINT}
        {UNLABEL {QUINTAIN_LOC}}

        [message]
            id=student
            message=_ "Hey! This quintain fights back!"
        [/message]
        [message]
            id=Delfador
            message=_ "Hmm, maybe we should have started with a doll."
        [/message]
        [message]
            id=student
            message=_ "Should I retreat?"
        [/message]
        [message]
            id=Delfador
            message=_ "Good idea!"
        [/message]
#wmlindent: start ignoring
        {GENDER ([message]
                speaker=narrator
                message=_ "Note: the tiny blue crown above Delfador means you will lose the game if he is killed. You will also lose the game if your leader (Konrad) is killed."
        [/message]) ([message]
                speaker=narrator
                message=_ "Note: the tiny blue crown above Delfador means you will lose the game if he is killed. You will also lose the game if your leader (Li'sar) is killed."
        [/message])}
#wmlindent: stop ignoring

        {MOVE Delfador 13 6 14 8}

        {VARIABLE future_hp $student_hp}
        {VARIABLE_OP future_hp add -15}
#wmlindent: start ignoring
        {GENDER (
            [message]
                id=Delfador
                message=_ "Unfortunately, you've used up your turn attacking the quintain. The quintain will now get a turn."
            [/message]
        ) (
            [message]
                id=Delfador
                message=_ "female^Unfortunately, you've used up your turn attacking the quintain. The quintain will now get a turn."
            [/message]
        )}
#wmlindent: stop ignoring
        [message]
            id=student
            message=_ "The DUMMY gets a turn?"
        [/message]
        [message]
            id=Delfador
            #wmllint: display on
            message=_ "Yes. It's a magical quintain.
Now, this quintain gets 5 chances to hit you for 3 damage each. If it hits every time, you'll drop from $student_hp to $future_hp hit points. Brace yourself!"
            #wmllint: display off
        [/message]
        {PRINT (_ "Click on the End Turn button on the bottom right")}
        {VARIABLE next_turn.capture_village $turn_number}
        {VARIABLE_OP next_turn.capture_village add 1}
    [/event]

    [event]
        name=new turn
        first_time_only=no

        [if]
            [variable]
                name=turn_number
                equals=$next_turn.capture_village
            [/variable]
            [then]
                # There is a 1 in 170,000 chance that the quintain will miss on all
                # 10 attacks. Ignoring that.
                {CLEAR_PRINT}
                [redraw][/redraw]
                [message]
                    id=student
                    message=_ "Ouch! I need to heal! Only $student_hp hitpoints left!"
                [/message]
                {LABEL (_"Village") {VILLAGE_LOC}}
                #wmlindent: start ignoring
                {GENDER (
                    [message]
                        id=Delfador
                        message=_ "There is a village on the other side of the river. Visiting villages is a good idea, and ending your turn in one will heal you. To the village!"
                    [/message]
                ) (
                    [message]
                        id=Delfador
                        message=_ "female^There is a village on the other side of the river. Visiting villages is a good idea, and ending your turn in one will heal you. To the village!"
                    [/message]
                )}
                {GENDER ({PRINT (_"Left click on Konrad")})
                        ({PRINT (_"Left click on Li'sar")})}
                #wmlindent: stop ignoring
                [event]
                    name=select
                    [filter]
                        side=1
                    [/filter]

                    #wmlindent: start ignoring
                        {GENDER ({PRINT (_"Click on the village to move Konrad")})
                                ({PRINT (_"Click on the village to move Li'sar")})}
                    #wmlindent: stop ignoring
                [/event]

                {TARGET_HEX 11 7}

                [event]
                    name=moveto
                    [filter]
                        side=1
                        x,y=11,7
                    [/filter]
                    {CLEAR_PRINT}
                    [redraw][/redraw]
                    {NO_TARGET_HEX}
                    [message]
                        speaker=narrator
                        #wmllint: display on
                        message=_ "You captured a village! It now flies your flag color and has been added to your total village count at the top of the screen (house icon). Villages provide the gold needed to recruit units. Each turn, you gain two gold plus one for every village you own." +
                        {CONTINUE_MSG}
                        #wmllint: display off
                    [/message]
                    {PRINT (_"Click on the End Turn button")}
                [/event]
                {VARIABLE next_turn.do_recruit $turn_number}
                {VARIABLE_OP next_turn.do_recruit add 1}
            [/then]
        [/if]
        [if]
            [variable]
                name=turn_number
                equals=$next_turn.do_recruit
            [/variable]
            [then]
                {CLEAR_PRINT}
                {UNLABEL {VILLAGE_LOC}}
                [store_unit]
                    [filter]
                        id=student
                    [/filter]
                    kill=no
                    variable=student_hp_check
                [/store_unit]
                {VARIABLE hp_difference $student_hp_check.max_hitpoints}
                {VARIABLE_OP hp_difference add -$student_hp_check.hitpoints}
                [if]
                    [variable]
                        name=hp_difference
                        greater_than=7
                    [/variable]
                    [then]
                        {VARIABLE hp_difference 8}
                    [/then]
                [/if]
#wmlindent: start ignoring
                {GENDER (
                    [message]
                        id=Delfador
                        message=_ "You're about to be healed by $hp_difference hitpoints, but I think you're going to need some help against that quintain."
                    [/message]
                ) (
                    [message]
                        id=Delfador
                        message=_ "female^You're about to be healed by $hp_difference hitpoints, but I think you're going to need some help against that quintain."
                    [/message]
                )}
#wmlindent: stop ignoring
                [message]
                    id=student
                    message=_ "I'll recruit some elves!"
                [/message]
                {LABEL (_"Keep") {KEEP_LOC}}
#wmlindent: start ignoring
                {GENDER (
                    [message]
                        id=Delfador
                        message=_ "A splendid idea. You can recruit two units if you return to the keep. You have plenty of gold for that."
                    [/message]
                ) (
                    [message]
                        id=Delfador
                        message=_ "female^A splendid idea. You can recruit two units if you return to the keep. You have plenty of gold for that."
                    [/message]
                )}
#wmlindent: stop ignoring
                {TARGET_HEX 9 6}
                #wmlindent: start ignoring
                {GENDER ({PRINT (_"Move Konrad to the keep")})
                        ({PRINT (_"Move Li'sar to the keep")})}
                #wmlindent: stop ignoring
                [event]
                    name=moveto
                    [filter]
                        x,y={KEEP_LOC}
                    [/filter]

                    {CLEAR_PRINT}
                    {UNLABEL {KEEP_LOC}}
                    [set_recruit]
                        recruit=Elvish Fighter
                        side=1
                    [/set_recruit]
                    [redraw][/redraw]
                    [message]
                        speaker=narrator
                        #wmllint: display on
                        message=_ "Whenever you're on a keep, you can recruit into castle tiles around it by right-clicking and selecting 'Recruit'. This time you will only be given one type of unit to choose: the Elvish Fighter." +
                        {CONTINUE_MSG}
                        #wmllint: display off
                    [/message]
                    {PRINT (_"Right click on one castle tile and select Recruit")}
                [/event]
                [event]
                    name=recruit
                    first_time_only=no
                    # zookeeper suggested we eliminate traits by killing
                    # the recruit and replacing it
                    [kill]
                        x,y=$x1,$y1
                    [/kill]
                    # Each one needs a unique description for next level.
                    {VARIABLE_OP description_num add 1}
                    {NOTRAIT_UNIT 1 "Elvish Fighter" $x1 $y1}
                    [+unit]
                        role="Recruit $description_num"
                        moves=0
                        generate_name=yes
                    [/unit]
                [/event]
                [event]
                    name=recruit
                    [filter]
                        x,y=10,6
                    [/filter]

                    [if]
                        [have_unit]
                            role="Recruit 1"
                        [/have_unit]
                        [then]
                            {CLEAR_PRINT}
                            [redraw][/redraw]
                            [message]
                                speaker=narrator
                                #wmllint: display on
                                message=_ "These newly recruited units can do nothing this turn; you will control them next turn.
Note: after this dialog, you can move the mouse over a unit to see a description on the right of the screen." +
                                {CONTINUE_MSG}
                                #wmllint: display off
                            [/message]
                            # They can move to the village if they're smart
                            {NO_TARGET_HEX}
                            {PRINT (_"Click on the End Turn button")}
                            {VARIABLE next_turn.elves_attack $turn_number}
                            {VARIABLE_OP next_turn.elves_attack add 1}
                        [/then]
                        [else]
                            {PRINT (_"Right click on the other castle tile and Recruit another unit")}
                        [/else]
                    [/if]
                [/event]
                [event]
                    name=recruit
                    [filter]
                        x,y=9,7
                    [/filter]

                    [if]
                        [have_unit]
                            role="Recruit 1"
                        [/have_unit]
                        [then]
                            {CLEAR_PRINT}
                            [redraw][/redraw]
                            [message]
                                speaker=narrator
                                #wmllint: display on
                                message=_ "These newly recruited units can do nothing this turn; you will control them next turn.
Note: after this dialog, you can move the mouse over a unit to see a description on the right of the screen." +
                                {CONTINUE_MSG}
                                #wmllint: display off
                            [/message]
                            # They can move to the village if they're smart
                            {NO_TARGET_HEX}
                            {PRINT (_"Click on the End Turn button")}
                            {VARIABLE next_turn.elves_attack $turn_number}
                            {VARIABLE_OP next_turn.elves_attack add 1}
                        [/then]
                        [else]
                            {PRINT (_"Right click on the other castle tile and Recruit another unit")}
                        [/else]
                    [/if]
                [/event]
                {VARIABLE next_turn.quintain_heals $turn_number}
                {VARIABLE_OP next_turn.quintain_heals add 1}
            [/then]
        [/if]
        [if]
            [variable]
                name=next_turn.quintain_heals
                equals=$turn_number
            [/variable]
            [then]
                [if]
                    [have_unit]
                        id=Quintain
                    [/have_unit]
                    [then]
                        {CLEAR_PRINT}
                        [message]
                            id=student
                            message=_ "Hey, the quintain just healed 2 hitpoints! I'd better attack it at once!"
                        [/message]
                        [message]
                            id=Delfador
                            message=_ "Yes, if a unit doesn't do anything for a turn, it will slowly heal."
                        [/message]
                    [/then]
                    [else]
                        [message]
                            id=Delfador
                            message=_ "Had the quintain survived your onslaught, it would have regained two hitpoints. If a unit doesn't do anything for a turn, it will slowly heal."
                        [/message]
                    [/else]
                [/if]
            [/then]
        [/if]
        [if]
            [variable]
                name=next_turn.elves_attack
                equals=$turn_number
            [/variable]
            [then]
                [message]
                    id=Delfador
                    message=_ "But before you send your fighters against the quintain, you should know they have two kinds of attack..."
                [/message]
                [message]
                    id=student
                    message=_ "I'll tell them to use the one that does the most damage!"
                [/message]
                [message]
                    id=Delfador
                    message=_ "And which would that be? The sword (5-4) or the bow (3-3)? I suppose you'll find out..."
                [/message]
                {PRINT (_"Left click on an Elvish Fighter")}
                {VARIABLE encourage (_"End your turn and attack again.")}
                {VARIABLE trying_to_be_a_wiseguy yes}
                [event]
                    name=select
                    first_time_only=no
                    [filter]
                        id=student
                    [/filter]

                    [if]
                        [variable]
                            name=trying_to_be_a_wiseguy
                            equals=yes
                        [/variable]
                        [then]
                            [message]
                                id=Delfador
                                #wmllint: display on
                                message=_ "You wouldn't do anything stupid like charging that quintain yourself again, now would you?
Use the fighters you recruited first; they'll be a lot of help."
                                #wmllint: display off
                            [/message]
                        [/then]
                    [/if]
                [/event]
                [event]
                    name=select
                    [filter]
                        type=Elvish Fighter
                    [/filter]
                    {PRINT (_"Left click on the Quintain to attack it.")}
                [/event]
                [event]
                    name=attack
                    [filter]
                        type=Elvish Fighter
                    [/filter]

                    {VARIABLE trying_to_be_a_wiseguy no}
                    {CLEAR_PRINT}
                    {VARIABLE next_turn.advice_chain[0].turn $turn_number}
                    {VARIABLE_OP next_turn.advice_chain[0].turn add 1}
                [/event]
                [event]
                    name=attack_end
                    [filter]
                        type=Elvish Fighter
                    [/filter]
                    [filter_attack]
                        name=sword
                    [/filter_attack]

                    {VARIABLE used_sword 1}
                    [if]
                        [variable]
                            name=used_bow
                            numerical_equals=1
                        [/variable]
                        [then]
                            [if]
                                [variable]
                                    name=quintain_dead
                                    numerical_equals=1
                                [/variable]
                                [then]
                                    [message]
                                        id=Delfador
                                        message=_ "Your elf used a sword (5-4; or 5 damage, 4 attacks), which is a melee attack. Quintain defended with its melee attack (3-5). The ranged attack was safer."
                                    [/message]
                                [/then]
                                [else]
                                    [message]
                                        id=Delfador
                                        #wmllint: display on
                                        message=_ "Your elf used a sword (5-4; or 5 damage, 4 attacks), which is a melee attack. The quintain defended with its melee attack (3-5). The ranged attack was safer.
End your turn, then attack again."
                                        #wmllint: display off
                                    [/message]
                                    {PRINT (_"Click on the End Turn button")}
                                [/else]
                            [/if]
                        [/then]
                        [else]
                            [message]
                                id=Delfador
                                #wmllint: display on
                                message=_ "Your elf used a sword (5-4; or 5 damage, 4 attacks), which is a melee attack. The quintain defended with its melee attack (3-5).
You should tell the other Elf to use the bow."
                                #wmllint: display off
                            [/message]
                            {PRINT (_"Attack with the other Elf")}
                            [event]
                                name=attack
                                {CLEAR_PRINT}
                            [/event]
                        [/else]
                    [/if]
                [/event]
                [event]
                    name=attack_end
                    [filter_attack]
                        name=bow
                    [/filter_attack]

                    {VARIABLE used_bow 1}
                    [if]
                        [variable]
                            name=used_sword
                            numerical_equals=1
                        [/variable]
                        [then]
                            [if]
                                [variable]
                                    name=quintain_dead
                                    numerical_equals=1
                                [/variable]
                                [then]
                                    [message]
                                        id=Delfador
                                        message=_ "Your elf used a bow, which is a ranged attack (3-3; or 3 damage, 3 attacks). The quintain has no ranged attack, only a melee attack, so it could not defend itself."
                                    [/message]
                                [/then]
                                [else]
                                    [message]
                                        id=Delfador
                                        #wmllint: display on
                                        message=_ "Your elf used a bow, which is a ranged attack (3-3; or 3 damage, 3 attacks). The quintain has no ranged attack, only a melee attack, so it could not defend itself.
End your turn, then attack again."
                                        #wmllint: display off
                                    [/message]
                                    {PRINT (_"Click on the End Turn button")}
                                [/else]
                            [/if]
                        [/then]
                        [else]
                            [message]
                                id=Delfador
                                message=_ "Your elf used a bow, which is a ranged attack (3-3; or 3 damage, 3 attacks). The quintain has no ranged attack, only a melee attack, so it could not defend itself."
                            [/message]
                            {PRINT (_"Attack with the other Elf")}
                            [event]
                                name=attack
                                {CLEAR_PRINT}
                            [/event]
                        [/else]
                    [/if]
                [/event]
            [/then]
        [/if]
        [if]
            [variable]
                name=next_turn.advice_chain[0].turn
                equals=$turn_number
            [/variable]
            [then]
                {CLEAR_PRINT}
                [message]
                    id=Delfador
                    message=_ "Keep attacking with both elves until the quintain is finished!"
                [/message]
                {VARIABLE next_turn.advice_chain[1].turn $turn_number}
                {VARIABLE_OP next_turn.advice_chain[1].turn add 1}
            [/then]
        [/if]
        [if]
            [variable]
                name=next_turn.advice_chain[1].turn
                equals=$turn_number
            [/variable]
            [then]
                [message]
                    id=Delfador
                    message=_ "Maybe you should recruit another elf?"
                [/message]
                [message]
                    speaker=narrator
                    #wmllint: display on
                    message=_ "Note:
You can right click on a unit to see a detailed Unit Description."
                    #wmllint: display off
                [/message]
                {VARIABLE next_turn.advice_chain[2].turn $turn_number}
                {VARIABLE_OP next_turn.advice_chain[2].turn add 1}
            [/then]
        [/if]
        [if]
            [variable]
                name=next_turn.advice_chain[2].turn
                equals=$turn_number
            [/variable]
            [then]
                [if]
                    [variable]
                        name=quintain_dead
                        numerical_equals=1
                    [/variable]
                    [then]
                        [message]
                            speaker=narrator
                            #wmllint: display on
                            message=_ "Note:
Remember to pull back wounded units into villages and recruit more if needed. Take special care of units with the highest experience points (XP) so they can level up!"
                            #wmllint: display off
                        [/message]
                    [/then]
                [/if]
                {VARIABLE next_turn.advice_chain[3].turn $turn_number}
                {VARIABLE_OP next_turn.advice_chain[3].turn add 1}
            [/then]
        [/if]
        [if]
            [variable]
                name=next_turn.advice_chain[3].turn
                equals=$turn_number
            [/variable]
            [then]
                [message]
                    speaker=narrator
                    #wmllint: display on
                    message=_ "Note:
Each village you own can support a single unit for free. After that, each unit costs you one gold per turn."
                    #wmllint: display off
                [/message]
                {VARIABLE next_turn.advice_chain[4].turn $turn_number}
                {VARIABLE_OP next_turn.advice_chain[4].turn add 1}
            [/then]
        [/if]
        [if]
            [variable]
                name=next_turn.advice_chain[4].turn
                equals=$turn_number
            [/variable]
            [then]
                [message]
                    speaker=narrator
                    #wmllint: display on
                    message=_ "Note:
When a unit gets enough experience (the experience bar is the smaller bar on the right), it will go up a level. Elvish Fighters have two options, and you will have a chance to choose which one you want. Note that level 2 units cost you twice as much to support as level 1 units."
                    #wmllint: display off
                [/message]
                {VARIABLE next_turn.advice_chain[5].turn $turn_number}
                {VARIABLE_OP next_turn.advice_chain[5].turn add 1}
            [/then]
        [/if]
        [if]
            [variable]
                name=next_turn.advice_chain[5].turn
                equals=$turn_number
            [/variable]
            [then]
                [message]
                    speaker=narrator
                    #wmllint: display on
                    message=_ "Note:
Once you select a unit, you'll see percentages for different terrain tiles. The higher the percentage, the more defense that unit will have. For example, defense is good in castles and villages but bad in rivers. The dummy's attacks are magical, however, so they have a 70% chance of hitting you wherever you stand."
                    #wmllint: display off
                [/message]
            [/then]
        [/if]
    [/event]

    [event]
        name=die
        [filter]
            id=student
        [/filter]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    [event]
        name=die
        [filter]
            type=Quintain
        [/filter]
        {CLEAR_PRINT}
        [message]
            speaker=second_unit
            message=_ "The quintain is dead, and I have gained more experience!"
        [/message]
#wmlindent: start ignoring
        {GENDER ([message]
                id=Delfador
                message=_ "Yes, you gain experience through battle, especially by killing an opponent. Gain enough experience and you'll become more powerful." +
                _ " Now, Konrad, I will leave you with more dummies to practice on! After that, we have real work to do..."
        [/message]) ([message]
                id=Delfador
                message=_ "Yes, you gain experience through battle, especially by killing an opponent. Gain enough experience and you'll become more powerful." +
                _ " Now, Li'sar, I will leave you with more dummies to practice on! After that, we have real work to do..."
        [/message])}
#wmlindent: stop ignoring
        {VARIABLE quintain_dead 1}

        [unit]
            id=Quintain1
            type=Quintain
            ai_special="guardian"
            x,y=16,10
            side=2
        [/unit]
        [unit]
            id=Quintain2
            type=Quintain
            ai_special="guardian"
            x,y=13,11
            side=2
        [/unit]
        [unit]
            id=Quintain3
            type=Quintain
            ai_special="guardian"
            x,y=9,11
            side=2
        [/unit]

        {MOVE Delfador 14 8 2 1}
        [scroll_to_unit]
            type=Quintain
        [/scroll_to_unit]

        [kill]
            id=Delfador
        [/kill]
        [message]
            speaker=narrator
            #wmllint: display on
            message=_ "Note:
These dummies only attack if you are a single tile away. With care, you should be able to kill them one at a time."
            #wmllint: display off
        [/message]

        [event]
            name=new turn
            first_time_only=no
            [message]
                speaker=narrator
                message=_ "Do you want to keep practicing?"
                [option]
                    message=_ "Yes, I'm still figuring it out."
                [/option]
                [option]
                    message=_ "No, I think I've got it."
                    [command]
                        [endlevel]
                            result=victory
                            carryover_report=no
                            carryover_add=yes
                            carryover_percentage=0
                        [/endlevel]
                    [/command]
                [/option]
            [/message]
        [/event]
    [/event]

    [event]
        name=time over
        [if]
            [variable]
                name=quintain_dead
                numerical_equals=1
            [/variable]
            [then]
                [endlevel]
                    result=victory
                    carryover_report=no
                    carryover_add=yes
                    carryover_percentage=0
                [/endlevel]
            [/then]
            [else]
                [endlevel]
                    result=defeat
                [/endlevel]
            [/else]
        [/if]
    [/event]

    [event]
        name=victory
        [message]
            speaker="narrator"
            message=_ "After your victory notice, the map will be grayed out to indicate that the scenario is over, but you will be able to examine the final positions and state of your troops before clicking 'End Scenario' to continue to the next scenario."
        [/message]
        {CLEAR_VARIABLE next_turn}
        {CLEAR_VARIABLE target_hex}
    [/event]

    # Experience tracking needed in Scenario2 code
    [event]
        name=advance
        first_time_only=no
        {VARIABLE_OP unit.variables.previous_xp add $unit.max_experience}
        [unstore_unit]
            variable=unit
            advance=false
        [/unstore_unit]
    [/event]
[/tutorial]
