

class CratersMod extends WorldModifier
{
  name="craters"
  chance=0.3

  function beforeErosion()
  {
    for (local n=irnd()%50+30; n>0; --n)
      gen_crater(hmrnd(), hmrnd(), rndf(5, 20), rndf(0.3, 0.9))
  }
}


class BigCraterMod extends WorldModifier
{
  name="big_crater"
  chance=0.1

  function beforeErosion()
  {
    gen_crater(hmrnd(), hmrnd(), rndf(50, 100), rndf(0.2, 0.5))
  }
}


class VolcanoMod extends WorldModifier
{
  name="volcano"
  chance=0.1

  cx=0
  cz=0
  rad=0

  function beforeErosion()
  {
    for (local iter=100; iter>0; --iter)
    {
      cx=hmfrnd()
      cz=hmfrnd()
      rad=rndf(5, 9)
      if (!test_circle_mark(cx, cz, rad*5, MARK_PLACEMENT, 0)) continue;
      mark_circle(cx, cz, rad*5, MARK_PLACE, 0);
      break;
    }
  }

  function beforeObjects()
  {
    NaturalVolcano(vec4f(cx, 0, cz, 1), rad,
      vec4f(rad*0.5, 30,  0, 0),
      vec4f(rad    , 90, 60, 0))
  }
}


function make_gorge(d, h, a)
{
  a*=2*PI
  local x=hmrnd()
  local y=hmrnd()
  local dx=cos(a)
  local dy=sin(a)
  local amp=d*0.7
  local b=0.5
  gen_fault(x, y, dx, dy, h, b, amp, null, GT_ROCK, 255)
  gen_fault(x-dx*d, y-dy*d, -dx, -dy, h, b, amp, null, GT_ROCK, 255)
}


class GorgesMod extends WorldModifier
{
  name="gorges"
  chance=0.2

  function beforeErosion()
  {
    local a=frnd()
    for (local n=irnd()%5+3; n>0; --n)
      make_gorge(20, 10, a+frnd()*0.1)
  }
}


class HousesMod extends WorldModifier
{
  name="houses"
  chance=0.2*99

  function beforeObjects()
  {
    for (local n=40; n; --n)
      place_house(hmrnd(), hmrnd(), irnd())
  }
}


// class PlacesMod extends WorldModifier
// {
//   name="places"
//   chance=2

//   function beforeErosion() { foreach (p in places) p.beforeErosion() }
//   function  afterErosion() { foreach (p in places) p. afterErosion() }
//   function beforeObjects() { foreach (p in places) p.beforeObjects() }
// }
