Difference between revisions of "T4 Modules Howto Guide/Zones"
m (grammar fix) |
(Lots of formatting. Little shuffles of text) |
||
Line 1: | Line 1: | ||
− | + | Zones are description files for areas. The dungeon is a zone, the ice themed cave is a zone, the overland map is a zone, the town is a zone. They can be relatively simple or complex, and can be interconnected in various ways. | |
− | + | ||
− | + | =What are zones= | |
+ | To the local adventure, a zone is a hangout. To a module writer a zone is a directory in <code>/data/zones</code> containing 5 files in it: | ||
+ | {|class="wikitable" | ||
+ | !File!!Purpose | ||
+ | |- | ||
+ | |zone.lua||Zone description file | ||
+ | |- | ||
+ | |grids.lua||Description of the zone terrain | ||
+ | |- | ||
+ | |npcs.lua||NPCs that exist in the zone | ||
+ | |- | ||
+ | |objects.lua||Objects in the zone | ||
+ | |- | ||
+ | |traps.lua||Traps in the zone | ||
+ | |} | ||
− | < | + | The files <code>grids.lua</code>, <code>npcs.lua</code>, <code>objects.lua</code> and <code>traps.lua</code> are used to load or define the features available in the zone. |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | At its simplest, a <code>load()</code> call to one of the files defined in the <code>/data/general/</code> directory is used, but zone special features can also be defined here, such as ice tiles in a ice cave or a boss that appears only in that zone. | ||
− | + | The reason for this is so you can have only orcs or trolls appear in your zone, with a forest tileset and only outdoor traps. This is also one of the main reasons for segmenting your definition files. | |
− | + | ||
+ | =Zone file= | ||
+ | The zone name, as referred to by other files, is the same as the folder name that this file is in. | ||
+ | {|class="wikitable" | ||
+ | !Variable!!Effect | ||
+ | |- | ||
+ | |name||Display name of this zone. May contain punctuation and spacing. | ||
+ | |- | ||
+ | |level_scheme||If "player", scale zone and NPC levels to match player level, if "fixed", do not scale NPC levels. | ||
+ | |- | ||
+ | |level_range||If level_scheme is "player", this limits the min and max that NPC levels can scale to. | ||
+ | |- | ||
+ | |max_level||Depth of a multi-level dungeon | ||
+ | |- | ||
+ | |actor_adjust_level||See below under "On level_scheme and level_range" | ||
+ | |- | ||
+ | |width||Width of levels. No effect if static level generated. | ||
+ | |- | ||
+ | |height||Height of levels. No effect if static level generated. | ||
+ | |- | ||
+ | |all_remembered||If true, level starts explored. | ||
+ | |- | ||
+ | |all_lited||If true, level starts lit. Or put another way, there is no darkness. | ||
+ | |- | ||
+ | |persistent||If not set, randomizes the level again every time it is entered. If true it saves one level per file. If "zone" it saves all levels in a zone file. If "memory" it saves the level with the mail savefile. | ||
+ | |- | ||
+ | |generator||Defines the generators used for this zone, read below. | ||
+ | |- | ||
+ | |levels||Used to override zone defaults for single levels, such as to add a static boss level at lowest level of zone. | ||
+ | |} | ||
− | + | =Map generators= | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | Generators are used to create dynamic maps. You can only select one of each type per zone, though you can override this in the levels variable. The <code>engine.generator.map</code> namespace has multiple generators for use. You reference them by attaching them to the namespace like so <code>engine.generator.map.Cavern</code> | ||
− | + | {|class="wikitable" | |
− | + | !Generator!!Description | |
+ | |- | ||
+ | |Cavern||Generates a cavern-like level. e.g. for Ardhungol. | ||
+ | |- | ||
+ | |Empty||makes an empty level | ||
+ | |- | ||
+ | |Forest||Generates a forest level with possible ponds of water. Used for the Trollshaws. | ||
+ | |- | ||
+ | |GOL||GOL is game of life I should rename it | ||
+ | |- | ||
+ | |Heightmap||Heightmap is just a bad experiment | ||
+ | |- | ||
+ | |Maze||Maze makes well, a maze...like in .. the maze ;) | ||
+ | |- | ||
+ | |Roomer||Roomer is the standard dungeon builder | ||
+ | |- | ||
+ | |Rooms||yeah Rooms is badly named and half working | ||
+ | |- | ||
+ | |Static||Loads a map file from the data/maps/ folder. It is used e.g. for towns or special levels (the map is then fixed) or for placing special fixed rooms/structures in a random map (e.g. the last level of Amon-Sûl). | ||
+ | |- | ||
+ | |TileSet||TileSet splits the level in tiles of 3x3, 5x5, .. (customizable) each with a set of defined tiles possibilities and it randomly places them, matching existing ones. Examples are the ancient elven ruins, the moria, the first level of the lost merchant quest | ||
+ | |- | ||
+ | |Town||Generates a random town composed of L-shaped and rectangular buildings. Used e.g. for the Rak'shor Pride. | ||
+ | |} | ||
+ | ==Actors== | ||
− | < | + | <code>engine.generator.actor.Random</code> |
− | + | ==Objects== | |
− | + | ||
− | + | <code>engine.generator.object.Random</code> | |
− | + | ||
− | + | ==Traps== | |
− | + | ||
− | + | <code>engine.generator.trap.Random</code> | |
− | + | ||
− | + | =Travelling between zones= | |
− | + | ||
− | + | TODO | |
− | + | ||
− | + | =Word of DarkGod= | |
− | + | ||
− | + | ==On level_scheme and level_range== | |
− | + | <code>max_level</code> is the "physical" depth and <code>level_range</code> is the range of levels allowed. | |
− | + | If the scheme is set to "fixed", or not set at all, actors will only have their natural level. If the scheme is set to "player" then the zone calls <code>game:getPlayer()</code> to get a player, takes its level and uses it to select a level for the zone. | |
− | + | ||
− | + | Imagine you have a zone with <code>max_level = 5; level_range={10,20}</code>. If a level 12 player enters, the zone will power up to level 12 for the first level and then one more per level. Basically it means that you can have zones that level-up with the player, to provide a challenge even if the player is not at the exact right level. | |
− | + | ||
− | + | Actors are always created as level 1, then they are leveled up to their minimum level (their own level_range) then the zone force level-up to the selected level using the <code>actor_adjust_level</code> field of the zone. That field is calculated with this function | |
− | + | <pre> | |
− | + | function(zone, level, e) | |
− | + | return zone.base_level + e:getRankLevelAdjust() + level.level-1 + rng.range(-1,2) | |
− | + | end | |
− | + | </pre> | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
Go back to [[T4 Modules Howto Guide]] | Go back to [[T4 Modules Howto Guide]] | ||
{{Module Guides}} | {{Module Guides}} |
Revision as of 20:33, 9 January 2021
Zones are description files for areas. The dungeon is a zone, the ice themed cave is a zone, the overland map is a zone, the town is a zone. They can be relatively simple or complex, and can be interconnected in various ways.
Contents
What are zones
To the local adventure, a zone is a hangout. To a module writer a zone is a directory in /data/zones
containing 5 files in it:
File | Purpose |
---|---|
zone.lua | Zone description file |
grids.lua | Description of the zone terrain |
npcs.lua | NPCs that exist in the zone |
objects.lua | Objects in the zone |
traps.lua | Traps in the zone |
The files grids.lua
, npcs.lua
, objects.lua
and traps.lua
are used to load or define the features available in the zone.
At its simplest, a load()
call to one of the files defined in the /data/general/
directory is used, but zone special features can also be defined here, such as ice tiles in a ice cave or a boss that appears only in that zone.
The reason for this is so you can have only orcs or trolls appear in your zone, with a forest tileset and only outdoor traps. This is also one of the main reasons for segmenting your definition files.
Zone file
The zone name, as referred to by other files, is the same as the folder name that this file is in.
Variable | Effect |
---|---|
name | Display name of this zone. May contain punctuation and spacing. |
level_scheme | If "player", scale zone and NPC levels to match player level, if "fixed", do not scale NPC levels. |
level_range | If level_scheme is "player", this limits the min and max that NPC levels can scale to. |
max_level | Depth of a multi-level dungeon |
actor_adjust_level | See below under "On level_scheme and level_range" |
width | Width of levels. No effect if static level generated. |
height | Height of levels. No effect if static level generated. |
all_remembered | If true, level starts explored. |
all_lited | If true, level starts lit. Or put another way, there is no darkness. |
persistent | If not set, randomizes the level again every time it is entered. If true it saves one level per file. If "zone" it saves all levels in a zone file. If "memory" it saves the level with the mail savefile. |
generator | Defines the generators used for this zone, read below. |
levels | Used to override zone defaults for single levels, such as to add a static boss level at lowest level of zone. |
Map generators
Generators are used to create dynamic maps. You can only select one of each type per zone, though you can override this in the levels variable. The engine.generator.map
namespace has multiple generators for use. You reference them by attaching them to the namespace like so engine.generator.map.Cavern
Generator | Description |
---|---|
Cavern | Generates a cavern-like level. e.g. for Ardhungol. |
Empty | makes an empty level |
Forest | Generates a forest level with possible ponds of water. Used for the Trollshaws. |
GOL | GOL is game of life I should rename it |
Heightmap | Heightmap is just a bad experiment |
Maze | Maze makes well, a maze...like in .. the maze ;) |
Roomer | Roomer is the standard dungeon builder |
Rooms | yeah Rooms is badly named and half working |
Static | Loads a map file from the data/maps/ folder. It is used e.g. for towns or special levels (the map is then fixed) or for placing special fixed rooms/structures in a random map (e.g. the last level of Amon-Sûl). |
TileSet | TileSet splits the level in tiles of 3x3, 5x5, .. (customizable) each with a set of defined tiles possibilities and it randomly places them, matching existing ones. Examples are the ancient elven ruins, the moria, the first level of the lost merchant quest |
Town | Generates a random town composed of L-shaped and rectangular buildings. Used e.g. for the Rak'shor Pride. |
Actors
engine.generator.actor.Random
Objects
engine.generator.object.Random
Traps
engine.generator.trap.Random
Travelling between zones
TODO
Word of DarkGod
On level_scheme and level_range
max_level
is the "physical" depth and level_range
is the range of levels allowed.
If the scheme is set to "fixed", or not set at all, actors will only have their natural level. If the scheme is set to "player" then the zone calls game:getPlayer()
to get a player, takes its level and uses it to select a level for the zone.
Imagine you have a zone with max_level = 5; level_range={10,20}
. If a level 12 player enters, the zone will power up to level 12 for the first level and then one more per level. Basically it means that you can have zones that level-up with the player, to provide a challenge even if the player is not at the exact right level.
Actors are always created as level 1, then they are leveled up to their minimum level (their own level_range) then the zone force level-up to the selected level using the actor_adjust_level
field of the zone. That field is calculated with this function
function(zone, level, e) return zone.base_level + e:getRankLevelAdjust() + level.level-1 + rng.range(-1,2) end
Go back to T4 Modules Howto Guide