26 Feb 11, 06:47PM
Congratulations on finding yourself a man! :D
The random terrain generator was meant to help find ideas for mappers.
This script can be run with tools.cfg installed.
It will automatically add its menu into the "editing" in-game menu.
The random terrain generator was meant to help find ideas for mappers.
This script can be run with tools.cfg installed.
It will automatically add its menu into the "editing" in-game menu.
[SELECT ALL] Code:
// rndmap -- Create a map and randomly edit height, solid, and lighting values -- by V-Man
// requires tools.cfg --
alias rndmap [
storeargs $arg1 $arg2 $arg3 $arg4
tmp_cubes = (pow 2 $arg1)
if (> $tmp3 30) [echo (c 3)Valid range for attenuation is 1..30
] [if (|| (> $tmp2 100) (< $tmp2 1)) [echo (c 3)Valid range for randomness level is 1..100
] [if (> $tmp4 64) [echo (c 3)Valid range for lighting rate is 0..64] [sleep 10 [
echo (c 9)Generating random map
echo (c 9)Map size level: (c 2)$tmp1
echo (c 9)Number of cubes: (c 2)$tmp_cubes
echo (c 9)Randomness level is (c 2)$tmp2
echo (c 9)Attenuation rate is (c 2)$tmp3
echo (c 9)Lighting rate is (c 2)$tmp4
if $editing [] [edittoggle]
newmap $tmp1
sleep 100 [if $editing [] [edittoggle]
loop rml (* (* $tmp1 $tmp2) 2) [rndsel; rndheight]
loop rsl (* $tmp1 (+ (div $tmp2 10) 1)) [rndsel; solid 1]]
loop rll (* (- (*f (divf 2 3) (square $tmp1)) (*f 3.6 $tmp1)) $tmp4) [rndsel; newent light (rnd 32) (rnd 196)]]]]]]
// rndmap (mapsize) (randomness) (attenuation) (lighting)
// rndmap 7 20 5 8 (creates a medium-sized map with good variety, dimly lit)
alias rndsel [select (+ (rnd (- $tmp_cubes 11)) 9) (+ (rnd (- $tmp_cubes 11)) 9) (+ (rnd (div $tmp_cubes $tmp3)) 2) (+ (rnd (div $tmp_cubes $tmp3)) 2)]
alias rndheight [editheight (rnd 2) (rndposneg (*f (divf (sqrt (* $tmp3 $tmp2)) 256) 128))]
newmenu "Generate a Random Map"
menuitemslider "1Map size level: " 6 9 [] 1 [] [tmp1 = $arg1]
menuitemslider "1Randomness level: " 1 100 [] 5 [] [tmp2 = $arg1]
menuitemslider "1Attenuation rate: " 1 30 [] 1 [] [tmp3 = $arg1]
menuitemslider "1Lighting rate: " 0 64 [] 4 [] [tmp4 = $arg1]
menuitem "" -1
menuitem "2 Generate" [rndmap $tmp1 $tmp2 $tmp3 $tmp4]
add2menu "editing" [menuitem "2Generate a Random Map" [showmenu "Generate a Random Map"]]
docsection [Custom]
docident [rndmap] [Generates a random terrain in a new map];
docargument [S] [Size level of new map] [6..9];
docargument [R] [Randomness level] [1..100];
docargument [A] [Attenuation rate] [1..30];
docargument [L] [Lighting rate] [0..64];
docexample [rndmap 7 20 5 8] [Creates a medium-sized map with good variety, dimly lit];
docremark [View the readme for this script for further details.];
docident [rndsel] [Randomly makes a selection];
docremark ["rndmap" should be run first.];
docident [rndheight] [Randomly adjusts the height of a selection (floor or ceiling)];
docremark ["rndmap" should be run first.];