Flatten Terrain Tool

The base game does not include a flatten terrain tool, but several mods include one. The tool must be used with caution, as generally any changes made with it cannot be undone. If terrain is flattened across the main river, trading will no longer be possible.

## How to create a Flatten Terrain Tool

### 1. Create a copy of Template\Clear.rsc

Name it FlattenTool.rsc

Change

```
CreateDragDescription createdrag
{
    bool _ignoreZones = false;
    PathBits _placeBits = Normal | Obstacle;
    int _maxWidth = 30;
    int _maxHeight = 30;
    int _minWidth = 1;
    int _minHeight = 1;
}
```

to

```
CreateDragDescription createdrag
{
	bool _ignoreZones = true;
	int _maxWidth = 256;
	int _maxHeight = 256;
	int _minWidth = 1;
	int _minHeight = 1;
}

```

Change

```
ClearAreaDescription cleararea
{
    bool _clearResources = true;
    bool _clearRoads = true;
    bool _clearPickups = false;
    bool _flattenGround = false;
}

```

to

```
ClearAreaDescription cleararea
{
	bool _clearResources = true;
	bool _clearRoads = true;
	bool _clearPickups = true;
	bool _flattenGround = true;
}

```

### 2. Create a copy of Template\StorageYard.rsc

Name it Flatten.rsc

In the section

```
ComponentDescription resource

{

	// how often to update

	UpdatePriority _updatePriority = Fourth;

	// declare types that will be used

	Description _descriptions

	[

		"ui",

		"map",

		"zone",

		"toolbar",

		"createdrag",

		"decal",

		"work",

		"storage",

		"storagedisplay",

		"highlight",

		"statusicon",

		"statemachine",

		"absorbresource",

		"cleararea",

		"destroy"

		"storagelocation",

	]

}

```

delete "ui", "storage", "storagedisplay", "absorbresource", and "storagelocation"

In the section

```
AbsorbResourceDescription absorbresource { }

StorageDisplayDescription storagedisplay { }

StateMachineDescription statemachine { }

ZoneDescription zone { }

StorageLocationDescription storagelocation { }

DestroyDescription destroy { }

```

delete

AbsorbResourceDescription absorbresource { }
StorageDisplayDescription storagedisplay { }
and StorageLocationDescription storagelocation { }

This removes some unused elements that can cause errors in the game with this mod.

Change

```
ToolbarDescription toolbar

{

	SpriteSheet _spriteSheet = "Dialog/SpriteSheet.rsc";

	String _spriteName = "BuildStorageYard";

	StringTable _stringTable = "Dialog/StringTable.rsc:objects";

	String _stringName = "StorageYard";

	String _stringNameLwr = "StorageYardLwr";

	String _toolTip = "StorageYardTip";

	String _statusStrings

	[

		"CreateOk",

		"CreateTooSmall",

		"CreateTooBig",

		"CreateBlocked",

	]

	int _group = 3;

}

```

to

```
ToolbarDescription toolbar

{

	SpriteSheet _spriteSheet = "Dialog/SpriteSheet.rsc";

	String _spriteName = "ClearRoad"; /*Change this when you create your own icon for the tool in the menu bar.*/

	StringTable _stringTable = "Dialog/StringTable.rsc:objects";

	String _stringName = "FlattenTerrain";

	String _toolTip = "FlattenTerrainTip";

	String _statusStrings

	[

		"CreateOk",

		"CreateTooSmall",

		"CreateTooBig",

		"CreateBlocked",

	]

	int _group = 3;

}

```

Change

```
CreateDragDescription createdrag

{

	bool _ignoreZones = false;

	PathBits _placeBits = Normal | Obstacle;

	int _maxWidth = 10;

	int _maxHeight = 10;

	int _minWidth = 2;

	int _minHeight = 2;

	ComponentDescription _allowAndRemove = "Template/Clear.rsc";

}

```

to

```
CreateDragDescription createdrag

{

	bool _ignoreZones = false;

	int _maxWidth = 100;

	int _maxHeight = 100;

	int _minWidth = 1;

	int _minHeight = 1;

	ComponentDescription _allowAndRemove = "Template/FlattenTool.rsc";

}

```

Change

```
DecalDescription decal

{

	MaterialInstance _materials [ "Terrain/TiledDecals/StorageYardMaterial.rsc" ]

	bool _tiled = true;

	float _initialAlpha = 0.5;

}

```

to

```
DecalDescription decal

{

	MaterialInstance _materials [ "Terrain/TiledDecals/ClearAreaMaterial.rsc" ]

	bool _tiled = true;

	float _initialAlpha = 1.0;

}

```

Delete the whole StorageDescription storage block.

Change

```
ClearAreaDescription cleararea

{

	bool _clearResources = true;

	bool _clearPickups = true;

}

```

to

```
ClearAreaDescription cleararea

{

	bool _clearResources = true;

	bool _clearPickups = true;

	bool _clearRoads = true;

	bool _flattenGround = true;

}

```

Delete the whole UIDescription ui block.

### 3. Edit Dialog\StringTable.rsc

Find the section named StringTable objects

Scroll down through this section until you find entries for clearing resources. At the bottom of this group of entries (after ClearCancel), add

```
{ String _name = "FlattenTerrain";		String _text = "Flatten Terrain"; }

{ String _name = "FlattenTerrainTip";	String _text = "Remove all resources and flatten terrain in the selected area."; }

```

### 4. Edit Game\ToolBar.rsc

Under External \_resources, scroll down to "clearcancel", and below it add "flatten"

In the bottom section of the file, scroll down until you find

```
Toolbar clearcancel : "base" { Toolbar _parent = "removal";int _sortPriority = 700;	Action _action = Tool;	ComponentDescription _tool = "Template/ClearCancel.rsc";Keys _hotKey = Tool6; bool _autoHotKey = true;  }

```

and below it add

```
Toolbar flatten : "base"{Toolbar _parent = "removal";	int _sortPriority = 800;	Action _action = Tool;	ComponentDescription _tool = "Template/Flatten.rsc";	Keys _hotKey = Tool7; bool _autoHotKey = true;  }

```

(note that these are both a single line without word wrapping)

### 5. (Optional) Create a 32 x 32 pixel icon for your tool.

Save it in png format as Dialog\Sprite\ToolBar\ToolFlatten.png

Edit Dialog\SpriteSheet.rsc

Find the section with the clear resources entries, and at the bottom of that section, under ClearIron, add

```
{ String _name = "FlattenTerrain"; String _source = "Sprite/Toolbar/ToolFlatten.png"; }

```

then go back and edit Template\Flatten.rsc, and change

String \_spriteName = "ClearRoad";

to

String \_spriteName = "FlattenTerrain";