Permalink
Browse files

sandbox: more scenario options and better map generation

  • Loading branch information...
MDT-Maikel committed Mar 11, 2018
1 parent 29a1a21 commit 0e535f880efa9815e795e76cb4773924d051b6f1
@@ -1,6 +1,6 @@
Sandkasten

Eine Karte zum Unfug treiben, ohne wenn und aber. Hier kannst du dich nach Lust und Laune austoben und kannst hier alles ausprobieren, was du möchtest.
In dieser Runde kannst du mit allen Objekten im Spiel experimentieren. Einfach nur Spaß haben!

Folgende Werkzeuge stehen dir hier zur Verfügung:

@@ -1,6 +1,6 @@
Sandbox

A scenario to play around with all the cool stuff.
In this round you can experiment with all objects in the game. Just have fun!

The following tools can be used:

@@ -2,56 +2,137 @@
Sandbox
Map drawing for sandbox scenario.
@author K_Pone
@author K_Pone, Maikel
*/

func InitializeMap(proplist map)
#include Library_Map

// Called be the engine: draw the complete map here.
public func InitializeMap(proplist map)
{
if (!MapGenPreset) MapGenPreset = "FlatLand"; // For the initial map on scenario start
// Initialize the map settings from scenario parameters. If a map is created in god mode
// these settings are already up to date.
InitMapSettings();

// These were set in the MapGen UI
Resize(MapGenSizeWidth ?? 80, MapGenSizeHeight ?? 50);
// Resize the map.
Resize(Settings_MapWdt, Settings_MapHgt);

if (MapGenPreset == "FlatLand")
{
Draw("Earth", { Algo = MAPALGO_Rect, X = 0, Y = MapGenSizeHeight / 2, Wdt = MapGenSizeWidth, Hgt = MapGenSizeHeight / 2 + 1 } );
}
else if (MapGenPreset == "Skylands")
// Draw empty map according to type setting.
if (Settings_MapType == CSETTING_MapType_Empty)
return true;

// Create the main surface: a rectangle with some turbulence on top.
var height = [9 * map.Hgt / 20, 9 * map.Hgt / 20, 11 * map.Hgt / 20][Settings_MapType - 1];
var amplitude = [[0, 10], [0, 18], [0, 40]][Settings_MapType - 1];
var scale = [[0, 10], [0, 16], [0, 24]][Settings_MapType - 1];
var rect = {X = 0, Y = height, Wdt = map.Wdt, Hgt = map.Hgt - height};
var surface = {Algo = MAPALGO_Rect, X = rect.X, Y = rect.Y, Wdt = rect.Wdt, Hgt = 8 * rect.Hgt / 6};
surface = {Algo = MAPALGO_Turbulence, Iterations = 4, Amplitude = amplitude, Scale = scale, Seed = Random(65536), Op = surface};

// Draw materials inside the main surface.
DrawMaterials(rect, surface);

// Draw some sky islands.
for (var x = RandomX(30, 60); x < map.Wdt - 30; x += RandomX(45, 85))
DrawSkyIsland(map, x, RandomX(32, 52), RandomX(20, 30), RandomX(18, 24));

// Return true to tell the engine a map has been successfully created.
return true;
}


// Draws materials on the given surface.
public func DrawMaterials(proplist rect, proplist surface)
{
var mask;
var x = rect.X;
var y = rect.Y;
var wdt = rect.Wdt;
var hgt = rect.Hgt;

// Earth forms the basis.
Draw("Earth", surface);

// A bit of different types of earth all around the surface.
DrawMaterialSlab("Earth-earth", surface, y, hgt, 4, 12);
DrawMaterialSlab("Earth-earth_root", surface, y, hgt, 2, 16);
DrawMaterialSlab("Earth-earth_spongy", surface, y, hgt, 2, 16);
DrawMaterialSlab("Earth-earth", surface, y, hgt, 4, 12);

// Basic materials.
DrawMaterialSlab("Rock", surface, y, hgt, 2, 8);
DrawMaterialSlab("Tunnel", surface, y, hgt, 6, 3);
DrawMaterialSlab("Ore", surface, y + hgt / 6, hgt / 2, 8, 10);
DrawMaterialSlab("Coal", surface, y + hgt / 7, hgt / 2, 8, 10);
DrawMaterialSlab("Firestone", surface, y + hgt / 6, hgt / 2, 6, 6);
DrawMaterialSlab("Tunnel", surface, y + hgt / 7, hgt / 4, 12, 8);
DrawMaterialSlab("Tunnel", surface, y + 2 * hgt / 3, hgt / 4, 8, 12);
DrawMaterialSlab("Water", surface, y + hgt / 3, hgt / 3, 8, 10);

// Valuable materials in the bottom layer.
DrawMaterialSlab("Firestone", surface, y + 3 * hgt / 5, 2 * hgt / 5, 6, 2);
DrawMaterialSlab("Rock", surface, y + 3 * hgt / 5, 2 * hgt / 5, 6, 14);
DrawMaterialSlab("Granite", surface, y + 3 * hgt / 5, 2 * hgt / 5, 6, 12);
DrawMaterialSlab("Tunnel", surface, y + 3 * hgt / 5, 2 * hgt / 5, 10, 8);
DrawMaterialSlab("Gold", surface, y + 2 * hgt / 3, hgt / 4, 3, 6);
DrawMaterialSlab("Gold", surface, y + 3 * hgt / 4, hgt / 4, 6, 6);
DrawMaterialSlab("Ruby", surface, y + 4 * hgt / 5, hgt / 5, 6, 4);
DrawMaterialSlab("Amethyst", surface, y + 4 * hgt / 5, hgt / 5, 6, 4);

// Draw the surface layer according to map type.
var border_height = [4, 6, 12][Settings_MapType - 1];
var border = {Algo = MAPALGO_Border, Top = border_height, Op = surface};
Draw("Earth", border);
var rnd_checker = {Algo = MAPALGO_RndChecker, Ratio = 30, Wdt = 2, Hgt = 2};
var rnd_border = {Algo = MAPALGO_And, Op = [border, rnd_checker]};
Draw(["Sand", "Rock", "Granite"][Settings_MapType - 1], rnd_border);
Draw(["Earth-earth_root", "Rock-rock_smooth", "Rock"][Settings_MapType - 1], rnd_border);
if (Settings_MapType == CSETTING_MapType_MapTypeMountains)
Draw("Everrock", rnd_border);
return;
}


public func DrawSkyIsland(proplist map, int x, int y, int wdt, int hgt)
{
// An island is just an ellipse with turbulence.
var island = {Algo = MAPALGO_Ellipsis, X = x, Y = y, Wdt = wdt / 2, Hgt = hgt / 2};
island = {Algo = MAPALGO_Turbulence, Iterations = 4, Amplitude = [8, 18], Seed = Random(65536), Op = island};
Draw("Earth", island);

// Overlay a set of materials inside the island.
DrawMaterial("Earth-earth_root", island, 4, 30);
DrawMaterial("Earth-earth", island, 3, 30);
DrawMaterial("Tunnel", island, 3, 10);
for (var mat in ["Coal", "Ore", "Firestone"])
{
var islands =
{
Algo = MAPALGO_Turbulence,
Op = { Algo=MAPALGO_RndChecker, Wdt=5, Hgt=2, Ratio = 10 }
};

Draw("Earth", islands);
DrawMaterial(mat, island, 4, 12);
DrawMaterial(mat, island, 6, 6);
}
else if (MapGenPreset == "Caves")
{
Draw("Earth", { Algo = MAPALGO_Rect, X = 0, Y = 0, Wdt = MapGenSizeWidth, Hgt = MapGenSizeHeight } );


for (var i = 0; i < 3; i++)
{
var tunnels =
{
Algo = MAPALGO_Polygon,
X = [Random(MapGenSizeWidth),Random(MapGenSizeWidth)],
Y = [Random(MapGenSizeHeight),Random(MapGenSizeHeight)],
Wdt = Random(10) + 3,
Empty = true,
Open = true
};

Draw("Tunnel", tunnels);
}
}
// Draw a top border out of sand and top soil.
var sand_border = {Algo = MAPALGO_And, Op = [{Algo = MAPALGO_Border, Op = island, Top = [-1,2]}, {Algo = MAPALGO_RndChecker, Ratio = 50, Wdt = 4, Hgt = 3}]};
var topsoil_border = {Algo = MAPALGO_And, Op = [{Algo = MAPALGO_Border, Op = island, Top = [-1,3]}, {Algo = MAPALGO_RndChecker, Ratio = 40, Wdt = 4, Hgt = 2}]};
Draw(["Sand", "Rock", "Granite"][Settings_MapType - 1], sand_border);
Draw(["Earth-earth_root", "Rock-rock_smooth", "Rock"][Settings_MapType - 1], topsoil_border);


return true;
// Draw a bottom border out of granite and rock (or everrock on insane).
var granite_border = {Algo = MAPALGO_Border, Op = island, Bottom = [-2,3]};
Draw(["Rock", "Granite", "Everrock"][Random(3)], granite_border);
var rock_border = {Algo = MAPALGO_RndChecker, Ratio = 20, Wdt = 2, Hgt = 2};
Draw(["Granite", "Rock", "Granite"][Random(3)], {Algo = MAPALGO_And, Op = [granite_border, rock_border]});
Draw(["Granite", "Rock", "Granite"][Random(3)], {Algo = MAPALGO_And, Op = [granite_border, rock_border]});
return;
}

global func PostMapGen()

/*-- Helper Functions --*/

public func DrawMaterialSlab(string mat, proplist mask, int y, int hgt, int spec_size, int ratio)
{
// This is called after the map is generated. Should be used to place environment objects.
}
var slab = {Algo = MAPALGO_Rect, X = this.X, Y = y, Wdt = this.Wdt, Hgt = hgt};
slab = {Algo = MAPALGO_Turbulence, Iterations = 4, Op = slab};
slab = {Algo = MAPALGO_And, Op = [slab, mask]};
DrawMaterial(mat, slab, spec_size, ratio);
return;
}
@@ -0,0 +1,123 @@
[ParameterDef]
Name=$MapSize$
Description=$DescMapSize$
ID=MapSize
Default=4

[Options]

[Option]
Name=$MapSizeNarrowSmall$
Value=0

[Option]
Name=$MapSizeNarrowNormal$
Value=1

[Option]
Name=$MapSizeNarrowLarge$
Value=2

[Option]
Name=$MapSizeBasicSmall$
Value=3

[Option]
Name=$MapSizeBasicNormal$
Value=4

[Option]
Name=$MapSizeBasicLarge$
Value=5

[Option]
Name=$MapSizeWideSmall$
Value=6

[Option]
Name=$MapSizeWideNormal$
Value=7

[Option]
Name=$MapSizeWideLarge$
Value=8

[ParameterDef]
Name=$MapType$
Description=$DescMapType$
ID=MapType
Default=1

[Options]

[Option]
Name=$MapTypeEmpty$
Value=0

[Option]
Name=$MapTypeFlatland$
Value=1

[Option]
Name=$MapTypeHills$
Value=2

[Option]
Name=$MapTypeMountains$
Value=3

[ParameterDef]
Name=$MapClimate$
Description=$DescMapClimate$
ID=MapClimate
Default=0

[Options]

[Option]
Name=$MapClimateTemperate$
Value=0

#[Option]
#Name=$MapClimateCold$
#Value=1

[ParameterDef]
Name=$Goal$
Description=$DescGoal$
ID=Goal
Default=1

[Options]

[Option]
Name=$NoGoal$
Value=0

[Option]
Name=$GoalMining$
Value=1

[Option]
Name=$GoalExpansion$
Value=2

[ParameterDef]
Name=$GodMode$
Description=$DescGodMode$
ID=GodMode
Default=2

[Options]

[Option]
Name=$GodModeOff$
Value=0

[Option]
Name=$GodModeHost$
Value=1

[Option]
Name=$GodModeAll$
Value=2
@@ -1,11 +1,18 @@
[Head]
Title=Sandbox
Icon=17
Title=Sandbox
Version=8,0
Difficulty=100

[Definitions]
Definition1=Objects.ocd
Definition2=Decoration.ocd/Misc.ocd/SprayCan.ocd

[Landscape]
Sky=Clouds2
SkyScrollMode=2
Secret=false

[Weather]
Climate=0
YearSpeed=0
Wind=0,100,-100,100
Oops, something went wrong.

0 comments on commit 0e535f8

Please sign in to comment.