#textdomain wesnoth

# Defines a terrain that has a transition image of the form: "void-n-ne-se-s.png"
# example: {TERRAIN_ADJACENT_4 gt !gt grassland}
# This will add 4-tile transitions from terrains of type g or t to terrains of
# any other type, using the filename grassland-x-x-x-x.png

#define TERRAIN_ADJACENT_4_FL LAYER TERRAIN ADJACENT IMAGESTEM FLAG
    [terrain_graphics]
        map="
,  2
.,   3
,  1
.,   4
,  5"
        [tile]
            pos=1
            type={ADJACENT}

            no_flag={FLAG}-@R0,{FLAG}-@R1,{FLAG}-@R2,{FLAG}-@R3
            set_flag={FLAG}-@R0,{FLAG}-@R1,{FLAG}-@R2,{FLAG}-@R3

            [image]
                layer={LAYER}
                name={IMAGESTEM}-@R0-@R1-@R2-@R3
            [/image]
        [/tile]
        [tile]
            pos=2
            type={TERRAIN}
            no_flag={FLAG}-@R3
            set_flag={FLAG}-@R3
        [/tile]
        [tile]
            pos=3
            type={TERRAIN}
            no_flag={FLAG}-@R4
            set_flag={FLAG}-@R4
        [/tile]
        [tile]
            pos=4
            type={TERRAIN}
            no_flag={FLAG}-@R5
            set_flag={FLAG}-@R5
        [/tile]
        [tile]
            pos=5
            type={TERRAIN}
            no_flag={FLAG}-@R0
            set_flag={FLAG}-@R0
        [/tile]

        rotations=n,ne,se,s,sw,nw
    [/terrain_graphics]
#enddef

# Same as above, but for 3-tile transitions.

#define TERRAIN_ADJACENT_3_FL LAYER TERRAIN ADJACENT IMAGESTEM FLAG
    [terrain_graphics]
        map="
,  2
.,   3
,  1
.,   4
,  ."
        [tile]
            pos=1
            type={ADJACENT}

            no_flag={FLAG}-@R0,{FLAG}-@R1,{FLAG}-@R2
            set_flag={FLAG}-@R0,{FLAG}-@R1,{FLAG}-@R2

            [image]
                layer={LAYER}
                name={IMAGESTEM}-@R0-@R1-@R2
            [/image]
        [/tile]
        [tile]
            pos=2
            type={TERRAIN}
            no_flag={FLAG}-@R3
            set_flag={FLAG}-@R3
        [/tile]
        [tile]
            pos=3
            type={TERRAIN}
            no_flag={FLAG}-@R4
            set_flag={FLAG}-@R4
        [/tile]
        [tile]
            pos=4
            type={TERRAIN}
            no_flag={FLAG}-@R5
            set_flag={FLAG}-@R5
        [/tile]

        rotations=n,ne,se,s,sw,nw
    [/terrain_graphics]
#enddef

# Same as above, but for 2-tile transitions.

#define TERRAIN_ADJACENT_2_FL LAYER TERRAIN ADJACENT IMAGESTEM FLAG
    [terrain_graphics]
        map="
,  2
.,   3
,  1
.,   .
,  ."
        [tile]
            pos=1
            type={ADJACENT}

            no_flag={FLAG}-@R0,{FLAG}-@R1
            set_flag={FLAG}-@R0,{FLAG}-@R1

            [image]
                layer={LAYER}
                name={IMAGESTEM}-@R0-@R1
            [/image]
        [/tile]
        [tile]
            pos=2
            type={TERRAIN}
            no_flag={FLAG}-@R3
            set_flag={FLAG}-@R3
        [/tile]
        [tile]
            pos=3
            type={TERRAIN}
            no_flag={FLAG}-@R4
            set_flag={FLAG}-@R4
        [/tile]

        rotations=n,ne,se,s,sw,nw
    [/terrain_graphics]
#enddef

# Same as above, but for 1-tile (simple) transitions.

#define TERRAIN_ADJACENT_1_FL LAYER TERRAIN_PATTERN ADJACENT IMAGESTEM FLAG
    [terrain_graphics]
        map="
,  2
.,   .
,  1
.,   .
,  ."
        [tile]
            pos=1
            type={ADJACENT}

            no_flag={FLAG}-@R0
            set_flag={FLAG}-@R0

            [image]
                layer={LAYER}
                name={IMAGESTEM}-@R0
            [/image]
        [/tile]
        [tile]
            pos=2
            type={TERRAIN_PATTERN}
            no_flag={FLAG}-@R3
            set_flag={FLAG}-@R3
        [/tile]

        rotations=n,ne,se,s,sw,nw
    [/terrain_graphics]
#enddef

# Defines a terrain that could have 4-tile, 3-tile, 2-tile, or 1-tile
# transitions to other terrains. The larger transitions have greater priority
# and go first.

#define TERRAIN_ADJACENT_FL LAYER TERRAIN_PATTERN ADJACENT IMAGESTEM FLAG
    {TERRAIN_ADJACENT_4_FL ({LAYER}) ({TERRAIN_PATTERN}) ({ADJACENT}) {IMAGESTEM} {FLAG}}
    {TERRAIN_ADJACENT_3_FL ({LAYER}) ({TERRAIN_PATTERN}) ({ADJACENT}) {IMAGESTEM} {FLAG}}
    {TERRAIN_ADJACENT_2_FL ({LAYER}) ({TERRAIN_PATTERN}) ({ADJACENT}) {IMAGESTEM} {FLAG}}
    {TERRAIN_ADJACENT_1_FL ({LAYER}) ({TERRAIN_PATTERN}) ({ADJACENT}) {IMAGESTEM} {FLAG}}
#enddef

#define TERRAIN_ADJACENT LAYER TERRAIN_PATTERN ADJACENT IMAGESTEM
    {TERRAIN_ADJACENT_FL ({LAYER}) ({TERRAIN_PATTERN}) ({ADJACENT}) {IMAGESTEM} transition}
#enddef

#define TERRAIN_ADJACENT_OV LAYER TERRAIN_PATTERN ADJACENT IMAGESTEM
    {TERRAIN_ADJACENT_FL ({LAYER}) ({TERRAIN_PATTERN}) ({ADJACENT}) {IMAGESTEM} overlay}
#enddef

# If you need a custom flag use this one, this allows stacking of
# several transitions.
#define TERRAIN_ADJACENT_CUSTOM LAYER TERRAIN_PATTERN ADJACENT IMAGESTEM FLAG
    {TERRAIN_ADJACENT_FL ({LAYER}) ({TERRAIN_PATTERN}) ({ADJACENT}) {IMAGESTEM} {FLAG}}
#enddef

# define a specific rule for layering when the transition borders
# on a specific OTHER_TERRAIN - to use in situations where the layering
# needs to be adjusted for three-way-junctions of a particular set of
# terrains
#define TERRAIN_ADJACENT_3_DIFFERENT LAYER TERRAIN_PATTERN ADJACENT OTHER_TERRAIN_PATTERN IMAGESTEM FLAG
    [terrain_graphics]
        map="
,  2
.,   3
,  1
.,   .
,  ."
        [tile]
            pos=1
            type={ADJACENT}

            no_flag={FLAG}-@R0,{FLAG}-@R1
            set_flag={FLAG}-@R0,{FLAG}-@R1

            [image]
                layer={LAYER}
                name={IMAGESTEM}-@R0
            [/image]
        [/tile]
        [tile]
            pos=2
            type={TERRAIN_PATTERN}
            no_flag={FLAG}-@R3
            set_flag={FLAG}-@R3
        [/tile]
        [tile]
            pos=3
            type={OTHER_TERRAIN_PATTERN}
            no_flag={FLAG}-@R4
            set_flag={FLAG}-@R4
        [/tile]

        rotations=n,ne,se,s,sw,nw
    [/terrain_graphics]
    [terrain_graphics]
        map="
,  2
3,   .
,  1
.,   .
,  ."
        [tile]
            pos=1
            type={ADJACENT}

            no_flag={FLAG}-@R0,{FLAG}-@R1
            set_flag={FLAG}-@R0,{FLAG}-@R1

            [image]
                layer={LAYER}
                name={IMAGESTEM}-@R0
            [/image]
        [/tile]
        [tile]
            pos=2
            type={TERRAIN_PATTERN}
            no_flag={FLAG}-@R3
            set_flag={FLAG}-@R3
        [/tile]
        [tile]
            pos=3
            type={OTHER_TERRAIN_PATTERN}
            no_flag={FLAG}-@R4
            set_flag={FLAG}-@R4
        [/tile]

        rotations=n,ne,se,s,sw,nw
    [/terrain_graphics]
#enddef
