Difference between revisions of "T4 Modules Howto Guide/Zones"

From Tales of Maj'Eyal
Jump to: navigation, search
m (grammar fix)
(Lots of formatting. Little shuffles of text)
Line 1: Line 1:
<h1 id="toc0">Zones: Your local adventurer hangouts</h1>
+
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.
<p>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.</p>
+
  
<p>What a zone is to the module writer is a directory in the /data/zones folder with 5 files in it:</p>
+
=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
 +
|}
  
<table>
+
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.
    <tr>
+
        <th>File</th>
+
        <th>Purpose</th>
+
    </tr>
+
    <tr>
+
        <td>zone.lua</td>
+
        <td>Zone description file</td>
+
    </tr>
+
    <tr>
+
        <td>grids.lua</td>
+
        <td>Description of the zone terrain</td>
+
    </tr>
+
    <tr>
+
        <td>npcs.lua</td>
+
        <td>NPCs that exist in the zone</td>
+
    </tr>
+
    <tr>
+
        <td>objects.lua</td>
+
        <td>Objects in the zone</td>
+
    </tr>
+
    <tr>
+
        <td>traps.lua</td>
+
        <td>Traps in the zone</td>
+
    </tr>
+
</table>
+
  
 +
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.
  
<h2 id="toc1">Zone Description: zone.lua</h2>
+
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.
<p>The zone name, as referred to by other files, is the same as the folder name that this file is in.</p>
+
  
 +
=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 &quot;zone&quot; 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.
 +
|}
  
<table>
+
=Map generators=
    <tr>
+
        <th>Variable</th>
+
        <th>Effect</th>
+
    </tr>
+
    <tr>
+
        <td>name</td>
+
        <td>Display name of this zone.  May contain punctuation and spacing.</td>
+
    </tr>
+
    <tr>
+
        <td>level_scheme</td>
+
        <td>If &quot;player&quot;, scale zone and NPC levels to match player level, if &quot;fixed&quot;, do not scale NPC levels.</td>
+
    </tr>
+
    <tr>
+
        <td>level_range</td>
+
        <td>If level_scheme is &quot;player&quot;, this limits the min and max that NPC levels can scale to.</td>
+
    </tr>
+
    <tr>
+
        <td>max_level</td>
+
        <td>Depth of a multi-level dungeon</td>
+
    </tr>
+
    <tr>
+
        <td>actor_adjust_level</td>
+
        <td>See below under &quot;On level_scheme and level_range&quot;</td>
+
    </tr>
+
    <tr>
+
        <td>width</td>
+
        <td>Width of levels. No effect if static level generated.</td>
+
    </tr>
+
    <tr>
+
        <td>height</td>
+
        <td>Height of levels. No effect if static level generated.</td>
+
    </tr>
+
    <tr>
+
        <td>all_remembered</td>
+
        <td>If true, level starts explored.</td>
+
    </tr>
+
    <tr>
+
        <td>all_lited</td>
+
        <td>If true, level starts lit.</td>
+
    </tr>
+
    <tr>
+
        <td>persistant</td>
+
        <td>If not set, randomizes the level again every time it is entered. If true it saves one level per file.  If &quot;zone&quot; it saves all levels in a zone file.  If &quot;memory&quot; it saves the level with the mail savefile.</td>
+
    </tr>
+
    <tr>
+
        <td>generator</td>
+
        <td>Defines the generators used for this zone, read below.</td>
+
    </tr>
+
    <tr>
+
        <td>levels</td>
+
        <td>Used to override zone defaults for single levels, such as to add a static boss level at lowest level of zone.</td>
+
    </tr>
+
</table>
+
  
 +
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>
  
<h2 id="toc2">Generator</h2>
+
{|class="wikitable"
<p>There are four kinds of generators at the time of writing. You can only select one of each type per zone, though you can override this in the levels variable.</p>
+
!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==
  
<h3 id="toc3">map</h3>
+
<code>engine.generator.actor.Random</code>
  
*<h5 id="toc4">engine.generator.map.Cavern</h5>
+
==Objects==
**Generates a caven-like level. Used e.g. for Ardhungol in the tome module.
+
  
*<h5 id="toc5">engine.generator.map.Empty</h5>
+
<code>engine.generator.object.Random</code>
**makes an empty level<br />
+
  
*<h5 id="toc6">engine.generator.map.Forest</h5>
+
==Traps==
**Generates a forest level with possible ponds of water. Used for the Trollshaws.<br />
+
  
*<h5 id="toc7">engine.generator.map.GOL</h5>
+
<code>engine.generator.trap.Random</code>
**GOL is game of life I should rename it
+
  
*<h5 id="toc8">engine.generator.map.Heightmap</h5>
+
=Travelling between zones=
**Heightmap is just a bad experiment;<br />
+
  
*<h5 id="toc9">engine.generator.map.Maze</h5>
+
TODO
**Maze makes well, a maze...like in .. the maze ;)
+
  
*<h5 id="toc10">engine.generator.map.Roomer</h5>
+
=Word of DarkGod=
**Roomer is the standard dungeon builder
+
  
*<h5 id="toc11">engine.generator.map.Rooms</h5>
+
==On level_scheme and level_range==
**yeah Rooms is badly named and half working
+
<code>max_level</code> is the "physical" depth and <code>level_range</code> is the range of levels allowed.
  
*<h5 id="toc12">engine.generator.map.Static</h5>
+
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.
**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).
+
  
*<h5 id="toc13">engine.generator.map.TileSet</h5>
+
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.
**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
+
  
*<h5 id="toc14">engine.generator.map.Town</h5>
+
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
**Generates a random town composed of L-shaped and rectangular buildings. Used e.g. for the Rak'shor Pride.
+
<pre>
 
+
function(zone, level, e)
 
+
    return zone.base_level + e:getRankLevelAdjust() + level.level-1 + rng.range(-1,2)
<h3 id="toc15">actor</h3>
+
end
 
+
</pre>
*<h5 id="toc16">engine.generator.actor.Random</h5>
+
 
+
<h3 id="toc17">object</h3>
+
 
+
*<h5 id="toc18">engine.generator.object.Random</h5>
+
 
+
<h3 id="toc19">trap</h3>
+
 
+
*<h5 id="toc20">engine.generator.trap.Random</h5>
+
 
+
<h2 id="toc21">Additional file contents</h2>
+
<p>The files grids.lua, npcs.lua, objects.lua and traps.lua are used to load or define the features available in the zone.</p>
+
 
+
<p>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.</p>
+
 
+
<p>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.</p>
+
 
+
 
+
<h2 id="toc22">Static maps</h2>
+
 
+
<h2 id="toc23">Travelling between zones</h2>
+
 
+
<h2 id="toc24">Word of DarkGod</h2>
+
 
+
<h3 id="toc25">On level_scheme and level_range</h3>
+
<p>&lt;&gt; max_level is the &quot;physical&quot; depth<br />
+
&lt;&gt; and level_range is the range of levels allowed<br />
+
&lt;&gt; if the scheme is set to &quot;fixed&quot;, or not set, then actors will only have their natural level<br />
+
&lt;&gt; if it is set to &quot;player&quot; then the zone calls game:getPlayer() to get a player, takes its level and uses it to select a level for the zone<br />
+
&lt;&gt; imagine:<br />
+
&lt;&gt; if you haev a zone with max_level = 5; level_range={10,20}<br />
+
&lt;&gt; then if a level 12 player enters, the zone &quot;levels itself&quot; to be level 12 for the first level and then one more per level<br />
+
&lt;&gt; basically it means that you can have zones that levelup with the player, as to provide a challenge even if the player is not at the exact right level<br />
+
&lt;&gt; actors are always created as level 1, then they are leveled up to theuir minimun level (their own level_range)<br />
+
&lt;&gt; then the zone force levelup to the selected level\&lt;dg_&gt; using the <br />
+
&lt;&gt;  actor_adjust_level = function(zone, level, e) return zone.base_level + e:getRankLevelAdjust() + level.level-1 + rng.range(-1,2) end,<br />
+
&lt;&gt; field of the zone</p>
+
  
 
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.

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