Main
Projects
Art
Music
Scripting
LiveJournal
Forum
Links
World Generator
by Moogle1

This script generates a "world" and is optimized for a 100x100 map set to wrap around. To change the number of continents, add or delete continent calls in the generate function.


# World Generator - Generates a random world.
#You will need to change the "generate" function to suit your map.

include,plotscr.hsd

define script (1,generate,0)
define script (-1,gen-up,3,0,0,0) #called by "continent"
define script (-1,gen-down,3,0,0,0) #called by "continent"
define script (-1,continent,2,0,0) #makes a continent at (x,y)

define constant,begin
 0,tile:sea
 1,tile:land
end

script,generate,begin
 continent(random(10,40),random(10,40))
 continent(random(60,90),random(10,40))
 continent(random(60,90),random(80,90))
 continent(random(10,40),random(80,90))
end

script,continent,x,y,begin
 showvalue(y)
 variable(ctr)
 variable(w-up)
 variable(w-down)
 variable(rand)
 w-up:=random(1,3)
 w-down:=random(1,3)
 for (ctr,x--random(10,30),x+random(10,30)) do
 (
   gen-up(ctr,y,y--w-up)
   gen-down(ctr,y,y+w-down)
   rand:=random(0,4)
   if (rand<<2) then (if (ctr<=x) then (increment(w-up)) else (decrement(w-up)))
   if (rand==3) then (increment(w-up))
   if (rand==4) then (decrement(w-up))
   rand:=random(0,4)
   if (rand<<2) then (if (ctr<=x) then (increment(w-down)) else (decrement(w-down)))
   if (rand==3) then (increment(w-down))
   if (rand==4) then (decrement(w-down))
   rand:=random(0,4)
   if (rand==3) then (increment(w-up))
   if (rand==4) then (decrement(w-up))
   rand:=random(0,4)
   if (rand==3) then (increment(w-down))
   if (rand==4) then (decrement(w-down))
 )
 while (w-up>=3,or,w-down>=3) do
 (
   gen-up(ctr,y,y--w-up)
   gen-down(ctr,y,y+w-up)
   if (random(0,2)>>0) then (decrement(w-up))
   if (random(0,2)>>0) then (decrement(w-down))
   if (random(0,2)>>0) then (decrement(w-up))
   if (random(0,2)>>0) then (decrement(w-down))
   if (w-up<<2,and,random(0,1)) then (w-up:=2)
   if (w-down<<2,and,random(0,1)) then (w-down:=2)
   increment(ctr)
 )
end

script,gen-up,x,y,y-to,begin
 variable(ctr)
 for (ctr,y-to,y) do
 (
   writemapblock(x,ctr,tile:land)
 )
 if (random(0,10)==0) then (gen-up(x--1,random((y+y-to)/2,y-to),y-to--random(1,3)))
 if (random(0,10)==0) then (gen-up(x+1,random((y+y-to)/2,y-to),y-to--random(1,3)))
end

script,gen-down,x,y,y-to,begin
 variable(ctr)
 for (ctr,y,y-to) do
 (
   writemapblock(x,ctr,tile:land)
 )
 if (random(0,10)==0) then (gen-down(x--1,random((y+y-to)/2,y-to),y-to+random(1,3)))
 if (random(0,10)==0) then (gen-down(x+1,random((y+y-to)/2,y-to),y-to+random(1,3)))
end

Site layout (c)2000 Jennifer Raby. Used by permission.