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

From Tales of Maj'Eyal
Jump to: navigation, search
(Trap info. Rearrange items)
 
(5 intermediate revisions by 4 users not shown)
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>
+
  
 +
=Zone description=
 +
The primary file in a zone folder is <code>zone.lua</code>. It defines the zone itself.
  
<h2 id="toc1">Zone Description: zone.lua</h2>
+
{|class="wikitable"
<p>The zone name, as referred to by other files, is the same as the folder name that this file is in.</p>
+
!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.
 +
|}
  
 +
==Loading code==
 +
The simplest way of loading code is to call <code>load()</code> against a file already defined in <code>/data/general/</code>. As an example, let's say I want to have kobolds in my zone, I would add <code>load("/data/general/npcs/kobold.lua")</code> to <code>npcs.lua</code>.
  
 +
Zone specific features can also be defined, such as placing ice tiles in an ice cave or having a boss that only appears in that zone. This is also one of the main reasons for segmenting your definition files.
  
<table>
+
==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 in <code>zone.lua</code>. In addition to grids, they define how many Enemies/Items/Traps spawn in the area. You can only select one generator of each type per zone, though you can override this in the levels variable.
  
<h2 id="toc2">Generator</h2>
+
===Maps===
<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>
+
  
 +
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>
  
<h3 id="toc3">map</h3>
+
{|class="wikitable"
 +
!Generator!!Description
 +
|-
 +
|Building||Populates the map with clusters of buildings ("blocks") divided into rooms ("buildings") by walls and corridors
  
*<h5 id="toc4">engine.generator.map.Cavern</h5>
+
external_floor = grid to use between buildings (rooms)
**Generates a caven-like level. Used e.g. for Ardhungol in the tome module.
+
  
*<h5 id="toc5">engine.generator.map.Empty</h5>
+
outside_floor = grid to use outside the building area
**makes an empty level<br />
+
|-
 +
|Cavern||Generates a cavern-like level. e.g. for Ardhungol.
 +
|-
 +
|CavernousTunnel||TODO: Need info
 +
|-
 +
|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
 +
|-
 +
|Hexacle||TODO: Need info
 +
|-
 +
|Maze||Maze makes well, a maze...like in .. the maze ;)
 +
|-
 +
|Octopus||Creates a space (Pod room) at center of map, with a number of 'arms' (Pod rooms) around it connected by tunnels
 +
|-
 +
|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.
 +
|}
  
*<h5 id="toc6">engine.generator.map.Forest</h5>
+
====Example====
**Generates a forest level with possible ponds of water. Used for the Trollshaws.<br />
+
In <code>zone.lua</code> you'll define the map as a property of the generator.
  
*<h5 id="toc7">engine.generator.map.GOL</h5>
+
<pre>
**GOL is game of life I should rename it
+
generator =  {
 +
    map = {
 +
    class = "engine.generator.map.Roomer",
 +
    nb_rooms = 10,
 +
    rooms = {"simple", "pillar"},
 +
    lite_room_chance = 100,
 +
    ['.'] = "FLOOR",
 +
    ['#'] = "WALL",
 +
    up = "UP",
 +
    down = "DOWN",
 +
    door = "DOOR",
 +
    }
 +
}
 +
</pre>
  
*<h5 id="toc8">engine.generator.map.Heightmap</h5>
+
===Actors===
**Heightmap is just a bad experiment;<br />
+
  
*<h5 id="toc9">engine.generator.map.Maze</h5>
+
Actors are the NPCs (friendly or otherwise) that spawn in the zone. (Fact check me) Generic and special NPCs for a are defined in <code>npcs.lua</code>. Generic are usually loaded from the base game files predefined in the base game files
**Maze makes well, a maze...like in .. the maze ;)
+
  
*<h5 id="toc10">engine.generator.map.Roomer</h5>
+
<code>nb_npc</code> defines how many enemies will spawn, given a min/max of possible values.
**Roomer is the standard dungeon builder
+
  
*<h5 id="toc11">engine.generator.map.Rooms</h5>
+
<code>guardian</code> defines which guardian (if any) spawns in the zone.
**yeah Rooms is badly named and half working
+
  
*<h5 id="toc12">engine.generator.map.Static</h5>
+
{|class="wikitable"
**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).
+
!Generator!!Description
 +
|-
 +
|Random||Spawn points are randomized
 +
|-
 +
|OnSpots||(Need more info)Spawn points are predetermined
 +
|}
  
*<h5 id="toc13">engine.generator.map.TileSet</h5>
+
====Example====
**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
+
In <code>zone.lua</code> you'll define the actor as a property of the generator.
  
*<h5 id="toc14">engine.generator.map.Town</h5>
+
<pre>
**Generates a random town composed by L-shaped and rectangular buildings. Used e.g. for the Rak'shor Pride.
+
generator = {
 +
    actor = {
 +
        class = "engine.generator.actor.Random",
 +
        nb_npc = {20, 30},
 +
-- guardian = "SHADE_OF_ANGMAR", -- The guardian is set in the static map
 +
    }
 +
}
 +
</pre>
  
 +
===Objects===
  
<h3 id="toc15">actor</h3>
+
{|class="wikitable"
 +
!Generator!!Description
 +
|-
 +
|Random||Spawn points are randomized
 +
|-
 +
|OnSpots||(Need more info)Spawn points are pre-determined
 +
|}
  
*<h5 id="toc16">engine.generator.actor.Random</h5>
+
====Example====
 +
In <code>zone.lua</code> you'll define the object as a property of the generator.
  
<h3 id="toc17">object</h3>
+
TODO: Add example
  
*<h5 id="toc18">engine.generator.object.Random</h5>
+
===Traps===
 +
Traps are traps. Traps only have one generator <code>engine.generator.trap.Random</code>. They're grouped based on similar properties or purposes. Since there aren't too many, we can list them here.
  
<h3 id="toc19">trap</h3>
+
{|class="wikitable"
 +
!Name!!Description
 +
|-
 +
|Alarm||Traps that draw enemies near
 +
|-
 +
|Annoy||Traps that interfere with talents and cooldowns
 +
|-
 +
|Complex||Traps that are thematically complex, let a trap that sets off a boulder to crush you or poison darts.
 +
|-
 +
|Elemental||Traps with elemental properties
 +
|-
 +
|Natural Forest||Traps that would naturally occur in a forest, like slippery rocks or poisonous vines.
 +
|-
 +
|Store||We do stores as "traps" to allow them to nicely overlay walls and such
 +
|-
 +
|Teleport||Traps that teleport the victim away.
 +
|-
 +
|Temporal||Traps that cause temporal damage and effects
 +
|-
 +
|Water||Traps that naturally occur in the water
 +
|}
  
*<h5 id="toc20">engine.generator.trap.Random</h5>
+
====Example====
 +
In <code>zone.lua</code> you'll define the trap as a property of the generator.
  
<h2 id="toc21">Additional file contents</h2>
+
TODO: Add example
<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>
+
==Travelling between zones==
  
<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>
+
TODO
  
 +
=Word of DarkGod=
  
<h2 id="toc22">Static maps</h2>
+
==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.
  
<h2 id="toc23">Travelling between zones</h2>
+
If the <code>level_scheme</code> is set to "fixed", or not set at all, actors will only have their natural level. If the <code>level_scheme</code> 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.
  
<h2 id="toc24">Word of DarkGod</h2>
+
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.
  
<h3 id="toc25">On level_scheme and level_range</h3>
+
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
<p>&lt;&gt; max_level is the &quot;physical&quot; depth<br />
+
<pre>
&lt;&gt; and level_range is the range of levels allowed<br />
+
function(zone, level, e)
&lt;&gt; if the scheme is set to &quot;fixed&quot;, or not set, then actors will only have their natural level<br />
+
    return zone.base_level + e:getRankLevelAdjust() + level.level-1 + rng.range(-1,2)
&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 />
+
end
&lt;&gt; imagine:<br />
+
</pre>
&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 [[T4modules-module-howto-guides]]
+
Go back to [[T4 Modules Howto Guide]]
 +
 
 +
{{Module Guides}}

Latest revision as of 22:15, 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.

Zone description

The primary file in a zone folder is zone.lua. It defines the zone itself.

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.

Loading code

The simplest way of loading code is to call load() against a file already defined in /data/general/. As an example, let's say I want to have kobolds in my zone, I would add load("/data/general/npcs/kobold.lua") to npcs.lua.

Zone specific features can also be defined, such as placing ice tiles in an ice cave or having a boss that only appears in that zone. This is also one of the main reasons for segmenting your definition files.

Generators

Generators are used to create dynamic maps in zone.lua. In addition to grids, they define how many Enemies/Items/Traps spawn in the area. You can only select one generator of each type per zone, though you can override this in the levels variable.

Maps

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
Building Populates the map with clusters of buildings ("blocks") divided into rooms ("buildings") by walls and corridors

external_floor = grid to use between buildings (rooms)

outside_floor = grid to use outside the building area

Cavern Generates a cavern-like level. e.g. for Ardhungol.
CavernousTunnel TODO: Need info
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
Hexacle TODO: Need info
Maze Maze makes well, a maze...like in .. the maze ;)
Octopus Creates a space (Pod room) at center of map, with a number of 'arms' (Pod rooms) around it connected by tunnels
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.

Example

In zone.lua you'll define the map as a property of the generator.

generator =  {
    map = {
    class = "engine.generator.map.Roomer",
    nb_rooms = 10,
    rooms = {"simple", "pillar"},
    lite_room_chance = 100,
    ['.'] = "FLOOR",
    ['#'] = "WALL",
    up = "UP",
    down = "DOWN",
    door = "DOOR",
    }
}

Actors

Actors are the NPCs (friendly or otherwise) that spawn in the zone. (Fact check me) Generic and special NPCs for a are defined in npcs.lua. Generic are usually loaded from the base game files predefined in the base game files

nb_npc defines how many enemies will spawn, given a min/max of possible values.

guardian defines which guardian (if any) spawns in the zone.

Generator Description
Random Spawn points are randomized
OnSpots (Need more info)Spawn points are predetermined

Example

In zone.lua you'll define the actor as a property of the generator.

generator = {
    actor = {
        class = "engine.generator.actor.Random",
        nb_npc = {20, 30},
--	guardian = "SHADE_OF_ANGMAR", -- The guardian is set in the static map
    }
}

Objects

Generator Description
Random Spawn points are randomized
OnSpots (Need more info)Spawn points are pre-determined

Example

In zone.lua you'll define the object as a property of the generator.

TODO: Add example

Traps

Traps are traps. Traps only have one generator engine.generator.trap.Random. They're grouped based on similar properties or purposes. Since there aren't too many, we can list them here.

Name Description
Alarm Traps that draw enemies near
Annoy Traps that interfere with talents and cooldowns
Complex Traps that are thematically complex, let a trap that sets off a boulder to crush you or poison darts.
Elemental Traps with elemental properties
Natural Forest Traps that would naturally occur in a forest, like slippery rocks or poisonous vines.
Store We do stores as "traps" to allow them to nicely overlay walls and such
Teleport Traps that teleport the victim away.
Temporal Traps that cause temporal damage and effects
Water Traps that naturally occur in the water

Example

In zone.lua you'll define the trap as a property of the generator.

TODO: Add example

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 level_scheme is set to "fixed", or not set at all, actors will only have their natural level. If the level_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