#textdomain wesnoth-tutorial

[tutorial]
    id=2_Tutorial
    name= _ "Wesnoth Tutorial — Part II"
    map_data="{campaigns/tutorial/maps/02_Tutorial_part_2.map}"
    turns=36
    experience_modifier=100

    {DEFAULT_SCHEDULE}

    {SCENARIO_MUSIC       battle-epic.ogg}
    {EXTRA_SCENARIO_MUSIC the_city_falls.ogg}
    {EXTRA_SCENARIO_MUSIC casualties_of_war.ogg}
    {EXTRA_SCENARIO_MUSIC heroes_rite.ogg}
    {EXTRA_SCENARIO_MUSIC northerners.ogg}

    [side]
        side=1
        controller=human
        recruit=Elvish Fighter,Elvish Archer,Elvish Shaman
        gold=120
        save_id=human_player
        persistent=yes
        team_name=player
        user_team_name= _ "team_name^Student"

        type=Fighter
        id=student
        name= _ "Konrad"
        unrenamable=yes
        canrecruit=yes

        facing=se
    [/side]

    [side]
        side=2
        controller=ai
        recruit=Orcish Grunt,Wolf Rider,Orcish Archer
        gold=100
        team_name=orcs
        user_team_name= _ "team_name^Orcs"

        type=Orcish Warrior
        id=Thrag
        name= _ "Thrag"
        canrecruit=yes

        facing=nw

        [unit]
            id=Dumbo
            generate_name=yes
            type=Orcish Grunt
            x,y=15,12
            ai_special=guardian
            facing=nw
            random_traits=no
        [/unit]

        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression    1.00}
            {AI_SIMPLE_ALWAYS_ASPECT village_value 0.30}
            # Galdrad's hints about getting to the island village before the wolf riders assume that some will be recruited by the end of turn 2, but won't be able to get to that village until turn 4.
            [aspect]
                id=recruitment_instructions
                [facet]
                    turns=1
                    [value]
                        [recruit]
                            type=Orcish Grunt,Orcish Archer
                        [/recruit]
                    [/value]
                [/facet]
                [facet]
                    turns=2
                    [value]
                        [recruit]
                            type=Wolf Rider
                            number=2
                            importance=1
                        [/recruit]
                        [recruit]
                            importance=0
                        [/recruit]
                    [/value]
                [/facet]
            [/aspect]
            [goal]
                name=target_location
                [criteria]
                    x,y=10,3
                [/criteria]
                value=2
            [/goal]
        [/ai]
    [/side]

    [side]
        side=3
        controller=null
        team_name=player
        user_team_name= _ "team_name^Student"
        no_leader=yes
        hidden=yes

        [unit]
            id=Galdrad
            name= _ "Galdrad"
            type=Elvish Champion
            x,y=4,11
            random_traits=no
            {IS_HERO}
            facing=ne
        [/unit]
    [/side]

    [event]
        name=prestart

        {VARIABLE lhpu_msg_i 0}

        {VARIABLE low_hp_unit_message[0].value ( _ "I hope I have a chance to retreat after this!")}
        {VARIABLE low_hp_unit_message[1].value ( _ "One lucky attack by an Orcish Grunt, and I’m done for!")}
        {VARIABLE low_hp_unit_message[2].value ( _ "I could make use of some healing in a village.")}
        {VARIABLE low_hp_unit_message[3].value ( _ "I had better retreat, before I get caught out with such low health!")}
        {VARIABLE low_hp_unit_message_female[0].value ( _ "female^I hope I have a chance to retreat after this!")}
        {VARIABLE low_hp_unit_message_female[1].value ( _ "female^One lucky attack by an Orcish Grunt, and I’m done for!")}
        {VARIABLE low_hp_unit_message_female[2].value ( _ "female^I could make use of some healing in a village.")}
        {VARIABLE low_hp_unit_message_female[3].value ( _ "female^I had better retreat, before I get caught out with such low health!")}

        [objectives]
            side=1
            [objective]
                description= _ "Defeat the Orc Leader"
                condition=win
            [/objective]

            [objective]
                description= _ "Death of Konrad"
                condition=lose
                [show_if]
                    [have_unit]
                        id=student
                        gender=male
                    [/have_unit]
                [/show_if]
            [/objective]

            [objective]
                description= _ "Death of Li’sar"
                condition=lose
                [show_if]
                    [have_unit]
                        id=student
                        gender=female
                    [/have_unit]
                [/show_if]
            [/objective]

            [objective]
                description= _ "Death of Galdrad"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}
        [/objectives]

        [if]
            [have_unit]
                canrecruit=yes
                gender=female
            [/have_unit]
            [then]
                [modify_side]
                    side=1
                    side_name=_"Li’sar"
                [/modify_side]
            [/then]
        [/if]

        [disallow_end_turn]
            reason=_"You cannot end your turn until you have recruited troops and captured a village!"
        [/disallow_end_turn]

        {VARIABLE undo_option yes}
    [/event]

    [event]
        name=start

        [message]
            speaker=narrator
            caption= _ "Welcome to Wesnoth!"
            image=wesnoth-icon.png
            message= _ "Welcome back! This is second part of the two-part tutorial. Part 2 will teach you about recalling units, abilities and weapon specials, income and upkeep, long-distance movement, zone of control, and time of day." +
                {CONTINUE_MSG}
        [/message]

        [message]
            speaker=student
            message= _ "Ho, Galdrad! Has Delfador conjured something else to beat me with? A flock of scarecrows, perhaps?"
            female_message= _ "female^Ho, Galdrad! Has Delfador conjured something else to beat me with? A flock of scarecrows, perhaps?"
        [/message]

        {GENDER (
            [message]
                speaker=Galdrad
                message= _ "This is no game, Konrad! Orcs have encamped across the river. This is elven country; they are fools to enter here. We Elves are fast and hard to hit in forests. You must defeat their leader so they never threaten us again. I will advise you."
            [/message]
        ) (
            [message]
                speaker=Galdrad
                message= _ "This is no game, Li’sar! Orcs have encamped across the river. This is elven country; they are fools to enter here. We Elves are fast and hard to hit in forests. You must defeat their leader so they never threaten us again. I will advise you."
            [/message]
        )}

        [message]
            speaker=student
            message= _ "What should I do?"
            female_message= _ "female^What should I do?"
        [/message]

        {TALK_ABOUT Dumbo ( _ "First, we will have to deal with the Orcish Grunt stationed in the middle of the river. He should be little trouble.")}

        {TALK_ABOUT Thrag ( _ "By then, their leader will have recruited more units to send against us and the real fight will begin.")}

        {TALK_ABOUT_LOC 15,4 ( _ "See this dark blue water? It’s too deep for either side to cross. The orcs could slowly wade through that narrow band of shallow lighter-blue water in the north; but we could stand on the shore and force them to fight us from the water, where they are exposed and we are protected by the forest.")}

        {TALK_ABOUT_LOC 17,11 ( _ "The more likely attack, then, is across the bridge. That middle island is the key: it has a village for healing injured units and forests in which we fight so well.")}

        [message]
            speaker=student
            message= _ "Let’s go! Attack!"
            # po: The "us" in "let's" refers to Galdrad and Li'sar.
            female_message= _ "female^Let’s go! Attack!"
        [/message]

        {GENDER (
            [message]
                speaker=Galdrad
                # po: Addressing Konrad
                message= _ "Hang on! You need to gather your forces. Or do you intend to fight the orcs single-handedly?"
            [/message]
        ) (
            [message]
                speaker=Galdrad
                # po: Addressing Li'sar
                message= _ "female^Hang on! You need to gather your forces. Or do you intend to fight the orcs single-handedly?"
            [/message]
        )}

        [if]
            # Do we have a recall list at all? It’s possible that the player lost all their units in the first scenario
            [have_unit]
                side=1
                x,y=recall,recall
                search_recall_list=yes
            [/have_unit]
            [then]
                [message]
                    speaker=Galdrad
                    message= _ "I see you have veteran troops from your training! You should <i>recall</i> them so as to start off the battle with more experienced units. Think carefully, though; if a unit has too little experience, it might be better to recruit a new one."
                [/message]

                # It's impossible to have a lvl 3 unit by now, and rare to even have a lvl 2, but let's mention it anyway
                [message]
                    speaker=Galdrad
                    message= _ "Some of your units have also managed to level up. They’re even more formidable, so you should recall them as well."
                    [show_if]
                        [have_unit]
                            side=1
                            x,y=recall,recall
                            level=2,3
                            search_recall_list=yes
                        [/have_unit]
                    [/show_if]
                [/message]
            [/then]
            [else]
                # Unlikely in any case
                [message]
                    speaker=Galdrad
                    message= _ "Unfortunately, none of your troops survived your training, so you will have to recruit new units. If you had any veteran troops, you could have <i>recalled</i> them to battle this scenario. More experienced units would have been of help against these orcs."
                [/message]
            [/else]
        [/if]

        [message]
            speaker=narrator
            caption= _ "Recalling"
            image=wesnoth-icon.png
            message= _ "In addition to recruiting new units each scenario, you can also <i>recall</i> your experienced veterans from previous scenarios, for the cost of 20 gold each. This allows you to build up a formidable army over the course of multiple scenarios by recalling your highest leveled troops or those with good combinations of traits and abilities. To recall a unit, right click while your leader stands on a keep and select the <i>Recall</i> option. Remember to also recruit new troops in addition to recalling old ones."
        [/message]

        [message]
            speaker=Galdrad
            message= _ "You also have two new types of units to recruit this scenario: Elvish Archers and Elvish Shamans. I’ll tell you more about them when you recruit them. Personally, I would recommend a balanced force of two archers, two fighters, and a shaman."
        [/message]

        {PRINT ( _ "Recruit or recall your troops")}
    [/event]

    # Explaining the Shaman
    [event]
        name=recruit
        [filter]
            side=1
            type=Elvish Shaman
        [/filter]

        [message]
            speaker=narrator
            image=$unit.profile
            caption= _ "Elvish Shaman"
            message= _ "The Shaman has the ability to <i>heal</i> friendly units around her. She also has a special attack which <i>slows</i> enemies, halving the damage they do for one turn. However, she’s physically weaker than fighters and archers, so be careful when sending her into battle."
        [/message]

        [message]
            speaker=narrator
            caption= _ "The <i>Heal</i> Ability"
            image=wesnoth-icon.png
            message= _ "At the start of each turn, allied units adjacent to a Shaman will recover 4 hitpoints, which is only half of the amount that a village would provide. The Shaman doesn’t gain experience from healing, only from combat, but advancing her is worthwhile — her second-level Elvish Druid advancement has healing equivalent to a village.

A detailed explanation of healing may be found in the <i>Gameplay</i> section of the help (default hotkey: <b>F1</b>)."
        [/message]

        [message]
            speaker=narrator
            caption= _ "Weapon Specials"
            image=wesnoth-icon.png
            message= _ "Weapon specials are special attack modifiers that make certain attacks more powerful. In this case, the Shaman has the Slows special on her entangle attack. When this attack successfully hits an enemy, it will halve the damage they do for one turn. Other weapon specials include First Strike, which allows that attack to always hit first no matter who attacks first, and Magical, which gives that attack a constant 70% chance to hit.

A full list of abilities and weapons specials, along with traits, may be found in the help (default hotkey: <b>F1</b>)."
        [/message]
    [/event]

    # Triggers the first time that the player has two healers.
    # If there are allied sides then this isn't accurate, but at this stage of the tutorial allied sides haven't been introduced yet.
    [event]
        name=recruit
        [filter]
            side=1
            type=Elvish Shaman
        [/filter]
        [filter_condition]
            [have_unit]
                ability_type=heals
                count=2
            [/have_unit]
        [/filter_condition]

        [if]
            [have_unit]
                type=Elvish Shaman
                count=2
            [/have_unit]
            [then]
                [message]
                    speaker=narrator
                    image=$unit.profile
                    caption= _ "Multiple Healers"
                    # po: both healers are level one elvish shamans
                    message= _ "You now have two healers. However, each unit can only receive healing from one healer — a unit will still only be healed 4 hitpoints per turn even when adjacent to both Shamans.

If either Shaman advances to become a Druid, then she’ll be able to heal adjacent units by 8 hitpoints per turn. A unit next to multiple healers is healed by the most advanced one."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=narrator
                    image=$unit.profile
                    caption= _ "Multiple Healers"
                    # po: one healer is a level one shaman, but the other healer is a druid or (very unlikely) a shyde
                    message= _ "You now have two healers. Your Druid can heal adjacent units by 8 hitpoints per turn compared to your Shaman's 4. However, each unit can only receive healing from one healer — a unit next to multiple healers is healed by the most advanced one."
                [/message]
            [/else]
        [/if]
        [message]
            speaker=narrator
            image=$unit.profile
            caption= _ "Healers and Villages"
            message= _ "A unit in a village will receive healing from the village instead of from adjacent healers."
        [/message]
        [message]
            speaker=Galdrad
            message= _ "Having more than one healer allows them to heal each other or to cover separate areas of the battlefield. It can also allow better tactical movement — the 2 hitpoints from rest-healing does combine with other sources of healing, so it’s often better to move a healer instead of an injured unit."
        [/message]
    [/event]

    # Explaining the Archer
    [event]
        name=recruit
        [filter]
            side=1
            type=Elvish Archer
        [/filter]

        [message]
            speaker=narrator
            image=$unit.profile
            caption= _ "Elvish Archer"
            message= _ "Unlike the Elvish Fighter, which has strong melee attacks, the Elvish Archer has strong ranged attacks. It’s useful to attack enemy units with strong melee attacks with strong ranged attacks, and vice versa. This allows your units to take less damage overall when your enemy counterattacks."
        [/message]
    [/event]

    # Mention upkeep and income
    [event]
        name=recruit,recall
        [filter]
            side=1
        [/filter]
        [filter_condition]
            [variable]
                name=turn_number
                numerical_equals=1
            [/variable]
            [have_unit]
                side=1
                race=elf
                count=5
            [/have_unit]
        [/filter_condition]

        {CLEAR_PRINT}

        # Easter egg if you recruit all Shamans
        [message]
            speaker=Galdrad
            message= _ "You certainly have a fondness for shamans, I see. They will provide a lot of healing, but not much offensive potential."
            [show_if]
                [have_unit]
                    type=Elvish Shaman
                    count=5
                [/have_unit]
            [/show_if]
        [/message]

        [message]
            speaker=Galdrad
            message= _ "While none of your recruited units can move yet, you still can. You need more income; there are some villages near the keep you can capture."
        [/message]

        {PRINT ( _ "Capture a village")}

        [disallow_end_turn]
            reason=_"You still have to capture a village!"
        [/disallow_end_turn]
    [/event]

    [event]
        name=capture
        first_time_only=no

        [filter]
            side=1
        [/filter]
        [filter_condition]
            [variable]
                name=turn_number
                numerical_equals=1
            [/variable]
        [/filter_condition]

        {CLEAR_PRINT}

        # NOTE: maybe give live income stats?

        [if]
            [not]
                [have_unit]
                    side=1
                    race=elf
                    count=5
                [/have_unit]
            [/not]
            [then]
                {PRINT ( _ "You forgot to recruit troops! You can press <b>u</b> to undo your last move.")}

                [disallow_end_turn]
                    reason=_"You still have to recruit troops!"
                [/disallow_end_turn]

                [allow_undo] [/allow_undo]
            [/then]
            [else]
                [message]
                    speaker=Galdrad
                    message= _ "Excellent! As Delfador mentioned earlier, each captured village will support one unit and provide you with 1 extra gold per turn."
                [/message]

                [message]
                    speaker=narrator
                    caption= _ "Income and Upkeep"
                    image=wesnoth-icon.png
                    message= _ "Each turn, you will gain 2 gold plus one for each village you own. However, <i>upkeep</i> is subtracted from that. You can support as many levels worth of units as the number of villages you own; beyond that, you must pay 1 gold per turn. Be careful, as owning too many units can cause you to have negative income and lose gold each turn!"
                [/message]

                [message]
                    speaker=narrator
                    caption= _ "Status Table"
                    image=wesnoth-icon.png
                    message= _ "The Status Table details the sides’ current status and starting conditions. Fog and shroud will affect what you can see in this table, and occasionally a side may be hidden; however, it is still useful to check this table when a scenario begins. You can access it in the <b>Menu</b> menu."
                [/message]

                [allow_end_turn][/allow_end_turn]

                {PRINT (_"End your turn")}
                [event]
                    name=side 1 turn end
                    {CLEAR_PRINT}
                [/event]
            [/else]
        [/if]

        [on_undo]
            {CLEAR_PRINT}

            {PRINT ( _ "Recruit or recall your troops")}
        [/on_undo]
    [/event]

    [event]
        name=moveto
        first_time_only=no

        [filter]
            id=student
            x=1-40
            y=1-20
            [not]
                x=5,3,5
                y=9,8,13
            [/not]
        [/filter]
        [filter_condition]
            [variable]
                name=turn_number
                numerical_equals=1
            [/variable]
        [/filter_condition]

        [if]
            [not]
                [have_unit]
                    side=1
                    race=elf
                    count=5
                [/have_unit]
            [/not]
            [then]
                {CLEAR_PRINT}

                {PRINT ( _ "You forgot to recruit troops! You can press <b>u</b> to undo your last move.")}

                [allow_undo] [/allow_undo]

                [on_undo]
                    {CLEAR_PRINT}

                    {PRINT ( _ "Recruit or recall your troops")}
                [/on_undo]
            [/then]
            [else]
                {CLEAR_PRINT}

                {PRINT ( _ "You forgot to capture a village! You can press <b>u</b> to undo your last move.")}

                [allow_undo] [/allow_undo]

                [on_undo]
                    {CLEAR_PRINT}

                    {PRINT ( _ "Capture a village")}
                [/on_undo]
            [/else]
        [/if]
    [/event]

    [event]
        name=turn 2

        {GENDER (
            [message]
                speaker=Galdrad
                message= _ "Now, young man, it is time to discuss strategy. Your units are ready to attack, and the orcish leader has begun gathering his own troops."
            [/message]
        ) (
            [message]
                speaker=Galdrad
                message= _ "Now, young lady, it is time to discuss strategy. Your units are ready to attack, and the orcish leader has begun gathering his own troops."
            [/message]
        )}

        [message]
            speaker=student
            message= _ "Galdrad, if I go by the ford, I could sneak up near his keep and dispatch him quickly."
            female_message= _ "female^Galdrad, if I go by the ford, I could sneak up near his keep and dispatch him quickly."
        [/message]

        [message]
            speaker=Galdrad
            message= _ "You could. However, elves (and orcs) have bad <i>defense</i> in water. You’ll be more vulnerable as you try to wade slowly across the ford; the enemy will have an 80% chance to hit you. Since elves have good defense in the forest, I would advise you keep to the trees and attack the orcs from there; your Fighters will only suffer a 40% chance of being hit in return, while Shamans and Archers will only incur a 30% chance."
        [/message]

        [message]
            speaker=Galdrad
            message= _ "However, keep an eye on that ford. The orcs may try to sneak around behind our forces. It might do to send a few units to defend the banks, and the village there."
        [/message]

        [message]
            speaker=student
            message= _ "Alright. The bridge it is, then, but I’ll be careful about the crossing."
            female_message= _ "female^Alright. The bridge it is, then, but I’ll be careful about the crossing."
        [/message]

        {TALK_ABOUT Dumbo ( _ "That Orcish Grunt is still blocking our path. He has no ranged attacks, so your archers should be able to engage him with little risk. Unfortunately, your units cannot reach him this turn, but you should not let them languish! Move them into position so they can attack next turn. There are also other villages on this side of the river. You should secure them for income and healing.")}

        [message]
            speaker=narrator
            caption= _ "Long-distance Movement"
            image=wesnoth-icon.png
            message= _ "You can order a unit to move for multiple turns by selecting the unit and clicking on the destination. A number will indicate how many turns it will take to get there."
        [/message]

        [message]
            speaker=student
            message= _ "I think I’ll stick around the keep for now, in order to recruit more units."
            female_message= _ "female^I think I’ll stick around the keep for now, in order to recruit more units."
        [/message]

        {GENDER (
            [message]
                speaker=Galdrad
                message= _ "You’ve learned well, Konrad. It is indeed a good idea to keep your leader safe and protected and in range of your keep early in the game. The tide of battle can turn quickly, and you don’t want to find yourself cut off from recruiting reinforcements."
            [/message]
        ) (
            [message]
                speaker=Galdrad
                message= _ "You’ve learned well, Li’sar. It is indeed a good idea to keep your leader safe and protected and in range of your keep early in the game. The tide of battle can turn quickly, and you don’t want to find yourself cut off from recruiting reinforcements."
            [/message]
        )}
    [/event]

    # If the player didn't provide bait for Dumbo, the guardian AI won't move
    # him, and that makes the scenario much harder than it should be. Hardcode
    # the exact move that we want rather than switching to the normal AI, as
    # the normal AI would probably take the village instead.
    [event]
        name=side 2 turn 2 end

        [if]
            [have_unit]
                id=Dumbo
                x,y=15,12
            [/have_unit]
            [not]
                # Sanity check, if there's a unit anywhere here then the Guardian AI
                # is expected to have attacked it; if not then something complex is
                # happening (maybe the player already has a Ranger with Ambush).
                #
                # The sanity check isn't to see if the guardian AI has moved
                # the unit, it's to check that moving from 15,12 to 10,9 doesn't
                # walk through a ZoC. We're in a side-end-turn event and
                # Dumbo's still on his starting point, so the guardian AI has
                # already decided not to move him (or a unit managed to get to
                # 14,11 for a fight, in which case let's show the sanity check
                # failure message anyway).
                [have_unit]
                    x=12-14
                    y=9-12
                [/have_unit]
            [/not]
            [then]
                [move_unit]
                    id=Dumbo
                    to_x,to_y=10,9
                [/move_unit]
            [/then]
        [/if]

        # Something has triggered the sanity check. If you want to test this,
        # use a unit with Ambush to put a ZoC on his path (which the player
        # won't have at this stage of the tutorial, any elvish archers that
        # they have will be fresh recruits).
        [if]
            [have_unit]
                id=Dumbo
            [/have_unit]
            [not]
                [have_unit]
                    id=Dumbo
                    x=1-12
                [/have_unit]
            [/not]
            # But not if the player has run on to the bridge themselves to attack.
            # That does make it harder, but the player can likely attack from 2 or
            # 3 sides, if they ignore the warning about attacking from water.
            [not]
                [have_unit]
                    side=1
                    [filter_adjacent]
                        id=Dumbo
                    [/filter_adjacent]
                [/have_unit]
            [/not]
            [then]
                [message]
                    speaker=narrator
                    caption= _ "The tutorial isn’t meant to be this difficult"
                    image=wesnoth-icon.png
                    message= _ "The orc on the island was supposed to move over the bridge, so that he could be attacked by several elves at once. Something’s broken the scripted event, which will make the scenario harder by leaving him in a defensive position.

Please report the bug."
                [/message]
            [/then]
        [/if]
    [/event]

    [event]
        name=turn 3

        [message]
            speaker=narrator
            caption= _ "Tracking Enemy Movement"
            image=wesnoth-icon.png
            message= _ "You can see where an enemy can reach by moving the mouse over them. You can see all possible enemy moves at once with the <b>Show Enemy Moves</b> command from the <b>Actions</b> menu."
        [/message]

        {TALK_ABOUT_LOC 15,11 ( _ "We must occupy that island before the Wolf Riders reach it!")}

        # Explain Zone of Control
        [message]
            speaker=student
            message= _ "Can’t we just move around the orcs?"
            # po: "we" refers to Li'sar, Galdrad, and the mixed-gender troops
            female_message= _ "female^Can’t we just move around the orcs?"
        [/message]

        # All around Dumbo
        [item]
            image=misc/highlight-hex.png
            [filter_adjacent_location]
                [filter]
                    id=Dumbo
                [/filter]
            [/filter_adjacent_location]
        [/item]

        {TALK_ABOUT Dumbo ( _ "No. Once you move close to an enemy unit, you are in its <i>Zone of Control</i> and cannot move further that turn. To move your troops onto that island without wading slowly through the water, you’ll have to kill the Grunt.")}

        [message]
            speaker=narrator
            caption= _ "Zone of Control"
            image=wesnoth-icon.png
            message= _ "The hexes immediately around a unit constitute its <i>Zone of Control</i>. When an enemy unit enters those hexes, they cannot move any further that turn. (An exception are units with the <i>skirmisher</i> ability, who are unaffected by zones of control.) This can be used to create a blockade to prevent stronger enemies from reaching key locations, such as villages, even if you have limited manpower."
        [/message]

        [remove_item]
            image=misc/highlight-hex.png
        [/remove_item]

        [event]
            name=attack_end
            [filter_second]
                id=Dumbo
            [/filter_second]

            [if]
                [variable]
                    name=unit.id
                    equals=student
                [/variable]
                [then]
                    [message]
                        speaker=student
                        message= _ "I hope I will survive the counter-attack if my units can’t take this grunt out this turn. I should order them to grab more villages if they can and move everyone closer for next turn."
                    [/message]

                    [message]
                        speaker=Galdrad
                        message= _ "If one of your Shamans stands just behind you, she will heal you 4 hitpoints at the beginning of the next turn."
                    [/message]
                [/then]
                [else]
                    [message]
                        speaker=student
                        message= _ "I hope my units will survive the counter-attack if I can’t take this grunt out this turn. I’d better grab more villages if I can and move everyone closer for next turn."
                    [/message]

                    [message]
                        speaker=Galdrad
                        message= _ "If one of your Shamans stands just behind your wounded units, she will heal them each 4 hitpoints at the beginning of the next turn."
                    [/message]
                [/else]
            [/if]

            [event]
                name=attack_end
                first_time_only=no
                [filter]
                    side=1
                    [not]
                        id=student
                    [/not]
                [/filter]

                [fire_event]
                    name=warn_about_units_with_low_health
                    [primary_unit]
                        id=$unit.id
                    [/primary_unit]
                    [secondary_unit]
                        id=$second_unit.id
                    [/secondary_unit]
                [/fire_event]
            [/event]
        [/event]
    [/event]

    [event]
        name=die
        [filter]
            id=Dumbo
        [/filter]

        [message]
            speaker=second_unit
            message= _ "One fewer orc to deal with, and our way across the bridge is clear! I also gained experience from striking the killing blow!"
            female_message= _ "female^One fewer orc to deal with, and our way across the bridge is clear! I also gained experience from striking the killing blow!"
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            x=17,18,19,20,21
            y=11,10,10,9,9
            side=1
        [/filter]
        [filter_condition]
            [variable]
                name=turn_number
                less_than=8
            [/variable]
        [/filter_condition]

        [message]
            speaker=Galdrad
            scroll=no
            message= _ "Be careful! If you stand on the bridge you are exposed to attack from multiple directions! Even though the orcs have low defense in water, they will overwhelm you with their numbers."
        [/message]

        {UNDO_REMINDER}
    [/event]

    # Capturing island village
    [event]
        name=capture
        [filter]
            side=1
            x,y=16,9
        [/filter]

        [message]
            speaker=Galdrad
            message= _ "Well done! The island village is ours. You can use the trees to set up a blockade against the orcs; they can only come across the bridge one by one without wading through the water, and you will be securely on a terrain with good defense."
        [/message]

        [if]
            [have_location]
                x,y=10,3
                [not]
                    owner_side=1
                [/not]
            [/have_location]

            [then]
                {TALK_ABOUT_LOC 10,3 ( _ "Don’t forget about that last village near the channel. The orcs will capture it if they try to sneak around via the ford! It will be hard to dislodge them if they do.")}
            [/then]
        [/if]
    [/event]

    [event]
        name=moveto
        [filter]
            [filter_location]
                terrain=Ww
            [/filter_location]
            side=1
        [/filter]

        [message]
            speaker=Galdrad
            scroll=no
            message= _ "It’s very dangerous to stand in water when there are enemies about! Your unit will have an 80% chance of being hit. Get back, and wait for them to attack you!"
        [/message]

        {UNDO_REMINDER}

        # cancel an eventually started attack to still allow undoing after the warning
        [cancel_action][/cancel_action]
    [/event]

    # Remind them to keep back
    [event]
        name=moveto
        [filter]
            id=student
            x=8-20
            y=1-20
        [/filter]
        [filter_condition]
            [variable]
                name=turn_number
                less_than=8
            [/variable]
        [/filter_condition]

        [message]
            speaker=Galdrad
            message= _ "You’re venturing away from your keep. You might need recruit more units, and I doubt the orc leader will let you use his! Careful!"
        [/message]

        {UNDO_REMINDER}
    [/event]

    [event]
        name=turn 4
        [filter_condition]
            [have_location]
                x,y=16,9
                [not]
                    owner_side=1
                [/not]
            [/have_location]
        [/filter_condition]

        {TALK_ABOUT_LOC 16,9 ( _ "We need to occupy that village, otherwise they will take it soon! Move a unit into the village to stop the orcs capturing it. Whichever unit you choose will benefit from the village’s healing, too.")}
    [/event]

    [event]
        name=turn 5

        {TALK_ABOUT_LOC 16,9 ( _ "Careful! It is now nighttime. Orcs are <i>chaotic</i>, which means their attacks are now 25% stronger. By day, their attacks are 25% weaker, which is a noticeable difference. You are <i>lawful</i>: stronger by day and weaker at night. Your elvish warriors are <i>neutral</i>: unaffected by the time of day.")}

        [message]
            speaker=narrator
            caption= _ "Time of Day"
            image=wesnoth-icon.png
            message= _ "During a scenario, the time of day will shift as turns pass. There are four <i>alignments</i> a unit may be: Lawful, Neutral, Chaotic, or Liminal. Each alignment gets a different bonus or handicap depending on the time of day. You can hover over the sky image below the minimap on the right to see the current time of day and who has the advantage."
        [/message]
    [/event]

    [event]
        name=turn 6

        [fire_event]
            name=check_income
        [/fire_event]

        # Just in case the player still hasn't captured 16,9.
        [if]
            [have_location]
                x,y=16,9
                owner_side=1
            [/have_location]
            [then]
                {TALK_ABOUT_LOC 16,9 ( _ "Remember to retreat your wounded units to villages. Shamans can only heal 4 hitpoints per turn, while villages can heal them faster at 8 per turn.

Different sources of healing are generally not combined. If a unit starts its turn next to multiple healers, or on a village and next to a healer, it will still be healed only once.

Rest-healing is an exception to the rule — if a unit doesn’t do anything for a turn, it will heal 2 hitpoints in addition to any healing it may receive from villages or healers, combining for a total of up to 10 hitpoints per turn.")}
            [/then]
            [else]
                {TALK_ABOUT_LOCS 11,8 9,12 ( _ "Remember to retreat your wounded units to villages. Shamans can only heal 4 hitpoints per turn, while villages can heal them faster at 8 per turn.

Different sources of healing are generally not combined. If a unit starts its turn next to multiple healers, or on a village and next to a healer, it will still be healed only once.

Rest-healing is an exception to the rule — if a unit doesn’t do anything for a turn, it will heal 2 hitpoints in addition to any healing it may receive from villages or healers, combining for a total of up to 10 hitpoints per turn.")}
            [/else]
        [/if]
    [/event]

    [event]
        name=turn 7

        [fire_event]
            name=check_income
        [/fire_event]
    [/event]

    [event]
        name=turn 9

        [message]
            speaker=narrator
            caption= _ "Tracking Unused Units"
            image=wesnoth-icon.png
            message= _ "You can ensure you use all your troops by pressing <b>n</b> to step from one unit to the next. If you press <b>space</b>, you can mark the currently selected unit as having finished its turn, which stops you moving it by accident later on. When <b>n</b> no longer selects a new unit, it’s safe to end your turn."
        [/message]
    [/event]

    [event]
        name=turn 10

        [message]
            speaker=narrator
            caption= _ "Victory Conditions"
            image=wesnoth-icon.png
            message= _ "In this scenario, you only need to defeat the orc leader to win. Victory conditions for a scenario are given under <b>Scenario Objectives</b> in the <b>Menu</b> menu."
        [/message]
    [/event]

    [event]
        name=turn 28

        [message]
            speaker=Galdrad
            message= _ "Hurry up and defeat the orcs before they become entrenched!"
        [/message]
    [/event]

    [event]
        name=check_income
        first_time_only=no
        [filter_condition]
            [variable]
                name=spoke_about_income
                boolean_equals=no
            [/variable]
        [/filter_condition]

        [store_gold]
            side=1
        [/store_gold]

        [if]
            [variable]
                name=gold
                greater_than=13
            [/variable]
            [then]
                {VARIABLE spoke_about_income yes}

                [message]
                    speaker=student
                    message= _ "I have enough gold to recruit more units!"
                    female_message= _ "female^I have enough gold to recruit more units!"
                [/message]

                [message]
                    speaker=Galdrad
                    message= _ "Good idea!"
                [/message]

                [message]
                    speaker=narrator
                    caption= _ "Recruit the Right Units"
                    image=wesnoth-icon.png
                    message= _ "Remember to recruit troops useful for the situation. Archers are particularly effective against Grunts, Wolf Riders and the orcish leader."
                [/message]
            [/then]
        [/if]

        {CLEAR_VARIABLE gold}
    [/event]

    # Warn when the orcs start using the eastern crossing, this is expected to happen around turn 7
    [event]
        name=side 1 turn
        first_time_only=no
        [filter_condition]
            [variable]
                name=spoke_about_orcs_crossing_river
                boolean_equals=no
            [/variable]
        [/filter_condition]

        # This uses vision range so that it still triggers even if the player has already put an elf ready to counterattack while the orc is on 20% def, because it's better to trigger it then rather than a couple of turns later when the player is already fighting the orcs.
        [store_reachable_locations]
            [filter_location]
                x,y=10,2
            [/filter_location]
            [filter]
                side=2
            [/filter]
            moves=max
            range=vision
            variable=reachable
        [/store_reachable_locations]

        [if]
            [variable]
                name=reachable.length
                greater_than=0
            [/variable]
            [then]
                {VARIABLE spoke_about_orcs_crossing_river yes}
                {TALK_ABOUT_LOC 12,2 ( _ "Beware of those orcs crossing the river! If they get into the forest they’ll be hard to dislodge!")}
            [/then]
        [/if]

        {CLEAR_VARIABLE reachable}
    [/event]

    [event]
        name=warn_about_units_with_low_health
        first_time_only=no
        [filter_condition]
            [variable]
                name=unit.hitpoints
                less_than="$($unit.max_hitpoints/5)"
            [/variable]
            [variable]
                name=unit.hitpoints
                greater_than=0
            [/variable]
            [variable]
                name=second_unit.hitpoints
                greater_than=0
            [/variable]

            [variable]
                name=lhpu_msg_i
                less_than_equal_to=3
            [/variable]
        [/filter_condition]

        [message]
            speaker=unit
            message="$low_hp_unit_message[$lhpu_msg_i].value"
            female_message="$low_hp_unit_message_female[$lhpu_msg_i].value"
        [/message]

        {VARIABLE_OP lhpu_msg_i add 1}

        [message]
            speaker=Galdrad
            message= _ "That unit is about one kill (8 experience points) away from gaining a level! Do not let it die!"
            [show_if]
                [variable]
                    name=unit.experience
                    greater_than=$($unit.max_experience - 8)
                [/variable]
            [/show_if]
        [/message]
    [/event]

    [event]
        name=capture
        [filter]
            id=Thrag
        [/filter]
        [filter_condition]
            [variable]
                name=turn_number
                greater_than=1
            [/variable]
        [/filter_condition]

        {TALK_ABOUT Thrag ( _ "Their leader has moved into that village! He’s not as stupid as I thought. The village heals him each turn and provides good defense.")}
    [/event]

    [event]
        name=capture
        [filter]
            side=2
            x=16,11,9
            y=9,8,12
        [/filter]

        {TALK_ABOUT_LOC ($x1,$y1) ( _ "That unit has captured our village! You’d better get him out; it heals him each turn and provides good defense.")}
    [/event]

    # Warn about using shaman to attack.
    [event]
        name=attack
        [filter]
            type=Elvish Shaman
        [/filter]

        [message]
            speaker=unit
            # po: The speaker is female
            message= _ "Using me to attack is risky! I can slow the opponent with my ranged attack, but I hope you have a plan if I miss!"
        [/message]
    [/event]

    [event]
        name=attack_end
        [filter_second]
            id=Thrag
        [/filter_second]
        [filter_condition]
            [variable]
                name=second_unit.hitpoints
                less_than=21
            [/variable]
        [/filter_condition]

        {TALK_ABOUT Thrag ( _ "You are close to killing their leader! Because he is second level, the unit who finishes him will gain 16 experience points. In a campaign, it’s important to decide which units you want to advance, and give those units the best chances to gain experience.")}

        [message]
            speaker=narrator
            caption= _ "You have almost finished the tutorial"
            image=wesnoth-icon.png
            message= _ "In a campaign you may have ten or even twenty scenarios to build your army, but this tutorial will conclude after you defeat Thrag."
        [/message]
    [/event]

    # Any level unit near advancement
    [event]
        name=die
        [filter]
            side=1
            race=elf
        [/filter]
        [filter_condition]
            [variable]
                name=unit.experience
                greater_than=$($unit.max_experience-13)
            [/variable]
        [/filter_condition]

        [if]
            [variable]
                name=unit.gender
                equals=male
            [/variable]
            [then]
                [message]
                    speaker=Galdrad
                    message= _ "We will miss $unit.name| because he had $unit.experience experience points. He would have advanced a level soon."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Galdrad
                    message= _ "We will miss $unit.name| because she had $unit.experience experience points. She would have advanced a level soon."
                [/message]
            [/else]
        [/if]
    [/event]

    # Level 1 units, not shamans, not near advancement. Shamans have their own death dialog
    [event]
        name=die
        [filter]
            side=1
            race=elf
            type=Elvish Fighter, Elvish Archer
        [/filter]
        [filter_condition]
            [variable]
                name=unit.experience
                less_than=10
            [/variable]
        [/filter_condition]

        [if]
            [variable]
                name=unit.gender
                equals=male
            [/variable]
            [then]
                [message]
                    speaker=Galdrad
                    message= _ "We will miss $unit.name|, but at least he was not one of our experienced troops!"
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Galdrad
                    message= _ "We will miss $unit.name|, but at least she was not one of our experienced troops!"
                [/message]
            [/else]
        [/if]
    [/event]

    # Level 2 and up units, any type
    [event]
        name=die
        [filter]
            side=1
            race=elf
            level=2,3,4
        [/filter]

        [message]
            speaker=Galdrad
            message= _ "Higher level units are powerful, but not invulnerable. We’ll miss you, $unit.name|."
        [/message]
    [/event]

    # Death of the shaman or one of her advancements with healing ability
    [event]
        name=die
        [filter]
            side=1
            type=Elvish Shaman,Elvish Druid,Elvish Shyde
        [/filter]

        [message]
            speaker=Galdrad
            message= _ "Losing a healer hurts all the troops! Keep them out of the enemy’s reach!"
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            [filter_location]
                x,y=38,5
                radius=6
            [/filter_location]
        [/filter]

        {TALK_ABOUT Thrag ( _ "Beware of the orc leader: he can do 36 hitpoints of damage at night! Attack with many units at once during the day.")}
    [/event]

    # Shaman advancements
    [event]
        name=post_advance
        [filter]
            side=1
            type=Elvish Druid
        [/filter]

        [message]
            speaker=unit
            # po: The speaker is female
            message= _ "Advancing a level has fully healed me! I am able to heal units 8 hitpoints per turn, instead of just 4, and may also cure them of poison if they cannot reach a village! I also have gained a new <i>magical</i> attack, meaning it always has a 70% chance to hit, but it is not as powerful as the similar attack wielded by the Elvish Sorceress."
        [/message]
    [/event]

    [event]
        name=post_advance
        [filter]
            side=1
            type=Elvish Sorceress
        [/filter]

        [message]
            speaker=unit
            # po: The speaker is female
            message= _ "Advancing a level has fully healed me! I cannot heal adjacent units anymore, but to compensate, I have a new, powerful faerie fire attack that deals 7 damage each for 4 strikes. It also has the <i>magical</i> weapon special, meaning it always has a 70% chance to hit."
        [/message]
    [/event]

    # Archer advancements
    [event]
        name=post_advance
        [filter]
            side=1
            type=Elvish Marksman
        [/filter]

        [message]
            speaker=unit
            message= _ "Advancing a level has fully healed me! When attacking, I always have at least a 60% chance of hitting with my longbow thanks to my <i>Marksman</i> ability, and I deal 9 damage each for 4 attacks. Use me to dislodge hard-to-hit units."
            female_message= _ "female^Advancing a level has fully healed me! When attacking, I always have at least a 60% chance of hitting with my longbow thanks to my <i>Marksman</i> ability, and I deal 9 damage each for 4 attacks. Use me to dislodge hard-to-hit units."
        [/message]
    [/event]

    [event]
        name=post_advance
        [filter]
            side=1
            type=Elvish Ranger
        [/filter]

        [message]
            speaker=unit
            message= _ "Advancing a level has fully healed me! I am good with both bow and sword, and I have a special ability: <i>Ambush</i>. I can hide in forests where enemies can only see me if they are right next to me."
            female_message= _ "female^Advancing a level has fully healed me! I am good with both bow and sword, and I have a special ability: <i>Ambush</i>. I can hide in forests where enemies can only see me if they are right next to me."
        [/message]
    [/event]

    # Fighter advancements
    [event]
        name=post_advance
        [filter]
            side=1
            type=Elvish Captain
        [/filter]

        [message]
            speaker=unit
            message= _ "Advancing a level has fully healed me! I am good with both bow and sword, and I have a special ability: <i>Leadership</i>. I do less damage myself than the Elvish Hero, but my ability allows my allies to fight better. First level units around me do 25% more damage, so position me carefully!"
        [/message]
    [/event]

    [event]
        name=post_advance
        [filter]
            side=1
            type=Elvish Hero
        [/filter]

        [message]
            speaker=unit
            message= _ "Advancing a level has fully healed me! I am particularly good with the sword, dealing 8 damage in 4 attacks. While I don’t have the Leadership abilities of the Elvish Captain, my superior fighting skills allow my attacks to do more damage!"
        [/message]
    [/event]

    # If you advance Konrad or Li'sar
    [event]
        name=post_advance
        [filter]
            id=student
        [/filter]

        [message]
            speaker=unit
            message= _ "Advancing a level has fully healed me! I have become better at using the sword, dealing 9 damage in 4 attacks. Although I do not have any special abilities, my fighting skills will allow me to beat the orcs by dealing more damage!"
            female_message= _ "female^Advancing a level has fully healed me! I have become better at using the sword, dealing 9 damage in 4 attacks. Although I do not have any special abilities, my fighting skills will allow me to beat the orcs by dealing more damage!"
        [/message]
    [/event]

    [event]
        name=time over

        [message]
            speaker=Galdrad
            message= _ "You took too long! Now we’ll never be rid of these orcs!"
        [/message]

        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    [event]
        name=last_breath
        [filter]
            id=student
        [/filter]

        [message]
            speaker=unit
            message= _ "That... was foolish. Next time I should be more careful."
            female_message= _ "female^That... was foolish. Next time I should be more careful."
        [/message]

        [endlevel]
            result=defeat
        [/endlevel]

        {CLEAR_PRINT}
    [/event]

    [event]
        name=last_breath
        [filter]
            id=Galdrad
        [/filter]

        [message]
            speaker=unit
            message= _ "Agh! Who will guide you to victory now?"
        [/message]

        [endlevel]
            result=defeat
        [/endlevel]

        {CLEAR_PRINT}
    [/event]

    [event]
        name=victory

        [message]
            speaker=Galdrad
            message= _ "You have beaten the orcs! You may want to try one of the rookie-level campaigns next, which include strategy hints. <i>A Tale of Two Brothers</i> is the easiest and is the recommended first campaign."
        [/message]
        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "You can also refer to the in-game help browser if you ever need to refresh your memory on gameplay mechanics."
        [/message]

        {CLEAR_VARIABLE low_hp_unit_message,lhpu_msg_i}
        {CLEAR_VARIABLE spoke_about_income,spoke_about_orcs_crossing_river}
        {CLEAR_VARIABLE undo_option}
    [/event]
[/tutorial]
