# The following flags are defined to have a meaning
#
# * base : the corresponding tile has already graphics for the terrain
# base. No other one should be added.
# * transition-$direction : the corresponding tile already has the transition
# in the given direction (or should not have one). No other one should be
# added.
# * keep-of-$castle : castle being a tile letter. The corresponding tile is the
# keep correspoding to the given castle tile

# The following should be kept on top of the file
{terrain-graphics}

#-----------------------------------------------------------------
# Forest<->Castle|Encampment special cases
#-----------------------------------------------------------------
#define FORESTADJCASTLEA FID ID PROB TILE
[terrain_graphics]
      map="
  1
*   1
  2
*   *
  *"

         [tile]
                 pos=1
                 type={ID}
         [/tile]

         [tile]
                 pos=2
                 type={FID}
                 no_flag="overlay"
                 set_flag="overlay"
         [/tile]

         probability={PROB}
         rotations=n,ne,se,s,sw,nw
         
         [image]
                 name={TILE}
                 position=vertical
                 base=90,144
         [/image]


[/terrain_graphics]
#enddef

{FORESTADJCASTLEA f Cn 100 forest-castle}
{FORESTADJCASTLEA F Cn 100 snow-forest-castle}

#define FORESTADJCASTLES FID ID PROB TILE
[terrain_graphics]
      map="
  1
*   *
  2
*   1
  *"

         [tile]
                 pos=1
                 type={ID}
         [/tile]

         [tile]
                 pos=2
                 type={FID}
                 no_flag="overlay"
                 set_flag="overlay"
         [/tile]

         probability={PROB}
         rotations=n,ne,se,s,sw,nw
         
         [image]
                 name={TILE}
                 position=vertical
                 base=90,144
         [/image]


[/terrain_graphics]
#enddef

{FORESTADJCASTLES f Cn 100 forest-castle}
{FORESTADJCASTLES F Cn 100 snow-forest-castle}

#define FORESTADJCASTLEO FID ID PROB TILE
[terrain_graphics]
      map="
  1
*   *
  2
*   *
  1"

         [tile]
                 pos=1
                 type={ID}
         [/tile]

         [tile]
                 pos=2
                 type={FID}
                 no_flag="overlay"
                 set_flag="overlay"
         [/tile]

         probability={PROB}
         rotations=n,ne,se,s,sw,nw
         
         [image]
                 name={TILE}
                 position=vertical
                 base=90,144
         [/image]


[/terrain_graphics]
#enddef

{FORESTADJCASTLEO f Cn 100 forest-castle}
{FORESTADJCASTLEO F Cn 100 snow-forest-castle}

#define FORESTADJCASTLE FID ID PROB TILE
[terrain_graphics]
      map="
  1
*   *
  2
*   *
  *"

         [tile]
                 pos=1
                 type={ID}
         [/tile]

         [tile]
                 pos=2
                 type={FID}
                 no_flag="overlay"
                 set_flag="overlay"
         [/tile]

         probability={PROB}
         rotations=n,ne,se,s,sw,nw
         
         [image]
                 name={TILE}-@R0
                 position=vertical
                 base=90,144
         [/image]


[/terrain_graphics]
#enddef

{FORESTADJCASTLE f Cn 100 forest-castle}
{FORESTADJCASTLE F Cn 100 snow-forest-castle}

#-----------------------------------------------------------------
# Use a Different forest tile  when next to:
# Shallow and deep Water, mountain, desert hill & mountain, 
# swamp and villages
#-----------------------------------------------------------------
#define FORESTADJ FID ID PROB TILE
[terrain_graphics]
      map="
  1
*   *
  2
*   *
  *"

         [tile]
                 pos=1
                 type={ID}
         [/tile]

         [tile]
                 pos=2
                 type={FID}
                 no_flag="overlay"
                 set_flag="overlay"
         [/tile]

         probability={PROB}
         rotations=n,ne,se,s,sw,nw
         
         [image]
                 name={TILE}
                 position=vertical
                 base=90,144
         [/image]


[/terrain_graphics]
#enddef

{FORESTADJ f csmJMwvabt 33 forest_small}
{FORESTADJ f csmJMwvabt 25 forest3}
{FORESTADJ f csmJMwvabt 10 forest4}
{FORESTADJ f csmJMwvabt 100 forest2_small}

{FORESTADJ F csmJMwvabt 100 snow-forest_small}

#Macro for Single Hex
#define SHEX TYPE FLAG PROB TILE
[terrain_graphics]
      map="
  *
*   *
  1
*   *
  *"

         [tile]
                 pos=1
                 type={TYPE}
                 no_flag={FLAG}
                 set_flag={FLAG}
         [/tile]

         probability={PROB}

         [image]
                 name={TILE}
                 position=vertical
                 base=90,146
         [/image]
[/terrain_graphics]
#enddef

#Single hex normal forest tiles
{SHEX f overlay 33 forest}
{SHEX f overlay 25 forest3}
{SHEX f overlay 10 forest4}
{SHEX f overlay 100 forest2}

#Single hex normal snow forest tiles
{SHEX F overlay 25 snow-forest2}
{SHEX F overlay 25 snow-forest3}
{SHEX F overlay 25 snow-forest4}
{SHEX F overlay 100 snow-forest}

#Single hex human villages (grassland)
{SHEX v overlay 33 village-human}
{SHEX v overlay 33 village-human2}
{SHEX v overlay 100 village-human3}

#Single hex human villages (hills)
{SHEX a overlay 33 village-human}
{SHEX a overlay 33 village-human2}
{SHEX a overlay 100 village-human3}

#Single hex human villages (mountains)
{SHEX b overlay 33 village-human}
{SHEX b overlay 33 village-human2}
{SHEX b overlay 100 village-human3}

#Single hex human villages (snow)
{SHEX VA overlay 33 village-human-snow}
{SHEX VA overlay 33 village-human-snow2}
{SHEX VA overlay 100 village-human-snow3}

#Single hex elven villages
{SHEX t overlay 50 village-elven}
{SHEX t overlay 100 village-elven2}

#Single hex elven villages (snow)
{SHEX e overlay 50 village-elven-snow}
{SHEX e overlay 100 village-elven-snow2}

#Single hex desert villages
{SHEX B overlay 100 village-desert}
{SHEX U overlay 100 village-desert2}

#Single hex underground villages
{SHEX D overlay 33 village-cave}
{SHEX D overlay 33 village-cave2}
{SHEX D overlay 100 village-cave3}

# Castle-specific transitions. Those are placed before base terrains, as they
# override the normal base terrain.
{CASTLE_TRANSITION CK T tropical-forest-ctrans}
#Special cases for encampment (nw, nw-n-ne and ne)
{CASTLE_TRANSITION nK T tropical-forest-ctrans}
#On the rest fall back on forest-castle
{CASTLE_TRANSITION nK f forest-ctrans}
#added ruins
#{CASTLE_TRANSITION NK f forest-ctrans}
#{CASTLE_TRANSITION QK f forest-ctrans}
#{CASTLE_TRANSITION qK f forest-ctrans}

#
# Attachs graphics to each known terrain types
#

{TERRAIN_BASE_PROB 	      u cave-floor4 	10} 
{TERRAIN_BASE_PROB 	      u cave-floor3 	3} 
{TERRAIN_BASE_PROB 	      u cave-floor2 	15} 
{TERRAIN_BASE_PROB 	      u cave-floor 	10} 
{TERRAIN_BASE 		      u cave-floor1}
{TERRAIN_BASE                 W cavewall}
{TERRAIN_BASE_PROB            m mountains-peak1     33}
{TERRAIN_BASE_PROB            m mountains-peak2     33}
{TERRAIN_BASE                 m mountains}
{TERRAIN_BASE_PROB            H snow-hills3         30}
{TERRAIN_BASE_PROB            H snow-hills2         30}
{TERRAIN_BASE                 H snow-hills}
{TERRAIN_BASE_PROB            h hills-variation1    15}
{TERRAIN_BASE_PROB            h hills-variation2    15}
{TERRAIN_BASE_PROB            h hills-variation3    30}
{TERRAIN_BASE                 h hills}
{TERRAIN_BASE_PROB            SF snow2 30}
{TERRAIN_BASE_PROB            SF snow3 30}
{TERRAIN_BASE                 SF snow}
{TERRAIN_BASE_PROB            g grassland-rocks1    2}
{TERRAIN_BASE_PROB            g grassland-rocks2    2}
{TERRAIN_BASE_PROB            g grassland-flowers1  3}
{TERRAIN_BASE_PROB            g grassland-flowers2  3}
{TERRAIN_BASE_PROB            gf grassland-r1 20}
{TERRAIN_BASE_PROB            gf grassland-r2 20}
{TERRAIN_BASE_PROB            gf grassland-r3 20}
{TERRAIN_BASE                 gf grassland-r4}
{TERRAIN_BASE                 r dirt}
{TERRAIN_BASE_PROB            R road3 33} 
{TERRAIN_BASE_PROB            R road2 33}
{TERRAIN_BASE                 R road}
{TERRAIN_BASE_PROB            d sand-plant        10}
{TERRAIN_BASE                 d sand}
{TERRAIN_BASE_PROB            i ice2 10}
{TERRAIN_BASE_PROB            i ice3 10}
{TERRAIN_BASE_PROB            i ice4 25}
{TERRAIN_BASE_PROB            i ice5 10}
{TERRAIN_BASE_PROB            i ice6 10}
{TERRAIN_BASE                 i ice}
{TERRAIN_BASE_PROB            w swampwater-flowers1  8}
{TERRAIN_BASE_PROB            w swampwater-flowers2  8}
{TERRAIN_BASE_PROB            w swampwater-plant1   10}
{TERRAIN_BASE_PROB            w swampwater-plant2   10}
{TERRAIN_BASE_PROB            w swampwater2         33}
{TERRAIN_BASE_PROB            w swampwater3         50}
{TERRAIN_BASE                 w swampwater}
{TERRAIN_BASE_PROB            c\|/ coast3        30}
{TERRAIN_BASE_PROB            c\|/ coast2        30}
{TERRAIN_BASE                 c\|/ coast}
{TERRAIN_BASE_PROB            s ocean3         30}
{TERRAIN_BASE_PROB            s ocean2         30}
{TERRAIN_BASE                 s ocean}
{TERRAIN_BASE                 ~ fog}
{TERRAIN_BASE_PROB            I desert-plant   2}
{TERRAIN_BASE_PROB            I desert-plant2  2}
{TERRAIN_BASE_PROB            I desert-plant3  2}
{TERRAIN_BASE_PROB            I desert2        25}
{TERRAIN_BASE_PROB            I desert3        25}
{TERRAIN_BASE_PROB            I desert4        5}
{TERRAIN_BASE_PROB            I desert5        5}
{TERRAIN_BASE_PROB            I desert6        5}
{TERRAIN_BASE_PROB            I desert7        5}
{TERRAIN_BASE                 I desert}
{TERRAIN_BASE_PROB            J desert-hills2  33}
{TERRAIN_BASE_PROB            J desert-hills3  33}
{TERRAIN_BASE                 J desert-hills}
{TERRAIN_BASE_PROB            M desert-mountain-peak1     25}
{TERRAIN_BASE_PROB            M desert-mountain-peak2     25}
{TERRAIN_BASE_PROB            M desert-mountain-peak3     25}
{TERRAIN_BASE                 M desert-mountains}
{TERRAIN_BASE_PROB_OV         T tropical-forest2 25}
{TERRAIN_BASE_PROB_OV         T tropical-forest3 25}
{TERRAIN_BASE_PROB_OV         T tropical-forest4 25}
{TERRAIN_BASE_OV              T tropical-forest}
{TERRAIN_BASE                 GT savanna}
{TERRAIN_BASE                 E desert-road}
{TERRAIN_BASE                 P desert-oasis}
#set them to 33 for some irregulrity
{TERRAIN_BASE_PROB            k ford2 33}
{TERRAIN_BASE                 k ford}
{TERRAIN_BASE_PROB            l lava2  33}
{TERRAIN_BASE                 l lava}

{TERRAIN_BASE                 X grassland-r1}
{CANYON X canyon}
#added ruins
{BRIDGE \ | / cs CKfFNQq bridge}

#
# Villages
#

{TERRAIN_BASE Y swampwater}
{TERRAIN_BASE Ve snow}
{TERRAIN_BASE Z coast}
{TERRAIN_BASE v grassland-r1}
{TERRAIN_BASE D cave-floor1}
{TERRAIN_BASE t grassland-r1}
{TERRAIN_BASE a hills}
{TERRAIN_BASE A snow-hills}
{TERRAIN_BASE b mountains}
{TERRAIN_BASE BU desert}
{TERRAIN_BASE L savanna}

{BUILDING Y ({VIMG       36,40 village-swampwater })}
{BUILDING Z ({VIMG       36,40 village-coast      })}
#{BUILDING A ({VIMG       36,40 village-snow     })}
{BUILDING L ({VIMG       36,40 village-tropical-forest  })}


#
# Transition between terrains
#

# Special transitions go first

# Castle and keeps. Always use the same letter for keeps: the CASTLE_AND_KEEP
# macro will determine the correct graphics to use, according to the adjacent
# castle letter.

# Flags the keep, they must be flagged to be recognized by the
# {CASTLE_AND_foo_KEEP} macros

#added ruins
{FLAG_IF_ADJACENT K N keep-of-N keep-flag}
{FLAG_IF_ADJACENT K Q keep-of-Q keep-flag}
{FLAG_IF_ADJACENT K q keep-of-q keep-flag}

{FLAG_IF_ADJACENT K C keep-of-C keep-flag}
{FLAG_IF_ADJACENT K n keep-of-n keep-flag}
{FLAG_IF_ADJACENT K o keep-of-o keep-flag}
{FLAG_REMAINING   K   keep-of-C keep-flag}

#
# Castles base terrains
#

{DISABLE_TRANSITIONS K}

{TERRAIN_BASE C castle}
{TERRAIN_BASE o dwarven-castle-floor}
{TERRAIN_BASE n dirt}
#added ruins
{TERRAIN_BASE N castle}
{TERRAIN_BASE Q sunken-ruin}
{TERRAIN_BASE_PROB            q swampwater2         30}
{TERRAIN_BASE_PROB            q swampwater3         30}
{TERRAIN_BASE q swampwater}

#{TERRAIN_BASE O orccastle}

{TERRAIN_BASE_FLAG K keep-of-C castle}
{TERRAIN_BASE_FLAG K keep-of-o dwarven-keep-floor}
{TERRAIN_BASE_FLAG K keep-of-n dirt}
#added ruins
{TERRAIN_BASE_FLAG K keep-of-N castle}
{TERRAIN_BASE_FLAG K keep-of-Q castle}
{TERRAIN_BASE_FLAG K keep-of-q castle}


# Loyalist castle
{DISABLE_TRANSITIONS C}
#added ruins
{TERRAIN_ADJACENT_CORNER       C      !NQqCK    !NQqCK   52,76 castle-convex}
{TERRAIN_ADJACENT_CORNER       !NQqCK    C      NQqC     56,68 castle-concave}
{TERRAIN_ADJACENT_CORNER       K      C       NQqC     54,72 keep-inside}
{TERRAIN_ADJACENT_CORNER_FLAG1 K      !NQqCK    !NQqCK   52,76 keep-of-C keep-wall}
{TERRAIN_ADJACENT_CORNER       K      !NQqCK   C       52,72 keep-wall-0}
{TERRAIN_ADJACENT_CORNER       K      C      !NQqCK    56,76 keep-wall-1} 
{TERRAIN_ADJACENT_CORNER_FLAG1 K      K      !K      56,76 keep-of-C keep-keep}

# ruined castle
#{DISABLE_TRANSITIONS N} #we want transitions...makes ruins look overgrown...

{TERRAIN_ADJACENT_CORNER_PROB  N      !NQqCK   !NQqCK   52,76 ruin5-convex 17}
{TERRAIN_ADJACENT_CORNER_PROB  N      !NQqCK   !NQqCK   52,76 ruin4-convex 20}
{TERRAIN_ADJACENT_CORNER_PROB  N      !NQqCK   !NQqCK   52,76 ruin3-convex 25}
{TERRAIN_ADJACENT_CORNER_PROB  N      !NQqCK   !NQqCK   52,76 ruin2-convex 33}
{TERRAIN_ADJACENT_CORNER_PROB  N      !NQqCK   !NQqCK   52,76 ruin1-convex 50}
{TERRAIN_ADJACENT_CORNER_PROB  N      !NQqCK   !NQqCK   52,76 castle-convex 100}

{TERRAIN_ADJACENT_CORNER_PROB  !NQqCK   N     NQqC     56,68 ruin5-concave 17}
{TERRAIN_ADJACENT_CORNER_PROB  !NQqCK   N     NQqC     56,68 ruin4-concave 20}
{TERRAIN_ADJACENT_CORNER_PROB  !NQqCK   N     NQqC     56,68 ruin3-concave 25}
{TERRAIN_ADJACENT_CORNER_PROB  !NQqCK   N     NQqC     56,68 ruin2-concave 33}
{TERRAIN_ADJACENT_CORNER_PROB  !NQqCK   N     NQqC     56,68 ruin1-concave 50}
{TERRAIN_ADJACENT_CORNER_PROB  !NQqCK   N     NQqC     56,68 castle-concave 100}

{TERRAIN_ADJACENT_CORNER_PROB  K      N     NQqC      54,72 ruinkeep3-inside 25}
{TERRAIN_ADJACENT_CORNER_PROB  K      N     NQqC      54,72 ruinkeep2-inside 33}
{TERRAIN_ADJACENT_CORNER_PROB  K      N     NQqC      54,72 ruinkeep1-inside 50}
{TERRAIN_ADJACENT_CORNER_PROB  K      N     NQqC      54,72 keep-inside 100}

{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K     !NQqCK   !NQqCK     54,72 keep-of-N ruinkeep3-wall 25}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K     !NQqCK   !NQqCK     54,72 keep-of-N ruinkeep2-wall 33}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K     !NQqCK   !NQqCK     54,72 keep-of-N ruinkeep1-wall 50}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K     !NQqCK   !NQqCK     52,76 keep-of-N keep-wall 100}

{TERRAIN_ADJACENT_CORNER_PROB  K      !NQqCK   N       54,72 ruinkeep3-wall-0 25}
{TERRAIN_ADJACENT_CORNER_PROB  K      !NQqCK   N       54,72 ruinkeep2-wall-0 33}
{TERRAIN_ADJACENT_CORNER_PROB  K      !NQqCK   N       54,72 ruinkeep1-wall-0 50}
{TERRAIN_ADJACENT_CORNER_PROB  K      !NQqCK   N       52,72 keep-wall-0 100}


{TERRAIN_ADJACENT_CORNER_PROB  K      N      !NQqCK    54,72 ruinkeep3-wall-1 25}
{TERRAIN_ADJACENT_CORNER_PROB  K      N      !NQqCK    54,72 ruinkeep2-wall-1 34}
{TERRAIN_ADJACENT_CORNER_PROB  K      N      !NQqCK    54,72 ruinkeep1-wall-1 50}
{TERRAIN_ADJACENT_CORNER_PROB  K      N      !NQqCK    56,76 keep-wall-1 100} 


{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K      K      !K      54,72 keep-of-N ruinkeep3-keep 34}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K      K      !K      54,72 keep-of-N ruinkeep2-keep 34}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K      K      !K      54,72 keep-of-N ruinkeep1-keep 50}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K      K      !K      56,76 keep-of-N keep-keep 100}


# sunken ruined castle
#{DISABLE_TRANSITIONS Q}

{TERRAIN_ADJACENT_CORNER_PROB  Q      wc   wc     52,76 sunken-ruin5-convex 17}
{TERRAIN_ADJACENT_CORNER_PROB  Q      wc   wc     52,76 sunken-ruin4-convex 20}
{TERRAIN_ADJACENT_CORNER_PROB  Q      wc   wc     52,76 sunken-ruin3-convex 25}
{TERRAIN_ADJACENT_CORNER_PROB  Q      wc   wc     52,76 sunken-ruin2-convex 33}
{TERRAIN_ADJACENT_CORNER_PROB  Q      wc   wc     52,76 sunken-ruin1-convex 50}
{TERRAIN_ADJACENT_CORNER_PROB  Q      wc   wc     52,76 sunken-ruin-convex 100}

{TERRAIN_ADJACENT_CORNER_PROB  wc   Q      qQNC      56,68 sunken-ruin5-concave 16}
{TERRAIN_ADJACENT_CORNER_PROB  wc   Q      qQNC      56,68 sunken-ruin4-concave 20}
{TERRAIN_ADJACENT_CORNER_PROB  wc   Q      qQNC      56,68 sunken-ruin3-concave 25}
{TERRAIN_ADJACENT_CORNER_PROB  wc   Q      qQNC      56,68 sunken-ruin2-concave 33}
{TERRAIN_ADJACENT_CORNER_PROB  wc   Q      qQNC      56,68 sunken-ruin1-concave 50}
{TERRAIN_ADJACENT_CORNER_PROB  wc   Q      qQNC      56,68 sunken-ruin-concave 100}

{TERRAIN_ADJACENT_CORNER_PROB  Q      !qQNCK   !qQNCK     52,76 ruin5-convex 17}	
{TERRAIN_ADJACENT_CORNER_PROB  Q      !qQNCK   !qQNCK     52,76 ruin4-convex 20}	
{TERRAIN_ADJACENT_CORNER_PROB  Q      !qQNCK   !qQNCK     52,76 ruin3-convex 25}	
{TERRAIN_ADJACENT_CORNER_PROB  Q      !qQNCK   !qQNCK     52,76 ruin2-convex 33}	
{TERRAIN_ADJACENT_CORNER_PROB  Q      !qQNCK   !qQNCK     52,76 ruin1-convex 50}	
{TERRAIN_ADJACENT_CORNER_PROB  Q      !qQNCK   !qQNCK     52,76 castle-convex 100}      

{TERRAIN_ADJACENT_CORNER_PROB  !qQNCK   Q      qQNC      56,68 ruin5-concave 17}	
{TERRAIN_ADJACENT_CORNER_PROB  !qQNCK   Q      qQNC      56,68 ruin4-concave 20}	
{TERRAIN_ADJACENT_CORNER_PROB  !qQNCK   Q      qQNC      56,68 ruin3-concave 25}	
{TERRAIN_ADJACENT_CORNER_PROB  !qQNCK   Q      qQNC      56,68 ruin2-concave 33}	
{TERRAIN_ADJACENT_CORNER_PROB  !qQNCK   Q      qQNC      56,68 ruin1-concave 50}	
{TERRAIN_ADJACENT_CORNER_PROB  !qQNCK   Q      qQNC      56,68 castle-concave 100}      

{TERRAIN_ADJACENT_CORNER_PROB  K      Q     NQqC      54,72 sunken-ruinkeep3-inside 25}
{TERRAIN_ADJACENT_CORNER_PROB  K      Q     NQqC      54,72 sunken-ruinkeep2-inside 33}
{TERRAIN_ADJACENT_CORNER_PROB  K      Q     NQqC      54,72 sunken-ruinkeep1-inside 50}
{TERRAIN_ADJACENT_CORNER_PROB  K      Q     NQqC      54,72 sunkenkeep-inside 100}     

{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K     !NQqCK   !NQqCK     52,76 keep-of-Q sunken-ruinkeep3-wall 25}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K     !NQqCK   !NQqCK     52,76 keep-of-Q sunken-ruinkeep2-wall 33}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K     !NQqCK   !NQqCK     52,76 keep-of-Q sunken-ruinkeep1-wall 50}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K     !NQqCK   !NQqCK     52,76 keep-of-Q sunkenkeep-wall 100}

{TERRAIN_ADJACENT_CORNER_PROB  K      !NQqCK   Q       52,72 sunken-ruinkeep3-wall-0 25}
{TERRAIN_ADJACENT_CORNER_PROB  K      !NQqCK   Q       52,72 sunken-ruinkeep2-wall-0 33}
{TERRAIN_ADJACENT_CORNER_PROB  K      !NQqCK   Q       52,72 sunken-ruinkeep1-wall-0 50}
{TERRAIN_ADJACENT_CORNER_PROB  K      !NQqCK   Q       52,72 sunkenkeep-wall-0 100}

{TERRAIN_ADJACENT_CORNER_PROB  K      Q      !NQqCK    56,76 sunken-ruinkeep3-wall-1 25} 
{TERRAIN_ADJACENT_CORNER_PROB  K      Q      !NQqCK    56,76 sunken-ruinkeep2-wall-1 33} 
{TERRAIN_ADJACENT_CORNER_PROB  K      Q      !NQqCK    56,76 sunken-ruinkeep1-wall-1 50} 
{TERRAIN_ADJACENT_CORNER_PROB  K      Q      !NQqCK    56,76 sunkenkeep-wall-1 100} 

{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K      K      !K      56,76 keep-of-Q sunken-ruinkeep3-keep 25}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K      K      !K      56,76 keep-of-Q sunken-ruinkeep2-keep 33}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K      K      !K      56,76 keep-of-Q sunken-ruinkeep1-keep 50}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K      K      !K      56,76 keep-of-Q sunkenkeep-keep 100}

# swamp ruined castle
#{DISABLE_TRANSITIONS q}

{TERRAIN_ADJACENT_CORNER_PROB  q      wc   wc     52,76 sunken-ruin5-convex 17}
{TERRAIN_ADJACENT_CORNER_PROB  q      wc   wc     52,76 sunken-ruin4-convex 20}
{TERRAIN_ADJACENT_CORNER_PROB  q      wc   wc     52,76 sunken-ruin3-convex 25}
{TERRAIN_ADJACENT_CORNER_PROB  q      wc   wc     52,76 sunken-ruin2-convex 33}
{TERRAIN_ADJACENT_CORNER_PROB  q      wc   wc     52,76 sunken-ruin1-convex 50}
{TERRAIN_ADJACENT_CORNER_PROB  q      wc   wc     52,76 sunken-ruin-convex 100}

{TERRAIN_ADJACENT_CORNER_PROB  wc   q      qQNC      56,68 sunken-ruin5-concave 17}
{TERRAIN_ADJACENT_CORNER_PROB  wc   q      qQNC      56,68 sunken-ruin4-concave 20}
{TERRAIN_ADJACENT_CORNER_PROB  wc   q      qQNC      56,68 sunken-ruin3-concave 25}
{TERRAIN_ADJACENT_CORNER_PROB  wc   q      qQNC      56,68 sunken-ruin2-concave 33}
{TERRAIN_ADJACENT_CORNER_PROB  wc   q      qQNC      56,68 sunken-ruin1-concave 50}
{TERRAIN_ADJACENT_CORNER_PROB  wc   q      qQNC      56,68 sunken-ruin-concave 100}


{TERRAIN_ADJACENT_CORNER_PROB  q      !qQNCK   !qQNCK     52,76 ruin5-convex 17}
{TERRAIN_ADJACENT_CORNER_PROB  q      !qQNCK   !qQNCK     52,76 ruin4-convex 20}
{TERRAIN_ADJACENT_CORNER_PROB  q      !qQNCK   !qQNCK     52,76 ruin3-convex 25}
{TERRAIN_ADJACENT_CORNER_PROB  q      !qQNCK   !qQNCK     52,76 ruin2-convex 33}
{TERRAIN_ADJACENT_CORNER_PROB  q      !qQNCK   !qQNCK     52,76 ruin1-convex 50} 
{TERRAIN_ADJACENT_CORNER_PROB  q      !qQNCK   !qQNCK     52,76 castle-convex 100}

{TERRAIN_ADJACENT_CORNER_PROB  !qQNCK   q      qQNC      56,68 ruin5-concave 17}	
{TERRAIN_ADJACENT_CORNER_PROB  !qQNCK   q      qQNC      56,68 ruin4-concave 20}	
{TERRAIN_ADJACENT_CORNER_PROB  !qQNCK   q      qQNC      56,68 ruin3-concave 25}	
{TERRAIN_ADJACENT_CORNER_PROB  !qQNCK   q      qQNC      56,68 ruin2-concave 33}	
{TERRAIN_ADJACENT_CORNER_PROB  !qQNCK   q      qQNC      56,68 ruin1-concave 50}	
{TERRAIN_ADJACENT_CORNER_PROB  !qQNCK   q      qQNC      56,68 castle-concave 100}      

{TERRAIN_ADJACENT_CORNER_PROB  K      q     NQqC      54,72 sunken-ruinkeep3-inside 25}
{TERRAIN_ADJACENT_CORNER_PROB  K      q     NQqC      54,72 sunken-ruinkeep2-inside 33}
{TERRAIN_ADJACENT_CORNER_PROB  K      q     NQqC      54,72 sunken-ruinkeep1-inside 50}
{TERRAIN_ADJACENT_CORNER_PROB  K      q     NQqC      54,72 sunkenkeep-inside 100}     

{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K     !NQqCK   !NQqCK     52,76 keep-of-q sunken-ruinkeep3-wall 25}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K     !NQqCK   !NQqCK     52,76 keep-of-q sunken-ruinkeep2-wall 33}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K     !NQqCK   !NQqCK     52,76 keep-of-q sunken-ruinkeep1-wall 50}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K     !NQqCK   !NQqCK     52,76 keep-of-q sunkenkeep-wall 100}	

{TERRAIN_ADJACENT_CORNER_PROB  K      !NQqCK   q       52,72 sunken-ruinkeep3-wall-0 25}
{TERRAIN_ADJACENT_CORNER_PROB  K      !NQqCK   q       52,72 sunken-ruinkeep2-wall-0 33}
{TERRAIN_ADJACENT_CORNER_PROB  K      !NQqCK   q       52,72 sunken-ruinkeep1-wall-0 50}
{TERRAIN_ADJACENT_CORNER_PROB  K      !NQqCK   q       52,72 sunkenkeep-wall-0 100}	

{TERRAIN_ADJACENT_CORNER_PROB  K      q      !NQqCK    56,76 sunken-ruinkeep3-wall-1 25} 
{TERRAIN_ADJACENT_CORNER_PROB  K      q      !NQqCK    56,76 sunken-ruinkeep2-wall-1 33} 
{TERRAIN_ADJACENT_CORNER_PROB  K      q      !NQqCK    56,76 sunken-ruinkeep1-wall-1 50} 
{TERRAIN_ADJACENT_CORNER_PROB  K      q      !NQqCK    56,76 sunkenkeep-wall-1 100} 	 

{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K      K      !K      56,76 keep-of-q sunken-ruinkeep3-keep 25}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K      K      !K      56,76 keep-of-q sunken-ruinkeep2-keep 33}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K      K      !K      56,76 keep-of-q sunken-ruinkeep1-keep 50}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K      K      !K      56,76 keep-of-q sunkenkeep-keep 100}	    

# Encampments
{DISABLE_TRANSITIONS n}
{TERRAIN_ADJACENT_CORNER       n      !nK    !nK     52,76 encampment-convex}
{TERRAIN_ADJACENT_CORNER       !nK    n      n       56,68 encampment-concave}
{TERRAIN_ADJACENT_CORNER_FLAG1 K      !nK    !nK     52,76 keep-of-n encampment-convex}
{TERRAIN_ADJACENT_CORNER       !nK    K      n       52,76 encampment-concave}
{TERRAIN_ADJACENT_CORNER       !nK    n      K       52,76 encampment-concave}

# Cave and dwarven castles
{DISABLE_TRANSITIONS W}
{DISABLE_TRANSITIONS o}
{TERRAIN_ADJACENT_CORNER       W      !WoK   !WoK    52,76 cavewall-convex}
{TERRAIN_ADJACENT_CORNER       !WoK   W      W       56,68 cavewall-concave}
{TERRAIN_ADJACENT_CORNER       o      !WoK   !WoK    52,76 dwarven-castle-convex}
{TERRAIN_ADJACENT_CORNER       !WoK   o      o       56,68 dwarven-castle-concave}
{TERRAIN_ADJACENT_CORNER_FLAG1 K      !WoK   !WoK    52,76 keep-of-o dwarven-castle-convex}
{TERRAIN_ADJACENT_CORNER       !WoK   K      o       56,68 dwarven-castle-concave}
{TERRAIN_ADJACENT_CORNER       !WoK   o      K       56,68 dwarven-castle-concave}
{TERRAIN_ADJACENT_CORNER       oK     W      W       52,76 dwarven-castle-wall-convex}
{TERRAIN_ADJACENT_CORNER       W      oK     oK      56,68 dwarven-castle-wall-concave}
{TERRAIN_ADJACENT_CORNER       oK     W      !WoK    54,68 dwarven-castle-wall-cw}
{TERRAIN_ADJACENT_CORNER       oK     !WoK   W       54,68 dwarven-castle-wall-ccw}

# Orcish castle
{DISABLE_TRANSITIONS O}
{TERRAIN_ADJACENT_CORNER       O      !O     !O      54,72 orccastle-convex}
{TERRAIN_ADJACENT_CORNER       !O     O      O       54,72 orccastle-concave}
#{TERRAIN_ADJACENT_CORNER   -50        K      O      O       <name>}
#{TERRAIN_ADJACENT_CORNER_FLAG1 -50    K      !OK    !OK     keep-of-O <name>}
#{TERRAIN_ADJACENT_CORNER   -50        K      O      !OK     <name>}
#{TERRAIN_ADJACENT_CORNER   -50        K      !OK    O       <name>} 

# Castle decorations and castle floors. Those must always be after the castles
# are defined.
{BUILDING_FLAG K ({VIMG 36,40 tent}) keep-of-n}
{BUILDING_FLAG K ({VIMG 36,40 dwarven-keep}) keep-of-o}

# {TERRAIN_ADJACENT_OV       -78         F      !F      snow-forest}
#added ruins
{TERRAIN_ADJACENT_VERTICAL             T      !TNQq      tropical-forest}
#{TERRAIN_ADJACENT_VERTICAL             F      !FNQq      snow-forest}
#{TERRAIN_ADJACENT_VERTICAL             f      !fNQq      forest}
{TERRAIN_ADJACENT          -174        mHhfF  N       grassland}
{TERRAIN_ADJACENT          -175        M     !M       desert-mountains}
{TERRAIN_ADJACENT          -176        mb     !mb     mountains}
{TERRAIN_ADJACENT          -177        HA     !HA     snow-hills}
{TERRAIN_ADJACENT          -178        J      !J      desert-hills}
{TERRAIN_ADJACENT          -179        ha     !ha     hills}
{TERRAIN_ADJACENT          -180        l      !lW     lava}
{TERRAIN_ADJACENT          -181        uD     !uD     cave-floor}
{TERRAIN_ADJACENT          -182        FS     ks      snow-to-water}
{TERRAIN_ADJACENT          -183        FS     cZp\|/  snow-to-water}
{TERRAIN_ADJACENT          -184        FS     s       snow-to-water}
{TERRAIN_ADJACENT          -185        SVFe    !SVFe    snow}
{TERRAIN_ADJACENT          -186        i      !i      ice}
{TERRAIN_ADJACENT          -187        TG     ks       savanna-to-water}
{TERRAIN_ADJACENT          -188        TG     cZp\|/  savanna-to-water}
{TERRAIN_ADJACENT          -189        TG     s       savanna-to-water}
{TERRAIN_ADJACENT          -190        ftgvX  ks       grassland-to-water}
{TERRAIN_ADJACENT          -191        ftgvX  cZp\|/  grassland-to-water}
{TERRAIN_ADJACENT          -192        ftgvX  s       grassland-to-water}
#{TERRAIN_ADJACENT          -193        ftgvX  cZp\|/s cliff}
{TERRAIN_ADJACENT          -193        GT     !GT     savanna}
{TERRAIN_ADJACENT          -194        ftgvX  !ftgvX  grassland}
{TERRAIN_ADJACENT          -195        PIB    !PIB    desert-oasis}
{TERRAIN_ADJACENT          -196        IBPU   !IBPU   desert}
{TERRAIN_ADJACENT          -197        d      !d      sand}
{TERRAIN_ADJACENT          -198        r      !r      dirt}
{TERRAIN_ADJACENT          -199        E      !E      desert-road}
{TERRAIN_ADJACENT          -200        R      !R      road}

#addedruins
{TERRAIN_ADJACENT          -201        Ywq     !Ywq     swampwater}
{TERRAIN_ADJACENT          -202        cZp\|/ !cZp\|/ coast}
{TERRAIN_ADJACENT          -203        s      !s      ocean}
{TERRAIN_ADJACENT          -204        k      !k      ford}
{TERRAIN_ADJACENT          -205        Q      N       sunken-ruin}
{TERRAIN_ADJACENT          -206        Q      !QN     coast}
{TERRAIN_ADJACENT          -207        !N     N       grassland}

{TERRAIN_BASE_DEFAULT void}
