#textdomain wesnoth-tb

#define CHARACTER_STATS_ARVITH
    type=Knight
    id=Arvith
    name= _ "Arvith"
    profile="portraits/arvith.png~RIGHT()"
    canrecruit=yes
    unrenamable=yes
#enddef

#define ARVITH_LAST_BREATH
    [event]
        name=last breath
        [filter]
            id=Arvith
        [/filter]

        [message]
            speaker=Arvith
            message= _ "All is lost now that I am dead..."
        [/message]

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

#define BARAN_LAST_BREATH
    [event]
        name=last breath
        [filter]
            id=Baran
        [/filter]

        [message]
            speaker=Baran
            message= _ "It is over, I am vanquished."
        [/message]

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

#define NEED_MERCENARY
    [role]
        role=Mercenary

        type="Paladin,Grand Knight,Knight,Lancer,Horseman"
        [not]
            id=Arvith
        [/not]

        reassign=no
        [auto_recall][/auto_recall]
        [else]
            [unit]
                role=Mercenary
                side=1
                type=Horseman
                placement=leader
                facing=ne
            [/unit]
        [/else]
    [/role]
#enddef

#define STORE_BARAN
    [if]
        [have_unit]
            side=1
            id=Baran
            search_recall_list=yes
        [/have_unit]
        [then]
            [store_unit]
                [filter]
                    id=Baran
                [/filter]
                kill=yes
                variable=baran_store
            [/store_unit]
        [/then]
    [/if]
#enddef

#define RESTORE_BARAN
    [if]
        [variable]
            name=baran_store.id
            equals=Baran
        [/variable]
        [then]
            [unstore_unit]
                variable=baran_store
                x,y=recall,recall
            [/unstore_unit]
            {CLEAR_VARIABLE baran_store}
        [/then]
    [/if]
#enddef

#define RECALL_ELSE ID PLACEMENT WML
    [recall]
        id={ID}
        {PLACEMENT}
    [/recall]
    [if]
        [not]
            [have_unit]
                side=1
                id={ID}
            [/have_unit]
        [/not]
        [then]
            {WML}
        [/then]
    [/if]
#enddef

#define NEED_BARAN PLACEMENT
    {RECALL_ELSE Baran {PLACEMENT} (
        [unit]
            id=Baran
            name= _ "Baran"
            unrenamable=yes
            type=Red Mage
            profile=portraits/baran.png
            side=1
            {IS_HERO}
            {PLACEMENT}
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
        [/unit]
    )}
#enddef
