#textdomain wesnoth-l
[scenario]

    id=unlawful_orders
    name= _ "Unlawful Orders"
    map_data="{campaigns/Liberty/maps/unlawful_orders.map}"
    {TURNS 30 22 16}

    next_scenario=hide_and_seek
    {SCENARIO_MUSIC "knolls.ogg"}
    {VICTORY_AND_DEFEAT_MUSIC}
    victory_when_enemies_defeated=yes

    [label]
        x,y=16,15
        text= _ "Elensefar"
    [/label]

    [label]
        x,y=8,13
        text= _ "Port of Elensefar"
    [/label]

    [story]
        [part]
            music="knolls.ogg"
            show_title=yes
            background="maps/wesnoth-liberty.png"
            {L_DOT 229 248}
            {L_DOT 232 270}
            {L_DOT 224 290}
            {L_CROSS 209 300}
        [/part]
    [/story]

    {DEFAULT_SCHEDULE}

    [side]
        type=Bandit
        description=Baldras
        side=1
        canrecruit=yes
        controller=human
        recruit=Thug,Footpad,Poacher
        gold=100
        team_name=good_guys
    [/side]

    [side]
        type=General
        description=Lord Maddock
        user_description= _ "Lord Maddock"
        profile=portraits/p_maddock.png
        side=2
        canrecruit=yes
        controller=ai
        recruit=Spearman,Horseman,Cavalryman,Heavy Infantryman,Mage,Bowman
        [ai]
            recruitment_pattern=scout,mixed fighter,fighter,archer,fighter
            leader_value=3
            village_value=0.2
        [/ai]
        {GOLD 130 100 70}
        team_name=good_guys
    [/side]

    {STARTING_VILLAGES 2 15}

    [side]
        type=General
        description=Kestrel
        user_description= _ "Kestrel"
        side=3
        canrecruit=yes
        controller=ai
        recruit=Spearman,Horseman,Cavalryman,Heavy Infantryman,Mage,Bowman
        [ai]
            caution=0.0
            aggression=1.0
            recruitment_pattern=scout,fighter,fighter,archer,mixed fighter
            leader_value=20
        [/ai]
        {GOLD 100 180 260}
    [/side]

    {STARTING_VILLAGES 3 5}

    #
    # Prestart events
    #
    [event]
        name=prestart

        # {SCATTER_IMAGE (terrain=Gg) 12 scenery/oak-leaning.png}

        [objectives]
            side=1
            [objective]
                description= _ "Defeat the enemy general"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Baldras"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Harper"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Maddock"
                condition=lose
            [/objective]
            [objective]
                description= _ "Turns run out"
                condition=lose
            [/objective]
        [/objectives]

        [store_unit]
            [filter]
                description=Baldras
            [/filter]

            kill=yes
            variable=stored_Baldras
        [/store_unit]

        [unit]
            side=3
            type=Lieutenant
            x,y=17,39
            description=Rothel
            user_description= _ "Rothel"
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]
    [/event]

    #
    # Starting conversation and actions
    #
    [event]
        name=start

        [move_unit_fake]
            side=1
            type=Boat
            x=25,23
            y= 9,11
        [/move_unit_fake]

        [item]
            x,y=23,11
            image=units/transport/boat.png~FL(horiz)
        [/item]

        [move_unit_fake]
            side=1
            type=$stored_Baldras.type
            x=23,21
            y=11,11
        [/move_unit_fake]

        [unstore_unit]
            variable=stored_Baldras
        [/unstore_unit]

        [recall]
            description=Harper
        [/recall]
        [role]
            type=Outlaw,Trapper,Thug,Poacher,Footpad,Bandit
            role=Advisor
        [/role]
        [recall]
            role=Advisor
        [/recall]

        [message]
            description=Lord Maddock
            message= _ "Baldras, your trip here was not wise. The Queen's patrols have been visiting the local villages and bringing the elders here. Those that swear allegiance to the Queen are allowed to return home. Those that do not..."
        [/message]
        [message]
            description=Baldras
            message= _ "...are dispatched on the spot. I know the price of dissent. But what of you?"
        [/message]
        [message]
            description=Lord Maddock
            message= _ "Well, they do not come within the walls of my city. They are actually camped nearby, and the main garrison is further south at Halstead. I know my time will soon come to swear allegiance, but they do not press me. They are afraid I will refuse."
        [/message]
        [message]
            description=Baldras
            message= _ "Will you?"
        [/message]
        [message]
            description=Lord Maddock
            message= _ "Yes. The Queen ascended to the throne through the vilest of treachery. However, while most of my forces were sent with the King to fight the orcs, we have a strong enough contingent here to make the Queen's forces think twice about attacking Elensefar outright."
        [/message]
        [message]
            description=Lord Maddock
            message= _ "We have an uneasy peace until they are done with the smaller villages and finally come around to obtaining my oath. The treaty between Elensefar and Wesnoth is ancient, but I am not so naive as to place my full trust in it. Not in these wicked times."
        [/message]
        [message]
            description=Harper
            message= _ "What can we do then? We have brought with us many from Annuvin province who are willing to fight, but our families are still at home. They will not last long if the Queen's patrols return."
        [/message]
        [message]
            description=Lord Maddock
            message= _ "I am unwilling to start a civil war. I believe the Queen will remain preoccupied with order throughout the kingdom and, more importantly, with quelling the Northerner threat. We are a matter she will choose to deal with later rather than sooner, if she can."
        [/message]
        [message]
            description=Kestrel
            message= _ "A foolish miscalculation, Lord Maddock. These men with which you consort are outlaws and fugitives. They are a well-organized gang of criminals and murderers. We will kill them and then expect your oath of allegiance to Queen Asheviere."
        [/message]
        [message]
            description=Lord Maddock
            message= _ "Men, to arms! The defense of Elensefar has begun!"
        [/message]

        {CLEAR_VARIABLE stored_Baldras}
    [/event]

    #
    # Special event - the human enemies become undead at night
    #

    [event]
        name=turn 4

        [music]
            name="frantic.ogg"
        [/music]

        [message]
            speaker=narrator
            message= _ "As the sun set, a horrific change began to take place to the human adversaries of Baldras and his allies..."
            image="wesnoth-icon.png"
        [/message]
    [/event]

#define TURN_TO_UNDEAD TURN
    [event]
        name=turn {TURN}

        [store_unit]
            [filter]
                side=3
            [/filter]

            kill=yes
            variable=stored_changers
        [/store_unit]

        {FOREACH stored_changers i}
            {VARIABLE stored_changers[$i].variables.real_hitpoints $stored_changers[$i].hitpoints}

            [unstore_unit]
                variable=stored_changers[$i]
            [/unstore_unit]
        {NEXT i}

        {CHG_TYPE side,type=3,Spearman Skeleton chaotic}
        {CHG_TYPE side,type=3,Swordsman Deathblade chaotic}
        {CHG_TYPE side,type=3,Pikeman Revenant chaotic}
        {CHG_TYPE side,type=3,Bowman (Skeleton Archer) chaotic}
        {CHG_TYPE side,type=3,Longbowman (Bone Shooter) chaotic}
        {CHG_TYPE (side,type=3,Heavy Infantryman) Ghoul chaotic}
        {CHG_TYPE (side,type=3,Shock Trooper) Necrophage chaotic}
        {CHG_TYPE side,type=3,Mage (Dark Adept) chaotic}
        {CHG_TYPE (side,type=3,White Mage) (Dark Sorcerer) chaotic}
        {CHG_TYPE (side,type=3,Red Mage) (Dark Sorcerer2) chaotic}
        {CHG_TYPE (side,type=3,Arch Mage) Lich chaotic}
        {CHG_TYPE (side,type=3,Mage of Light) Necromancer chaotic}
        {CHG_TYPE side,type=3,Cavalryman (Skeleton Rider) chaotic}
        {CHG_TYPE side,type=3,Dragoon (Bone Knight) chaotic}
        {CHG_TYPE side,type=3,Horseman (Skeleton Rider2) chaotic}
        {CHG_TYPE side,type=3,Lancer (Bone Knight2) chaotic}
        {CHG_TYPE side,type=3,Knight (Bone Knight3) chaotic}
        {CHG_TYPE side,type=3,Lieutenant (Death Squire) chaotic}
        {CHG_TYPE side,type=3,General (Death Knight) chaotic}

        [store_unit]
            [filter]
                side=3
            [/filter]

            kill=yes
            variable=stored_changers
        [/store_unit]

        {FOREACH stored_changers i}
            {VARIABLE stored_changers[$i].hitpoints $stored_changers[$i].variables.real_hitpoints}

            [unstore_unit]
                variable=stored_changers[$i]
            [/unstore_unit]
        {NEXT i}

        {CLEAR_VARIABLE stored_changers}

        [colour_adjust]
            red=255
            green=100
            blue=100
        [/colour_adjust]
        [delay]
            time=10
        [/delay]
        [colour_adjust]
            red=0
            green=0
            blue=0
        [/colour_adjust]
        [redraw]
        [/redraw]

        [disallow_recruit]
            side=3
            type=Spearman,Horseman,Cavalryman,Heavy Infantryman,Mage,Bowman
        [/disallow_recruit]
        [allow_recruit]
            side=3
            type=Skeleton,Skeleton Rider,Skeleton Rider2,Dark Adept,Skeleton Archer
        [/allow_recruit]
    [/event]
#enddef

#define TURN_TO_HUMAN TURN
    [event]
        name=turn {TURN}

        [store_unit]
            [filter]
                side=3
            [/filter]

            kill=yes
            variable=stored_changers
        [/store_unit]

        {FOREACH stored_changers i}
            {VARIABLE stored_changers[$i].variables.real_hitpoints $stored_changers[$i].hitpoints}

            [unstore_unit]
                variable=stored_changers[$i]
            [/unstore_unit]
        {NEXT i}

        {CHG_TYPE side,type=3,Skeleton Spearman lawful}
        {CHG_TYPE side,type=3,Deathblade Swordsman lawful}
        {CHG_TYPE side,type=3,Revenant Pikeman lawful}
        {CHG_TYPE (side,type=3,Skeleton Archer) Bowman lawful}
        {CHG_TYPE (side,type=3,Bone Shooter) Longbowman lawful}
        {CHG_TYPE side,type=3,Ghoul (Heavy Infantryman) lawful}
        {CHG_TYPE side,type=3,Necrophage (Shock Trooper) lawful}
        {CHG_TYPE (side,type=3,Dark Adept) Mage lawful}
        {CHG_TYPE (side,type=3,Dark Sorcerer) (White Mage) lawful}
        {CHG_TYPE (side,type=3,Dark Sorcerer2) (Red Mage) lawful}
        {CHG_TYPE side,type=3,Lich (Arch Mage) lawful}
        {CHG_TYPE side,type=3,Necromancer (Mage of Light) lawful}
        {CHG_TYPE (side,type=3,Skeleton Rider) Cavalryman lawful}
        {CHG_TYPE (side,type=3,Bone Knight) Dragoon lawful}
        {CHG_TYPE (side,type=3,Skeleton Rider2) Horseman lawful}
        {CHG_TYPE (side,type=3,Bone Knight2) Lancer lawful}
        {CHG_TYPE (side,type=3,Bone Knight3) Knight lawful}
        {CHG_TYPE (side,type=3,Death Squire) Lieutenant lawful}
        {CHG_TYPE (side,type=3,Death Knight) General lawful}

        [store_unit]
            [filter]
                side=3
            [/filter]

            kill=yes
            variable=stored_changers
        [/store_unit]

        {FOREACH stored_changers i}
            {VARIABLE stored_changers[$i].hitpoints $stored_changers[$i].variables.real_hitpoints}

            [unstore_unit]
                variable=stored_changers[$i]
            [/unstore_unit]
        {NEXT i}

        {CLEAR_VARIABLE stored_changers}

        [colour_adjust]
            red=255
            green=255
            blue=100
        [/colour_adjust]
        [delay]
            time=10
        [/delay]
        [colour_adjust]
            red=0
            green=0
            blue=0
        [/colour_adjust]
        [redraw]
        [/redraw]

        [disallow_recruit]
            side=3
            type=Skeleton,Skeleton Rider,Skeleton Rider2,Dark Adept,Skeleton Archer
        [/disallow_recruit]
        [allow_recruit]
            side=3
            type=Spearman,Horseman,Cavalryman,Heavy Infantryman,Mage,Bowman
        [/allow_recruit]
    [/event]
#enddef

    {TURN_TO_UNDEAD 4}
    {TURN_TO_HUMAN 7}
    {TURN_TO_UNDEAD 10}
    {TURN_TO_HUMAN 13}
    {TURN_TO_UNDEAD 16}
    {TURN_TO_HUMAN 19}
    {TURN_TO_UNDEAD 22}
    {TURN_TO_HUMAN 25}
    {TURN_TO_UNDEAD 28}

    [event]
        name=turn 4
        [message]
            description=Harper
            message= _ "I cannot believe what my eyes are seeing! The flesh runs from their bones... these are not human warriors we fight. They are evil spirits masquerading as human!"
        [/message]
    [/event]

    [event]
        name=turn 7
        [music]
            name="knolls.ogg"
        [/music]
        [message]
            description=Lord Maddock
            message= _ "Their human aspect is returning! This is an evil manner of sorcery we face, but one that we may yet overcome. CHARGE!"
        [/message]
    [/event]

    #
    # Victory
    #
    [event]
        name=die
        [filter]
            description=Kestrel
        [/filter]
        [message]
            speaker=second_unit
            message= _ "Who are you? What are you?"
        [/message]
        [message]
            description=Kestrel
            message= _ "We are accursed. We were once under the command of Prince Eldred, the King's son and betrayer. The price for our treason is this hellish existence. We know not who or what inflicted this curse upon us, but our mortal deaths may be only the beginning of the penance we are doomed to pay."
        [/message]

        [kill]
            description=Kestrel
            animate=yes
            fire_event=no
        [/kill]

        [message]
            description=Baldras
            message= _ "Lord Maddock, now that we are victorious, will you help us?"
        [/message]
        [message]
            description=Lord Maddock
            message= _ "I will not. Unless you want me to round up the city's thieves to fight for you, I do not have the troops to spare. However, I am not the only one who commands men in this corner of Wesnoth."
        [/message]
        [message]
            description=Baldras
            message= _ "I don't understand. There are no other noble lords in this area."
        [/message]
        [message]
            description=Lord Maddock
            message= _ "Southeast of here there is a town, and there you may find assistance of the type I cannot give."
        [/message]
        [message]
            description=Baldras
            message= _ "Wish us well. If we are to resist the Wesnoth army a second time, we're going to need more than clubs and slings against steel."
        [/message]
        [endlevel]
            result=victory
            bonus=yes
        [/endlevel]
    [/event]

    #
    # Loss conditions - turns run out
    #
    [event]
        name=time over
        [message]
            description=Baldras
            message= _ "Look, more riders come from the southeast. We cannot survive another assault. We are finished!"
        [/message]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    {LIBERTY_DEATHS}
[/scenario]
