#textdomain wesnoth-low

#ifdef MULTIPLAYER
#define MP_SIDE NUM WML
    [side]
        side={NUM}
        {WML}
    [/side]
#enddef
#else
#define MP_SIDE NUM WML
    [side]
        side={NUM}
        hidden=yes
        controller=null
        allow_player=no
        no_leader=yes
    [/side]
#enddef
#endif

#define DEFAULT_VICTORY MP_BONUS
    [event]
        name=enemies defeated
        [endlevel]
#ifdef MULTIPLAYER
            bonus={MP_BONUS}
#else
            bonus=yes
#endif
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]
#enddef

#define FILTER_LOYALS
    [filter_wml]
        upkeep="loyal"
    [/filter_wml]
#enddef

#define RECALL_LOYALS
    [store_unit]
        variable=loyals
        [filter]
            {FILTER_LOYALS}
            [not]
                canrecruit=yes
            [/not]
            x,y=recall,recall
        [/filter]
    [/store_unit]

    [foreach]
        array=loyals
        [do]
            [recall]
                id=$this_item.id
            [/recall]
        [/do]
    [/foreach]
    {CLEAR_VARIABLE loyals}
#enddef

#define ELVES_SCOUTS
Elvish Scout#enddef

#define ELVES_STEEL
Elvish Fighter, Elvish Archer, {ELVES_SCOUTS}#enddef

#define ELVES_NON_STEEL
Elvish Shaman, Wose, {ELVES_SCOUTS}#enddef

#define NORTH_ELVES_VILLAGES
    {STARTING_VILLAGES_AREA 2 24  7 12}
    {STARTING_VILLAGES_AREA 2 38 25 12}
    {STARTING_VILLAGES_AREA 2 55 36  7}

    {VILLAGE_SIDE 2 11 27}
    {VILLAGE_SIDE 2 48  8}
#enddef

#define VILLAGE_SIDE SIDE X Y
    [event]
        name=prestart

        [capture_village]
            side={SIDE}
            x={X}
            y={Y}
        [/capture_village]
    [/event]
#enddef

#define STARTING_VILLAGES_ORC SIDE
    [event]
        name=prestart

        #{CAPTURE_VILLAGES_OF_TYPE (*^Vhh) {SIDE} 1 1 {INFINITY}}
        [capture_village]
            side={SIDE}
            terrain=*^Vo*
        [/capture_village]
    [/event]
#enddef

#define STARTING_VILLAGES_ELF SIDE
    [event]
        name=prestart

        [capture_village]
            side={SIDE}
            terrain=*^Ve*
        [/capture_village]
    [/event]
#enddef

#define STARTING_VILLAGES_DWARF SIDE
    [event]
        name=prestart

        [capture_village]
            side={SIDE}
            terrain=*^Vhh*
        [/capture_village]
    [/event]
#enddef

#define STARTING_VILLAGES_HUMAN SIDE
    [event]
        name=prestart

        [capture_village]
            side={SIDE}
            terrain=*^Vh,*^Vha,*^Vhc,*^Vl*
        [/capture_village]
    [/event]
#enddef

#define STARTING_VILLAGES_TROLL SIDE
    [event]
        name=prestart

        [capture_village]
            side={SIDE}
            terrain=*^Vc*
        [/capture_village]
    [/event]
#enddef

# Thanks to Shadow Master for this macro
# !***Macro to random place unit within area***
#define RANDOM_PLACEMENT _X _Y _RADIUS _WML
    [random_placement]
        num_items=1
        variable=random_placement_location
        [filter_location]
            x,y={_X},{_Y}
            radius={_RADIUS}
        [/filter_location]
        [command]
            [unit]
                {_WML}
                x,y=$random_placement_location.x,$random_placement_location.y
            [/unit]
        [/command]
    [/random_placement]
#enddef

#define ELF_SETUP
    {FLAG_VARIANT wood-elvish}
#enddef

#define SAURIAN_SETUP
    {FLAG_VARIANT undead}
#enddef

#define ORC_SETUP
    {FLAG_VARIANT6 ragged}
#enddef

#define DWARF_SETUP
    {FLAG_VARIANT knalgan}
#enddef

#define LOYALIST_SETUP
    {FLAG_VARIANT loyalist}
#enddef

#define TROLL_SETUP
    {FLAG_VARIANT undead}
#enddef
