# 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
#
# when adding new probabilities update the commented line
# the proper way to calculate the propabilities is described here
# http://www.wesnoth.org/wiki/Terrain_Graphics_Probability

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

#-----------------------------------------------------------------
# Forest<->Castle|Encampment special cases, also used by some other
# terrain
# Macro's moved to terrain-graphics/forestcastle.cfg
#-----------------------------------------------------------------

{FORESTADJCASTLEA f CnqQoKN 100 forest-castle}
{FORESTADJCASTLEA F CnqQoKN 100 snow-forest-castle}
{FORESTADJCASTLEA ] CnolqQoKN 100 mushrooms-castle}
{FORESTADJCASTLEA T CnolqQoKN 100 tropical-forest-castle}
{MOUNTAINADJCASTLEA m CnqQoKXlN 100 mountains-castle}

{FORESTADJCASTLES f CnqQoKN 100 forest-castle}
{FORESTADJCASTLES F CnqQoKN 100 snow-forest-castle}
{FORESTADJCASTLES T CnqQoKN 100 tropical-forest-castle}
{FORESTADJCASTLES ] CnolWqQoKN 100 mushrooms-castle}

{FORESTADJCASTLEO f CnqQoKN 100 forest-castle}
{FORESTADJCASTLEO F CnqQoKN 100 snow-forest-castle}
{FORESTADJCASTLEO T CnqQoKN 100 tropical-forest-castle}
{FORESTADJCASTLEO ] CnolWqQoKN 100 mushrooms-castle}

{FORESTADJCASTLE f CnqQoKN 100 forest-castle}
{FORESTADJCASTLE F CnqQoKN 100 snow-forest-castle}
{FORESTADJCASTLE T CnqQoKN 100 tropical-forest-castle}
{FORESTADJCASTLE ] CnolWqQoKN 100 mushrooms-castle}
{FORESTADJCASTLE m CnqQoKXlN 100 mountains-castle}

#33% 17% 5% 45%
{FORESTADJ f csmJMwvabtXWl 33 forest_small}
{FORESTADJ f csmJMwvabtXWl 25 forest3}
{FORESTADJ f csmJMwvabtXWl 10 forest4}
{FORESTADJ f csmJMwvabtXWl 100 forest2_small}

{FORESTADJ F csmJMwvabtXWl 100 snow-forest_small}

{FORESTADJ ] csmJMwvabtXWl 100 mushrooms-castle}

#define SWAMPADJSINGLE FID ID NID PROB TILE
[terrain_graphics]
      map="
  1
3   3
  2
3   3
  3"

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

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

         [tile]
                 pos=3
                 type={NID}
         [/tile]

         probability={PROB}
         rotations=n,ne,se,s,sw,nw

         [image]
                 name={TILE}-@R0
                 position=vertical
                 base=90,144
         [/image]


[/terrain_graphics]
#enddef

{SWAMPADJSINGLE Yw CnQoKNhaHAmb& !CnQoKNhaHAmb& 100 reed-castle}
{SWAMPADJSINGLE q !q q 100 reed-castle}

{FORESTADJ Yw CnQoKNhaHAmb& 8 reed1-small}
{FORESTADJ Yw CnQoKNhaHAmb& 13 reed2-small}
{FORESTADJ Yw CnQoKNhaHAmb& 21 reed3-small}
{FORESTADJ Yw CnQoKNhaHAmb& 100 reed4-small}
{FORESTADJ q !q 8 reed1-small}
{FORESTADJ q !q 13 reed2-small}
{FORESTADJ q !q 21 reed3-small}
{FORESTADJ q !q 100 reed4-small}



# Mountains
# macros found in terrain-graphics/mountains.cfg

#TWOBYFOUR TYPE NAME1 NAME2 NAME3 NAME4 NAME5 FLAG PROB
{TWOBYFOUR mb& mountain_range3_1 mountain_range3_2 mountain_range3_3 mountain_range3_4 mountain_range3_5 overlay 18}

#TWOBYFOUR2 TYPE NAME1 NAME2 NAME3 NAME4 NAME5 FLAG PROB
{TWOBYFOUR2 mb& mountain_range4_1 mountain_range4_2 mountain_range4_3 mountain_range4_4 mountain_range4_5 overlay 26}

#ONEBYTHREE TYPE NAME1 NAME2 NAME3 FLAG PROB
{ONEBYTHREE mb& mountain_range1_1 mountain_range1_2 mountain_range1_3 overlay 20}

#ONEBYTHREE2 TYPE NAME1 NAME2 NAME3 FLAG PROB
{ONEBYTHREE2 mb& mountain_range2_1 mountain_range2_2 mountain_range2_3 overlay 20}

# TWOBYTWO TYPE NAME1 NAME2 NAME3 FLAG PROB
{TWOBYTWO mb& mountain5_1 mountain5_2 mountain5_3 overlay 40}
{TWOBYTWO mb& mountain6_1 mountain6_2 mountain6_3 overlay 30}

#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 mountain tiles (mountain + village)
#33% 33% 33%
{SHEX mb& overlay 33 mountains3}
{SHEX mb& overlay 50 mountains2}
{SHEX mb& overlay 100 mountains}

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

#Single hex tropical forest tiles
#33% 17% 5% 45%
{SHEX T overlay 33 tropical-forest2}
{SHEX T overlay 25 tropical-forest3}
{SHEX T overlay 10 tropical-forest4}
{SHEX T overlay 100 tropical-forest}

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

#Single hex Great-tree
#33% 17% 50%
{SHEX ? overlay 33 great-tree3}
{SHEX ? overlay 25 great-tree2}
{SHEX ? overlay 100 great-tree1}

#Single hex underground mushroom forest tiles
#20% 20% 20% 20% 20%
{SHEX ] overlay 20 mushrooms2}
{SHEX ] overlay 25 mushrooms3}
{SHEX ] overlay 33 mushrooms4}
{SHEX ] overlay 50 mushrooms5}
{SHEX ] overlay 100 mushrooms}

#Single hex Cave lit by Beam of Light
#33% 33% 33%
{SHEX ' overlay 33 cave-beam3}
{SHEX ' overlay 50 cave-beam2}
{SHEX ' overlay 100 cave-beam1}


{SHEX Ywq overlay 10 reed3}
{SHEX Ywq overlay 20 reed1}
{SHEX Ywq overlay 25 reed2}
{SHEX Ywq overlay 33 reed4}
{SHEX Ywq overlay 50 reed5}
{SHEX Ywq overlay 100 reed6}

#Macro for clouds
#define CLOUDS TYPE NAME1 NAME2 NAME3 FLAG PROB
[terrain_graphics]
      map="
.   .
  *
*   *
  2
*   *
  *"

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

         [image]
                 name={NAME1}
                 position=vertical
                 base=32,208
         [/image]

         [image]
                 name={NAME2}
                 position=vertical
                 base=88,372
         [/image]

         [image]
                 name={NAME3}
                 position=vertical
                 base=142,308
         [/image]

         probability={PROB}
[/terrain_graphics]
#enddef

#33% 33% 33%
{CLOUDS & cloud1_1 cloud1_2 cloud1_3 clouds 33}
{CLOUDS & cloud1_1 cloud2_2 cloud1_3 clouds 50}
{CLOUDS & cloud1_1 cloud3_2 cloud1_3 clouds 100}

#
#       >  V I L L A G E   B U I L D I N G S   <

# Flagged as 'village' so they can be placed on
# top of both 'base' and 'overlay'

#Single hex human villages (grassland, hills, mountains)
#30% 30% 40%
{SHEX v village 30 village-human}
{SHEX v village 43 village-human2}
{SHEX v village 100 village-human3}

{SHEX ab village 100 village-human4}

#Single hex human villages (snow)
#33% 33% 33%
{SHEX V village 33 village-human-snow}
{SHEX V village 50 village-human-snow2}
{SHEX V village 100 village-human-snow3}

{SHEX A village 100 village-human-snow4}

#Single hex elven villages
#10% 25% 25% 40%
{SHEX t village 10 village-elven}
{SHEX t village 28 village-elven3}
{SHEX t village 38 village-elven4}
{SHEX t village 100 village-elven2}

#Single hex elven villages (snow)
#10% 25% 25% 40%
{SHEX e village 10 village-elven-snow}
{SHEX e village 28 village-elven-snow3}
{SHEX e village 38 village-elven-snow4}
{SHEX e village 100 village-elven-snow2}

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

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

{SHEX p village 100 village-dwarven}

#Single hex swamp village
#50% 50%
{SHEX Y village 50 village-swampwater}
{SHEX Y village 100 village-swampwater2}

#Single hex coastal village
{SHEX Z village 100 village-coast}

#Single hex tropical village
{SHEX L village 100 village-tropical-forest}

#
#       >  V I L L A G E   B A S E   T E R R A I N  <
#

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

#
#       >  B A S E   T E R R A I N S  <
#

#10% 3% 13% 7% 67%
{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}

#33% 33% 33%
{TERRAIN_BASE_PROB            [ cave-hills-variation1    33}
{TERRAIN_BASE_PROB            [ cave-hills-variation2    50}
{TERRAIN_BASE                 [ cave-hills-variation3}

#33% 33% 33%
{TERRAIN_BASE_PROB            h hills-variation1    33}
{TERRAIN_BASE_PROB            h hills-variation2    50}
{TERRAIN_BASE                 h hills-variation3}

#30% 30% 40%
{TERRAIN_BASE_PROB            H snow-hills3         30}
{TERRAIN_BASE_PROB            H snow-hills2         43}
{TERRAIN_BASE                 H snow-hills}

#30% 30% 40%
{TERRAIN_BASE_PROB            SF snow2 	30}
{TERRAIN_BASE_PROB            SF snow3 	43}
{TERRAIN_BASE                 SF snow}


{TERRAIN_BASE                 X chasm}

{TERRAIN_BASE_PROB            l lava  33}
{TERRAIN_BASE_PROB            l lava2 50}
{TERRAIN_BASE                 l lava3}


#g 2% 2% 3% 3% 9% 9% 9% 9% 9% 9% 9% 27%
{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}
#f? 10% 10% 10% 10% 10% 10% 10% 30%
{TERRAIN_BASE_PROB            gf? grassland-r1 10}
{TERRAIN_BASE_PROB            gf? grassland-r2 11}
{TERRAIN_BASE_PROB            gf? grassland-r3 13}
{TERRAIN_BASE_PROB            gf? grassland-r4 14}
{TERRAIN_BASE_PROB            gf? grassland-r5 17}
{TERRAIN_BASE_PROB            gf? grassland-r6 20}
{TERRAIN_BASE_PROB            gf? grassland-r7 25}
{TERRAIN_BASE                 gf? grassland-r8}

{TERRAIN_BASE_PROB            GT  savanna	33}
{TERRAIN_BASE_PROB            GT  savanna2	50}
{TERRAIN_BASE                 GT  savanna3}

{TERRAIN_BASE                 r dirt}

#33% 33% 33%
{TERRAIN_BASE_PROB            R road3 33}
{TERRAIN_BASE_PROB            R road2 50}
{TERRAIN_BASE                 R road}

{TERRAIN_BASE                 E  desert-road}

#2% 2% 2% 24% 24% 3% 3% 3% 3% 36%
{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        34}
{TERRAIN_BASE_PROB            I desert4        6}
{TERRAIN_BASE_PROB            I desert5        6}
{TERRAIN_BASE_PROB            I desert6        7}
{TERRAIN_BASE_PROB            I desert7        7}
{TERRAIN_BASE                 I desert}

#33% 33% 33%
{TERRAIN_BASE_PROB            J desert-hills2  33}
{TERRAIN_BASE_PROB            J desert-hills3  50}
{TERRAIN_BASE                 J desert-hills}

#25% 25% 25% 25%
{TERRAIN_BASE_PROB            M desert-mountain-peak1     25}
{TERRAIN_BASE_PROB            M desert-mountain-peak2     33}
{TERRAIN_BASE_PROB            M desert-mountain-peak3     50}
{TERRAIN_BASE                 M desert-mountains}

{TERRAIN_BASE                 P desert-oasis}

#10% 10% 10% 70%
{TERRAIN_BASE_PROB            d sand-rock1        10}
{TERRAIN_BASE_PROB            d sand-rock2        11}
{TERRAIN_BASE_PROB            d sand-rock3        13}
{TERRAIN_BASE                 d sand}


#8% 8% 8% 8% 23% 23% 23%
{TERRAIN_BASE_PROB            w swampwater-flowers1  8}
{TERRAIN_BASE_PROB            w swampwater-flowers2  9}
{TERRAIN_BASE_PROB            w swampwater-plant1   10}
{TERRAIN_BASE_PROB            w swampwater-plant2   11}
{TERRAIN_BASE_PROB            w swampwater2         33}
{TERRAIN_BASE_PROB            w swampwater3         50}
{TERRAIN_BASE                 w swampwater}

#10% 10% 10% 10% 25% 35%
{TERRAIN_BASE_PROB            i ice2 10}
{TERRAIN_BASE_PROB            i ice3 11}
{TERRAIN_BASE_PROB            i ice5 13}
{TERRAIN_BASE_PROB            i ice6 14}
{TERRAIN_BASE_PROB            i ice4 42}
{TERRAIN_BASE                 i ice}

#set them to 33 for some irregulrity
#33% 67%
{TERRAIN_BASE_PROB            k ford2 33}
{TERRAIN_BASE                 k ford}

#30% 30% 40%
{TERRAIN_BASE_PROB            c\|/ coast3        30}
{TERRAIN_BASE_PROB            c\|/ coast2        43}
{TERRAIN_BASE                 c\|/ coast}

#30% 30% 40%
{TERRAIN_BASE_PROB            s ocean3         30}
{TERRAIN_BASE_PROB            s ocean2         43}
{TERRAIN_BASE                 s ocean}

{TERRAIN_BASE                 ~ fog}


#This one is to fill the "gaps" at the map edges. There are no
#non-multihex mountains so hills fit better
{TERRAIN_BASE                 mb& hills-variation1}


#added ruins
{BRIDGE \ | / csX CKfFNQq bridge}

#
#     >  T R A N S I T I O N S   B E T W E E N   T E R R A I N S  <
#

# 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}

#
#     >  C A S T L E S   B A S E   T E R R A I N S  <
#

{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}

#30% 30% 40%
{TERRAIN_BASE_PROB            q swampwater2         30}
{TERRAIN_BASE_PROB            q swampwater3         43}
{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_IF_NOT_NORTH_OF_WATER K keep-of-Q castle}
{TERRAIN_BASE_FLAG K keep-of-Q sunken-keep-coast}
{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
# Not disabled for now because it messes with the new cliff
{DISABLE_TRANSITIONS N} #we want transitions...makes ruins look overgrown...

#17% 17% 17% 17% 17% 17%
{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}

#17% 17% 17% 17% 17% 17%
{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}

#75% 25%
{TERRAIN_ADJACENT_CORNER_PROB  K      N     NQqC      54,72 ruinkeep1-inside 75}
{TERRAIN_ADJACENT_CORNER_PROB  K      N     NQqC      54,72 keep-inside 100}

#75% 25%
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K     !NQqCK   !NQqCK     54,72 keep-of-N ruinkeep1-wall 75}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K     !NQqCK   !NQqCK     52,76 keep-of-N keep-wall 100}

#75% 25%
{TERRAIN_ADJACENT_CORNER_PROB  K      !NQqCK   N       54,72 ruinkeep1-wall-0 75}
{TERRAIN_ADJACENT_CORNER_PROB  K      !NQqCK   N       52,72 keep-wall-0 100}


#75% 25%
{TERRAIN_ADJACENT_CORNER_PROB  K      N      !NQqCK    54,72 ruinkeep1-wall-1 75}
{TERRAIN_ADJACENT_CORNER_PROB  K      N      !NQqCK    56,76 keep-wall-1 100}


#75% 25%
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K      K      !K      54,72 keep-of-N ruinkeep1-keep 75}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K      K      !K      56,76 keep-of-N keep-keep 100}


# sunken ruined castle
#{DISABLE_TRANSITIONS Q}

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

#17% 17% 17% 17% 17% 17%
{TERRAIN_ADJACENT_CORNER_PROB  wcs   Q      qQNC      56,68 sunken-ruin5-concave 17}
{TERRAIN_ADJACENT_CORNER_PROB  wcs   Q      qQNC      56,68 sunken-ruin4-concave 20}
{TERRAIN_ADJACENT_CORNER_PROB  wcs   Q      qQNC      56,68 sunken-ruin3-concave 25}
{TERRAIN_ADJACENT_CORNER_PROB  wcs   Q      qQNC      56,68 sunken-ruin2-concave 33}
{TERRAIN_ADJACENT_CORNER_PROB  wcs   Q      qQNC      56,68 sunken-ruin1-concave 50}
{TERRAIN_ADJACENT_CORNER_PROB  wcs   Q      qQNC      56,68 sunken-ruin-concave 100}

#17% 17% 17% 17% 17% 17%
{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}

#17% 17% 17% 17% 17% 17%
{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}

#75% 25%
{TERRAIN_ADJACENT_CORNER_PROB  K      Q     NQqC      54,72 sunken-ruinkeep1-inside 75}
{TERRAIN_ADJACENT_CORNER_PROB  K      Q     NQqC      54,72 sunkenkeep-inside 100}

#75% 25%
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K     !NQqCK   !NQqCK     52,76 keep-of-Q sunken-ruinkeep1-wall 75}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K     !NQqCK   !NQqCK     52,76 keep-of-Q sunkenkeep-wall 100}

#75% 25%
{TERRAIN_ADJACENT_CORNER_PROB  K      !NQqCK   Q       52,72 sunken-ruinkeep1-wall-0 75}
{TERRAIN_ADJACENT_CORNER_PROB  K      !NQqCK   Q       52,72 sunkenkeep-wall-0 100}

#75% 25%
{TERRAIN_ADJACENT_CORNER_PROB  K      Q      !NQqCK    56,76 sunken-ruinkeep1-wall-1 75}
{TERRAIN_ADJACENT_CORNER_PROB  K      Q      !NQqCK    56,76 sunkenkeep-wall-1 100}

#75% 25%
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K      K      !K      56,76 keep-of-Q sunken-ruinkeep1-keep 75}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K      K      !K      56,76 keep-of-Q sunkenkeep-keep 100}

# swamp ruined castle
#{DISABLE_TRANSITIONS q}

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

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

#17% 17% 17% 17% 17% 17%
{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}

#17% 17% 17% 17% 17% 17%
{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}

#75% 25%
{TERRAIN_ADJACENT_CORNER_PROB  K      q     NQqC      54,72 ruinkeep1-inside 75}
{TERRAIN_ADJACENT_CORNER_PROB  K      q     NQqC      54,72 keep-inside 100}

#75% 25%
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K     !NQqCK   !NQqCK     52,76 keep-of-q ruinkeep1-wall 75}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K     !NQqCK   !NQqCK     52,76 keep-of-q keep-wall 100}

#75% 25%
{TERRAIN_ADJACENT_CORNER_PROB  K      !NQqCK   q       52,72 ruinkeep1-wall-0 75}
{TERRAIN_ADJACENT_CORNER_PROB  K      !NQqCK   q       52,72 keep-wall-0 100}

#75% 25%
{TERRAIN_ADJACENT_CORNER_PROB  K      q      !NQqCK    56,76 ruinkeep1-wall-1 75}
{TERRAIN_ADJACENT_CORNER_PROB  K      q      !NQqCK    56,76 keep-wall-1 100}

#75% 25%
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K      K      !K      56,76 keep-of-q ruinkeep1-keep 75}
{TERRAIN_ADJACENT_CORNER_FLAG1_PROB  K      K      !K      56,76 keep-of-q keep-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 X}
{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      !WoKXl   !WoKXl    52,76 dwarven-castle-convex}
{TERRAIN_ADJACENT_CORNER       !WoKXl   o      o       56,68 dwarven-castle-concave}
{TERRAIN_ADJACENT_CORNER_FLAG1 K      !WoKXl   !WoKXl    52,76 keep-of-o dwarven-castle-convex}
{TERRAIN_ADJACENT_CORNER       !WoKXl   K      o       56,68 dwarven-castle-concave}
{TERRAIN_ADJACENT_CORNER       !WoKXl   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      !WoKl   54,68 dwarven-castle-wall-cw}
{TERRAIN_ADJACENT_CORNER       oK     !WoKl  W       54,68 dwarven-castle-wall-ccw}

#castle-chasm transitions
{TERRAIN_ADJACENT_CORNER       o      X      X       52,76 chasm-dcastle-convex}
{TERRAIN_ADJACENT_CORNER       X      o      o       56,68 chasm-dcastle-concave}
{TERRAIN_ADJACENT_CORNER_FLAG1 K      X      X       52,76 keep-of-o chasm-dcastle-convex}
{TERRAIN_ADJACENT_CORNER       X      K      o       56,68 chasm-dcastle-concave}
{TERRAIN_ADJACENT_CORNER       X      o      K       56,68 chasm-dcastle-concave}

{TERRAIN_ADJACENT_CORNER        o       !XKolW  X       52,76 chasm-dcastle-ccw}
{TERRAIN_ADJACENT_CORNER_FLAG1  K       !XKolW  X       52,76 keep-of-o chasm-dcastle-ccw}
{TERRAIN_ADJACENT_CORNER        o       X       !XKolW  52,76 chasm-dcastle-cw}
{TERRAIN_ADJACENT_CORNER_FLAG1  K       X       !XKolW  52,76 keep-of-o chasm-dcastle-cw}

#castle-lava transitions

{TERRAIN_ADJACENT_CORNER       o      l      l       52,76 lava-dcastle-convex}
{TERRAIN_ADJACENT_CORNER       l      o      o       56,68 lava-dcastle-concave}
{TERRAIN_ADJACENT_CORNER_FLAG1 K      l      l       52,76 keep-of-o lava-dcastle-convex}
{TERRAIN_ADJACENT_CORNER       l      K      o       56,68 lava-dcastle-concave}
{TERRAIN_ADJACENT_CORNER       l      o      K       56,68 lava-dcastle-concave}

{TERRAIN_ADJACENT_CORNER        o       !lKoXW  l       52,76 lava-dcastle-ccw}
{TERRAIN_ADJACENT_CORNER_FLAG1  K       !lKoXW  l       52,76 keep-of-o lava-dcastle-ccw}
{TERRAIN_ADJACENT_CORNER        o       l       !lKoXW  52,76 lava-dcastle-cw}
{TERRAIN_ADJACENT_CORNER_FLAG1  K       l       !lKoXW  52,76 keep-of-o lava-dcastle-cw}

#castle-lava-wall transitions

{TERRAIN_ADJACENT_CORNER_NORTH  oK      W      l        52,76 dwarven-castle-wall-cw}
{TERRAIN_ADJACENT_CORNER_NORTH  oK      l      W        52,76 dwarven-castle-wall-ccw}
{TERRAIN_ADJACENT_CORNER_SW     oK      W      l        52,76 lava-dcastle-ccw}
{TERRAIN_ADJACENT_CORNER_SE     oK      l      W        52,76 lava-dcastle-cw}
{TERRAIN_ADJACENT_CORNER_SE     oK      W      l        52,76 dwarven-castle-wall-cw}
{TERRAIN_ADJACENT_CORNER_SW     oK      l      W        52,76 dwarven-castle-wall-ccw}
{TERRAIN_ADJACENT_CORNER_W      oK      W      l        52,76 lava-dcastle-ccw}
{TERRAIN_ADJACENT_CORNER_E      oK      l      W        52,76 lava-dcastle-cw}
{TERRAIN_ADJACENT_CORNER_E      oK      W      l        52,76 dwarven-castle-wall-cw}
{TERRAIN_ADJACENT_CORNER_W      oK      l      W        52,76 dwarven-castle-wall-ccw}

#castle-lava-chasm transitions

{TERRAIN_ADJACENT_CORNER       o      X      l       52,76 lava-dcastle-chasm-ccw}
{TERRAIN_ADJACENT_CORNER_FLAG1 K      X      l       52,76 keep-of-o lava-dcastle-chasm-ccw}
{TERRAIN_ADJACENT_CORNER       o      l      X       52,76 lava-dcastle-chasm-cw}
{TERRAIN_ADJACENT_CORNER_FLAG1 K      l      X       52,76 keep-of-o lava-dcastle-chasm-cw}


# 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>}

# Lava
{DISABLE_TRANSITIONS l}
{TERRAIN_ADJACENT_CORNER        l       !lXKoW  !lXKoW  52,76 lava-convex}
{TERRAIN_ADJACENT_CORNER        !lXKoW  l       l       56,68 lava-concave}

{TERRAIN_ADJACENT_CORNER        X       l       l       52,76 lava-chasm-convex}
{TERRAIN_ADJACENT_CORNER        l       X       X       56,68 lava-chasm-concave}

{TERRAIN_ADJACENT_CORNER        X       !lXKo   l       52,76 chasm-convex}
{TERRAIN_ADJACENT_CORNER        X       l       !lXKo   52,76 chasm-convex}
{TERRAIN_ADJACENT_CORNER        l       X       !lXKo   52,76 lava-chasm-ccw}
{TERRAIN_ADJACENT_CORNER        l       !lXKo   X       52,76 lava-chasm-cw}

# Chasm
{TERRAIN_ADJACENT_CORNER        X       !XKolW  !XKolW  52,76 chasm-convex}
{TERRAIN_ADJACENT_CORNER        !XKolW  X       X       56,68 chasm-concave}


# Hack to get chasm/wall transitions right
{TERRAIN_ADJACENT_CORNER_NORTH  X       W       !X      76,52 chasm-convex}
{TERRAIN_ADJACENT_CORNER_NORTH  X       !X      W       76,52 chasm-convex}
{TERRAIN_ADJACENT_CORNER_E      X       W       !X      0,0 chasm-convex}
{TERRAIN_ADJACENT_CORNER_E      X       !X      W       0,0 chasm-convex}
{TERRAIN_ADJACENT_CORNER_W      X       W       !X      100,100 chasm-convex}
{TERRAIN_ADJACENT_CORNER_W      X       !X      W       100,100 chasm-convex}

{TERRAIN_ADJACENT_CORNER_NS     W       X       X       56,68 chasm-concave}
{TERRAIN_ADJACENT_CORNER_E      W       X       X       0,0 chasm-concave}
{TERRAIN_ADJACENT_CORNER_W      W       X       X       100,100 chasm-concave}


# Hack to get lava/wall transitions right
{TERRAIN_ADJACENT_CORNER_NORTH  l       W       !lX     76,52 lava-convex}
{TERRAIN_ADJACENT_CORNER_NORTH  l       !lX     W       76,52 lava-convex}
{TERRAIN_ADJACENT_CORNER_E      l       W       !lX     0,0 lava-convex}
{TERRAIN_ADJACENT_CORNER_E      l       !lX     W       0,0 lava-convex}
{TERRAIN_ADJACENT_CORNER_W      l       W       !lX     100,100 lava-convex}
{TERRAIN_ADJACENT_CORNER_W      l       !lX     W       100,100 lava-convex}

{TERRAIN_ADJACENT_CORNER_NS     W       l       l       56,68 lava-concave}
{TERRAIN_ADJACENT_CORNER_E      W       l       l       0,0 lava-concave}
{TERRAIN_ADJACENT_CORNER_W      W       l       l       100,100 lava-concave}

#ifdef CAMPAIGN_DESERT
#This is a hack to get the letter y have the new lava
#when used in the local terrain-graphics it gave serveral
#glitches and this seems to work --Mordante
{DISABLE_TRANSITIONS y}
{TERRAIN_ADJACENT_CORNER        y       !yXKoW  !yXKoW  52,76 lava-convex}
{TERRAIN_ADJACENT_CORNER        !yXKoW  y       y       56,68 lava-concave}

{TERRAIN_ADJACENT_CORNER        X       y       y       52,76 lava-chasm-convex}
{TERRAIN_ADJACENT_CORNER        y       X       X       56,68 lava-chasm-concave}

{TERRAIN_ADJACENT_CORNER        X       !yXKo   y       52,76 chasm-convex}
{TERRAIN_ADJACENT_CORNER        X       y       !yXKo   52,76 chasm-convex}
{TERRAIN_ADJACENT_CORNER        y       X       !yXKo   52,76 lava-chasm-ccw}
{TERRAIN_ADJACENT_CORNER        y       !yXKo   X       52,76 lava-chasm-cw}

# Hack to get lava/wall transitions right
{TERRAIN_ADJACENT_CORNER_NORTH  y       W       !yX     76,52 lava-convex}
{TERRAIN_ADJACENT_CORNER_NORTH  y       !yX     W       76,52 lava-convex}
{TERRAIN_ADJACENT_CORNER_E      y       W       !yX     0,0 lava-convex}
{TERRAIN_ADJACENT_CORNER_E      y       !yX     W       0,0 lava-convex}
{TERRAIN_ADJACENT_CORNER_W      y       W       !yX     100,100 lava-convex}
{TERRAIN_ADJACENT_CORNER_W      y       !yX     W       100,100 lava-convex}

{TERRAIN_ADJACENT_CORNER_NS     W       y       y       56,68 lava-concave}
{TERRAIN_ADJACENT_CORNER_E      W       y       y       0,0 lava-concave}
{TERRAIN_ADJACENT_CORNER_W      W       y       y       100,100 lava-concave}
#endif


# 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_PROB K ({VIMG 20,26 tent}) keep-of-n 50}
{BUILDING_FLAG_PROB K ({VIMG 20,26 tent2}) keep-of-n 100}
{BUILDING_FLAG K ({VIMG 36,40 dwarven-keep}) keep-of-o}

#
#       > N O R M A L   T R A N S I T I O N S. < 

#The order mostly controls which overlap which, some
# TERRAIN_ADJACENT_CUSTOMs and varying layer numbers are used to make some
# special transitions to layer in more complex ways.

{TERRAIN_ADJACENT          -140    mHhfF?           N                   grassland}

{TERRAIN_ADJACENT_CUSTOM   -150    mb&              HSJpkscZ\|/wY       mountains transition2}
{TERRAIN_ADJACENT_CUSTOM   -151    mb&              !mbXhCKNnoQW        mountains transition2}
{TERRAIN_ADJACENT          -160    M                !MX                 desert-mountains}


{TERRAIN_ADJACENT          -170    HA               kscZ\|/wY           snow-hills-to-water}
{TERRAIN_ADJACENT          -171    HA               h                   snow-hills-to-hills}
{TERRAIN_ADJACENT          -172    HA               !HAXha              snow-hills}
{TERRAIN_ADJACENT          -180    J                !JX                 desert-hills}
{TERRAIN_ADJACENT          -190    ha               !hakscZ\|/wY        hills}
{TERRAIN_ADJACENT_CUSTOM   -191    ha               kscZ\|/wY           hills transition2}
{TERRAIN_ADJACENT          -200    [                ![                  cave-hills}

{TERRAIN_ADJACENT          -210    uDp]'            !uDXp]'             cave-floor}
{TERRAIN_ADJACENT          -220    l                !lWX                lava}
#ifdef CAMPAIGN_DESERT
{TERRAIN_ADJACENT          -220    y                !yWX                lava}
#endif
{TERRAIN_ADJACENT          -230    FSVe             kscZ\|/wY           snow-to-water}
{TERRAIN_ADJACENT          -240    FSVe             !SVFeX              snow}
{TERRAIN_ADJACENT          -260    TGL              kscZ\|/             savanna-to-water}

{TERRAIN_ADJACENT          -250    Ywq              !YwqhaHAmb&                swampwater}


# These two work in conjunction with the mountain and hill transitions to create
# a smooth coastline between grassland, hills and mountains.

{TERRAIN_ADJACENT          -270    ftgvX?         !ftgvX?mb&hakscZ\|/wY grassland}
{TERRAIN_ADJACENT          -319    ftgvX?mb&ha      kscZ\|/           grassland-to-water}

{TERRAIN_ADJACENT          -280    GTL              !GTLX               savanna}
{TERRAIN_ADJACENT          -290    R                !R                  road}
{TERRAIN_ADJACENT          -259    r                !r                  dirt}
{TERRAIN_ADJACENT          -310    E                !E                  desert-road}
{TERRAIN_ADJACENT          -320    PIB              !PIB                desert-oasis}
{TERRAIN_ADJACENT          -330    IBPU             !IBPU               desert}
{TERRAIN_ADJACENT          -340    d                !d                  sand}


# Water Transitions draw below everything else

{SET_ADJACENT_FLAG         Qq      K                kscZ\|/Y           transition2}
{TERRAIN_ADJACENT_CUSTOM   -500    CKnNo            kscZ\|/i            castle-to-ice transition3}
{TERRAIN_ADJACENT_CUSTOM   -505    CKnNo            kscZ\|/             castle-to-water transition2}
{TERRAIN_ADJACENT_CUSTOM   -510    i                kscZ\|/wY           ice-to-water submerged_part}
{TERRAIN_ADJACENT          -503    i                !iX                 ice}

{TERRAIN_ADJACENT          -520    cZ\|/            !cZ\|/m             coast}
{TERRAIN_ADJACENT          -530    k                !k                  ford}
{TERRAIN_ADJACENT          -540    s                !s                  ocean}
{TERRAIN_ADJACENT_CUSTOM   -550    Q                NC                  sunken-ruin transition2}
{TERRAIN_ADJACENT          -560    Q                !QN                 coast}
{TERRAIN_ADJACENT          -570    !N               N                   grassland}

{TERRAIN_BASE_DEFAULT void}
