# This file contains a WIP set of terrain graphics macros, intended to be as
# short and simple as possible.

#define NEW:BASE TERRAIN IMAGESTEM
    # Places {IMAGESTEM}[1-11].png as base tiles. Assumes 72x72 hex-shaped
    # images.

    [terrain_graphics]
        map="
, *
* , *
, 1
* , *
, *"

        [tile]
            pos=1
            type={TERRAIN}
            set_no_flag=base
        [/tile]

        [image]
            name={IMAGESTEM}@V.png
            variations=";2;3;4;5;6;7;8;9;10;11"
            layer=-1000
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]
#enddef

#define NEW:FOREST TERRAINLIST ADJACENT IMAGESTEM
    # This assumes centered images. Places the images named
    # {IMAGESTEM}-small[1-11].png on all {TERRAIN} adjacent to {ADJACENT}, and
    # {IMAGESTEM}[1-11].png on all others.

    [terrain_graphics]
        map="
,  2
*,   *
,  1
*,   *
,  *"
        [tile]
            pos=1
            type={TERRAINLIST}
            set_no_flag=overlay
        [/tile]

        [tile]
            pos=2
            type={ADJACENT}
        [/tile]

        rotations=n,ne,se,s,sw,nw

        [image]
            name={IMAGESTEM}-small@V.png
            variations=";2;3;4;5;6;7;8;9;10;11"
            layer=0
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
,  *
*,   *
,  1
*,   *
,  *"
        [tile]
            pos=1
            type={TERRAINLIST}
            set_no_flag=overlay
        [/tile]

        [image]
            name={IMAGESTEM}@V.png
            variations=";2;3;4;5;6;7;8;9;10;11"
            layer=0
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]
#enddef

#define NEW:FENCE TERRAINLIST IMAGESTEM
    [terrain_graphics]
        map="
,  .
2,   2
,  1
2,   2
,  ."
        [tile]
            pos=1
            type={TERRAINLIST}
            no_flag=fence
            set_flag=fence,fence-[ne,se,sw,nw]
        [/tile]

        [tile]
            pos=2
            type={TERRAINLIST}
        [/tile]

        [image]
            name={IMAGESTEM}-ne-se-sw-nw.png
            layer=-80
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
,  .
2,   2
,  1
.,   2
,  ."
        [tile]
            pos=1
            type={TERRAINLIST}
            no_flag=fence
            set_flag=fence,fence-[ne,se,nw]
        [/tile]

        [tile]
            pos=2
            type={TERRAINLIST}
        [/tile]

        [image]
            name={IMAGESTEM}-ne-se-nw.png
            layer=-80
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
,  .
2,   .
,  1
2,   2
,  ."
        [tile]
            pos=1
            type={TERRAINLIST}
            no_flag=fence
            set_flag=fence,fence-[se,sw,nw]
        [/tile]

        [tile]
            pos=2
            type={TERRAINLIST}
        [/tile]

        [image]
            name={IMAGESTEM}-se-sw-nw.png
            layer=-80
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
,  .
.,   2
,  1
2,   2
,  ."
        [tile]
            pos=1
            type={TERRAINLIST}
            no_flag=fence
            set_flag=fence,fence-[ne,se,sw]
        [/tile]

        [tile]
            pos=2
            type={TERRAINLIST}
        [/tile]

        [image]
            name={IMAGESTEM}-ne-se-sw.png
            layer=-80
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
,  .
2,   2
,  1
2,   .
,  ."
        [tile]
            pos=1
            type={TERRAINLIST}
            no_flag=fence
            set_flag=fence,fence-[ne,sw,nw]
        [/tile]

        [tile]
            pos=2
            type={TERRAINLIST}
        [/tile]

        [image]
            name={IMAGESTEM}-ne-sw-nw.png
            layer=-80
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
,  .
.,   2
,  1
.,   2
,  ."
        [tile]
            pos=1
            type={TERRAINLIST}
            no_flag=fence
            set_flag=fence,fence-[ne,se]
        [/tile]

        [tile]
            pos=2
            type={TERRAINLIST}
        [/tile]

        [image]
            name={IMAGESTEM}-ne-se.png
            layer=-80
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
,  .
2,   .
,  1
2,   .
,  ."
        [tile]
            pos=1
            type={TERRAINLIST}
            no_flag=fence
            set_flag=fence,fence-[sw,nw]
        [/tile]

        [tile]
            pos=2
            type={TERRAINLIST}
        [/tile]

        [image]
            name={IMAGESTEM}-sw-nw.png
            layer=-80
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
,  .
.,   .
,  1
2,   2
,  ."
        [tile]
            pos=1
            type={TERRAINLIST}
            no_flag=fence
            set_flag=fence,fence-[se,sw]
        [/tile]

        [tile]
            pos=2
            type={TERRAINLIST}
        [/tile]

        [image]
            name={IMAGESTEM}-se-sw.png
            layer=-80
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
,  .
2,   2
,  1
.,   .
,  ."
        [tile]
            pos=1
            type={TERRAINLIST}
            no_flag=fence
            set_flag=fence,fence-[ne,nw]
        [/tile]

        [tile]
            pos=2
            type={TERRAINLIST}
        [/tile]

        [image]
            name={IMAGESTEM}-ne-nw.png
            layer=-80
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
,  *
*,   2
,  1
*,   *
,  *"
        [tile]
            pos=1
            type={TERRAINLIST}
            no_flag=fence
            set_flag=fence,fence-@R4
        [/tile]

        [tile]
            pos=2
            type={TERRAINLIST}
            has_flag=fence-@R4
        [/tile]

        rotations=n,ne,se,s,sw,nw

        [image]
            # wmlscope: start ignoring
            name={IMAGESTEM}-@R1-@R4-@V.png
            # wmlscope: stop ignoring
            variations="01;02"
            layer=-80
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
,  *
*,   2
,  1
*,   *
,  *"
        [tile]
            pos=1
            type={TERRAINLIST}
            no_flag=fence
            set_flag=fence,fence-@R4
        [/tile]

        [tile]
            pos=2
            type={TERRAINLIST}
        [/tile]

        rotations=n,ne,se,s,sw,nw

        [image]
            # wmlscope: start ignoring
            name={IMAGESTEM}-@R1-@R4-@V.png
            # wmlscope: stop ignoring
            variations="01;02"
            layer=-80
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
,  *
2,   2
,  1
2,   2
,  *"
        [tile]
            pos=1
            type={TERRAINLIST}
            no_flag=fence
            set_flag=fence,fence-[ne,se,sw,nw]
        [/tile]

        [tile]
            pos=2
            type=!,{TERRAINLIST}
        [/tile]

        [image]
            name={IMAGESTEM}-ne-se-sw-nw.png
            layer=-80
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
,  *
*,   2
,  1
*,   *
,  *"
        [tile]
            pos=1
            type=!,{TERRAINLIST}
        [/tile]

        [tile]
            pos=2
            type={TERRAINLIST}
            has_flag=fence-@R4
        [/tile]

        rotations=n,ne,se,s,sw,nw

        [image]
            # wmlscope: start ignoring
            name={IMAGESTEM}-@R1.png
            # wmlscope: stop ignoring
            layer=-80
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]
#enddef

#define NEW:WALL_P TERRAINLIST ADJACENT PROB IMAGESTEM
    [terrain_graphics]
        map="
2
,  3
1"
        [tile]
            pos=1
            type={TERRAINLIST}
            set_no_flag=wall-@R0
        [/tile]
        [tile]
            pos=2
            type={ADJACENT}
            set_no_flag=wall-@R2
        [/tile]
        [tile]
            pos=3
            type={ADJACENT}
            set_no_flag=wall-@R4
        [/tile]

        rotations=tr,r,br,bl,l,tl
        probability={PROB}

        [image]
            layer=0
            base=54,72
            name={IMAGESTEM}@V-convex-@R0.png
            variations=";2;3;4;5;6"
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
2
,  3
1"
        [tile]
            pos=1
            type={ADJACENT}
            set_no_flag=wall-@R0
        [/tile]
        [tile]
            pos=2
            type={TERRAINLIST}
            set_no_flag=wall-@R2
        [/tile]
        [tile]
            pos=3
            type={TERRAINLIST}
            set_no_flag=wall-@R4
        [/tile]

        rotations=tr,r,br,bl,l,tl
        probability={PROB}

        [image]
            layer=0
            base=54,72
            name={IMAGESTEM}@V-concave-@R0.png
            variations=";2;3;4;5;6"
        [/image]
    [/terrain_graphics]
#enddef

#define NEW:WALL TERRAINLIST ADJACENT IMAGESTEM
    {NEW:WALL_P {TERRAINLIST} {ADJACENT} 100 {IMAGESTEM}}
#enddef

#define NEW:WALL2_P TERRAINLIST ADJACENT1 ADJACENT2 PROB IMAGESTEM
    {NEW:WALL {TERRAINLIST} {ADJACENT1} {IMAGESTEM}}

    [terrain_graphics]
        map="
2
,  3
1"
        [tile]
            pos=1
            type={TERRAINLIST}
            set_no_flag=wall-@R0
        [/tile]
        [tile]
            pos=2
            type={ADJACENT1}
            set_no_flag=wall-@R2
        [/tile]
        [tile]
            pos=3
            type={ADJACENT2}
            set_no_flag=wall-@R4
        [/tile]

        rotations=tr,r,br,bl,l,tl

        [image]
            layer=0
            base=54,72
            name={IMAGESTEM}@V-cw-@R0.png
            variations=";2;3;4;5;6"
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
2
,  3
1"
        [tile]
            pos=1
            type={TERRAINLIST}
            set_no_flag=wall-@R0
        [/tile]
        [tile]
            pos=2
            type={ADJACENT2}
            set_no_flag=wall-@R2
        [/tile]
        [tile]
            pos=3
            type={ADJACENT1}
            set_no_flag=wall-@R4
        [/tile]

        rotations=tr,r,br,bl,l,tl

        [image]
            layer=0
            base=54,72
            name={IMAGESTEM}@V-ccw-@R0.png
            variations=";2;3;4;5;6"
        [/image]
    [/terrain_graphics]
#enddef

#define NEW:WALL2 TERRAINLIST ADJACENT1 ADJACENT2 IMAGESTEM
    {NEW:WALL2_P {TERRAINLIST} {ADJACENT1} {ADJACENT2} 100 {IMAGESTEM}}
#enddef

#define NEW:WAVES TERRAINLIST ADJACENT LAYER IMAGESTEM
    [terrain_graphics]
        map="
,  2
*,   3
,  1
*,   *
,  *"
        [tile]
            pos=1
            type={TERRAINLIST}
            set_no_flag=waves-@R0
        [/tile]
        [tile]
            pos=2
            type={ADJACENT}
            set_no_flag=waves-@R2
        [/tile]
        [tile]
            pos=3
            type={ADJACENT}
            set_no_flag=waves-@R4
        [/tile]

        rotations=tr,r,br,bl,l,tl

        [image]
            name={ANIMATION_06_150 {IMAGESTEM}-convex -@R0}
            random_start=no
            layer={LAYER}
            center=90,144
            base=90,144
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
,  2
*,   3
,  1
*,   *
,  *"
        [tile]
            pos=1
            type={ADJACENT}
            set_no_flag=waves-@R0
        [/tile]
        [tile]
            pos=2
            type={TERRAINLIST}
            set_no_flag=waves-@R2
        [/tile]
        [tile]
            pos=3
            type={TERRAINLIST}
            set_no_flag=waves-@R4
        [/tile]

        rotations=tr,r,br,bl,l,tl

        [image]
            name={ANIMATION_06_150 {IMAGESTEM}-concave -@R0}
            random_start=no
            layer={LAYER}
            center=90,144
            base=90,144
        [/image]
    [/terrain_graphics]
#enddef

#define NEW:BEACH TERRAINLIST ADJACENT IMAGESTEM
    [terrain_graphics]
        map="
,  2
*,   3
,  1
*,   *
,  *"
        [tile]
            pos=1
            type={ADJACENT}
            set_no_flag=beach-@R0-[@R5,@R1]
        [/tile]
        [tile]
            pos=2
            type={TERRAINLIST}
            set_no_flag=beach-@R2-@R3
        [/tile]
        [tile]
            pos=3
            type={TERRAINLIST}
            set_no_flag=beach-@R4-@R3
        [/tile]

        rotations=tr,r,br,bl,l,tl

        [image]
            # wmlscope: start ignoring
            name={IMAGESTEM}-concave-@R0-@R5.png
            # wmlscope: stop ignoring
            layer=-500
            center=90,144
            base=90,144
        [/image]
        [image]
            # wmlscope: start ignoring
            name={IMAGESTEM}-concave-@R0-@R1.png
            # wmlscope: stop ignoring
            layer=-500
            center=90,144
            base=90,144
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
,  2
*,   3
,  1
*,   *
,  *"
        [tile]
            pos=1
            type={TERRAINLIST}
            set_no_flag=beach-@R0-[@R5,@R1]
        [/tile]
        [tile]
            pos=2
            type={ADJACENT}
            set_no_flag=beach-@R2-@R3
        [/tile]
        [tile]
            pos=3
            type={ADJACENT}
            set_no_flag=beach-@R4-@R3
        [/tile]

        rotations=tr,r,br,bl,l,tl

        [image]
            # wmlscope: start ignoring
            name={IMAGESTEM}-convex-@R0-@R5.png
            # wmlscope: stop ignoring
            layer=-500
            center=90,144
            base=90,144
        [/image]
        [image]
            # wmlscope: start ignoring
            name={IMAGESTEM}-convex-@R0-@R1.png
            # wmlscope: stop ignoring
            layer=-500
            center=90,144
            base=90,144
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
,  2
*,   3
,  1
*,   *
,  *"
        [tile]
            pos=1
            type={TERRAINLIST}
            set_no_flag=beach-@R0-@R5
        [/tile]
        [tile]
            pos=2
            type={ADJACENT}
            set_no_flag=beach-@R2-@R3
        [/tile]
        [tile]
            pos=3
            type=!,{TERRAINLIST},{ADJACENT}
        [/tile]

        rotations=tr,r,br,bl,l,tl

        [image]
            # wmlscope: start ignoring
            name={IMAGESTEM}-convex-@R0-@R5.png
            # wmlscope: stop ignoring
            layer=-500
            center=90,144
            base=90,144
        [/image]
    [/terrain_graphics]

    [terrain_graphics]
        map="
,  2
*,   3
,  1
*,   *
,  *"
        [tile]
            pos=1
            type={TERRAINLIST}
            set_no_flag=beach-@R0-@R1
        [/tile]
        [tile]
            pos=2
            type=!,{TERRAINLIST},{ADJACENT}
        [/tile]
        [tile]
            pos=3
            type={ADJACENT}
            set_no_flag=beach-@R4-@R3
        [/tile]

        rotations=tr,r,br,bl,l,tl

        [image]
            # wmlscope: start ignoring
            name={IMAGESTEM}-convex-@R0-@R1.png
            # wmlscope: stop ignoring
            layer=-500
            center=90,144
            base=90,144
        [/image]
    [/terrain_graphics]
#enddef

#define NEW:VILLAGE TERRAINLIST IMAGESTEM
    [terrain_graphics]
        map="
, *
* , *
, 1
* , *
, *"

        [tile]
            pos=1
            type={TERRAINLIST}
            set_no_flag=village
        [/tile]

        [image]
            name={IMAGESTEM}@V.png
            variations=";2;3;4"
            layer=0
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]
#enddef

#define NEW:VILLAGE_A3 TERRAINLIST TIME IMAGESTEM
    [terrain_graphics]
        map="
, *
* , *
, 1
* , *
, *"

        [tile]
            pos=1
            type={TERRAINLIST}
            set_no_flag=village
        [/tile]

        [image]
            name={IMAGESTEM}[01~03].png:{TIME}
            layer=0
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]
#enddef

#define NEW:VILLAGE_A4 TERRAINLIST TIME IMAGESTEM
    [terrain_graphics]
        map="
, *
* , *
, 1
* , *
, *"

        [tile]
            pos=1
            type={TERRAINLIST}
            set_no_flag=village
        [/tile]

        [image]
            name={IMAGESTEM}[01~04].png:{TIME}
            layer=0
            base=90,144
            center=90,144
        [/image]
    [/terrain_graphics]
#enddef

# This hacky macro will hopefully be replaced with a more elegant way of passing
# variation-specific probabilities sometime
#define VILLAGE_PROBABILITY PROB
    [+terrain_graphics]
        probability={PROB}
    [/terrain_graphics]
#enddef
