#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 the 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 Part I"
    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
        save_id=human_player
        persistent=yes
        gold=100
        canrecruit=yes
        side=1
        controller=human
    [/side]
    #! -- No leader means NO DESCRIPTIONS. Period.
    [side]
        no_leader=yes
        side=2
        controller=ai
        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT caution 0}
            {AI_SIMPLE_ALWAYS_ASPECT aggression 1}
            [goal]
                [criteria]
                    id=student
                [/criteria]
                value=10
            [/goal]
            [goal]
                [criteria]
                    id=Delfador
                [/criteria]
                value=.1
            [/goal]
        [/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
                caption= _"Welcome to Wesnoth!"
                message= _"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
                caption= _"Welcome to Wesnoth!"
                message= _"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 <b>Here</b>." +
                {CONTINUE_MSG}
        [/message]) ([message]
                speaker=narrator
                message= _"Move Li’sar next to Delfador by clicking on the tile marked <b>Here</b>." +
                {CONTINUE_MSG}
        [/message])}
#wmlindent: stop ignoring
        {TARGET_HEX 12 5}
        {PRINT (_"Left click on tile labeled <b>Here</b>")}
    [/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
                    caption= _"Oops!"
                    #wmllint: display on
                    message= _"You moved to the wrong place! After this message, you can press <b>u</b> 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]
        [color_adjust]
            red=100
            green=100
            blue=100
        [/color_adjust]
        [delay]
            time=10
        [/delay]
        [color_adjust]
            red=0
            green=0
            blue=0
        [/color_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 fight a dummy?"
        [/message]

#wmlindent: start ignoring
        {GENDER (
            [message]
                id=Delfador
                message= _"You have 32 hitpoints and a sword, boy. I’m fairly sure you’ll win."
            [/message]
        ) (
            [message]
                id=Delfador
                message= _"female^Young lady, you have 32 hitpoints and a sword. I’m fairly sure you’ll win."
            [/message]
        )}
#wmlindent: stop ignoring

#wmlindent: start ignoring
        {GENDER ([message]
                speaker=narrator
                caption= _"Attacking"
                # wmllint: local spelling OK
                message= _"To attack the quintain, first select the attacker (Konrad) then the target (the quintain). You will see an attack description. When you click <b>OK</b>, Konrad will attack." +
        {CONTINUE_MSG}
        [/message]) ([message]
                speaker=narrator
                caption= _"Attacking"
                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 <b>OK</b>, 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 sub 3}
    [/event]

    [event]
        name=defender_hits
        first_time_only=no
        [filter]
            id=student
        [/filter]
        {VARIABLE_OP student_hp sub 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, perhaps 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
                caption= _"Crowns"
                message= _"The tiny metal 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
                caption= _"Crowns"
                message= _"The tiny metal 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 sub 15}
#wmlindent: start ignoring
        {GENDER (
            [message]
                id=Delfador
                message= _"Unfortunately, you’ve used up your turn attacking the quintain. The quintain now gets to attack."
            [/message]
        ) (
            [message]
                id=Delfador
                message= _"female^Unfortunately, you’ve used up your turn attacking the quintain. The quintain now gets to attack."
            [/message]
        )}
#wmlindent: stop ignoring
        [message]
            id=student
            message= _"The <i>dummy</i> 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 <b>End Turn</b> button in the bottom right of the screen")}
        {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
                        caption= _"Villages"
                        # We could say 'It now flies your colors...'. Maybe too subtle for a basic tutorial?
                        message= _"You have captured a village! It now flies your flag and has been added to your total village count. (The house icon at the top of the screen shows how many villages you currently control.) 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 <b>End Turn</b> 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 sub $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 it’s time to summon some help against that quintain."
                    [/message]
                ) (
                    [message]
                        id=Delfador
                        message= _"female^You’re about to be healed by $hp_difference hitpoints, but it’s time to summon 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
                        caption= _"Recruiting"
                        #wmllint: display on
                        message= _"Whenever you’re on a <i>keep</i>, you can <i>recruit</i> into the castle tiles around it by right-clicking and selecting <b>Recruit</b>. 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 a castle tile and select <b>Recruit</b>")}
                [/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 2"
                        [/have_unit]
                        [then]
                            {CLEAR_PRINT}
                            [redraw][/redraw]
                            [message]
                                speaker=narrator
                                caption= _"New Recruits"
                                #wmllint: display on
                                message= _"New units cannot act in the turn they appear; you will gain control of them next turn.
After this dialog, you can move the mouse over a unit to see a summary of its abilities 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 <b>End Turn</b> 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 2"
                        [/have_unit]
                        [then]
                            {CLEAR_PRINT}
                            [redraw][/redraw]
                            [message]
                                speaker=narrator
                                caption= _"New Recruits"
                                #wmllint: display on
                                message= _"New units cannot act in the turn they appear; you will gain control of them next turn.
After this dialog, you can move the mouse over a unit to see a summary of its abilities 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 <b>End Turn</b> 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 <i>melee</i> attack. The quintain defended with its melee attack (3–5)." + _" The ranged attack would have been 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 <i>melee</i> attack. The quintain defended with its melee attack (3–5)." + _" The ranged attack would have been safer." + _"
End your turn, then attack again."
                                        #wmllint: display off
                                    [/message]
                                    {PRINT (_"Click on the <b>End Turn</b> 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 <i>melee</i> 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 <i>ranged</i> 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 <i>ranged</i> 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 <b>End Turn</b> button")}
                                [/else]
                            [/if]
                        [/then]
                        [else]
                            [message]
                                id=Delfador
                                message= _"Your elf used a bow, which is a <i>ranged</i> 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
                    caption= _"Unit Descriptions"
                    #wmllint: display on
                    message= _"You can right click on a unit to see a detailed <b>Unit Description</b>."
                    #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
                            caption= _"Protect Your Troops"
                            #wmllint: display on
                            message= _"Remember to pull back wounded units into villages and recruit more if needed. Take special care of units with the highest <i>experience points (XP)</i> so they can gain levels and become more powerful."
                            #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
                    caption= _"Support"
                    #wmllint: display on
                    message= _"Each village you control will <i>support</i> one 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
                    caption= _"Advancement"
                    #wmllint: display on
                    message= _"When a unit gains enough experience points (the <i>experience bar</i>, if present, is on the <b>right</b> of the <i>hitpoints bar</i>), it will go up a level. Elvish Fighters have two advancement options, and you will be able to choose which one you want. However, second level units cost twice as much to support as first level 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
                    caption= _"Defenses"
                    # wmllint: local spelling quintains
                    #wmllint: display on
                    message= _"Whenever one of your units is selected, you’ll see varying percentages as you move the mouse over the map. The higher the percentage, the more <i>defense</i> that unit has in that kind of terrain. For example, most units have good defenses in castles and villages but poor defenses in rivers. However, these quintains use a <i>magical</i> attack, which always has a 70% chance of hitting no matter what terrain its target occupies."
                    #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 destroyed, 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
            caption= _"Note"
            #wmllint: display on
            message= _"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"
            caption= _"Victory"
            message= _"After your victory notice, the map will be grayed out to indicate that the scenario is over, but you will still be able to examine the final positions and state of your troops and any surviving enemies. This is called <i>linger mode</i>. When you’re finished, click the <b>End Scenario</b> button to go on the next scenario in the campaign."
        [/message]
        {CLEAR_VARIABLE next_turn}
        {CLEAR_VARIABLE target_hex}
    [/event]

    [event]
        name=defeat
        {CLEAR_PRINT}
    [/event]

    # Experience tracking needed in Scenario2 code
    # Give them roles of 'Veteran' as well or instead? Lets you track 0XP units cleanly.
    [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]
