T4 Modules Howto Guide/Zones

From Tales of Maj'Eyal
Revision as of 22:15, 9 January 2021 by QuixoticScamp (Talk | contribs) (Trap info. Rearrange items)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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