How do I generate a map in various ways?

If you have a module that you'd like comments on or would like to know how to create your very own module, post here

Moderator: Moderator

Post Reply
Message
Author
delax
Posts: 1
Joined: Fri Jan 25, 2013 9:54 am

How do I generate a map in various ways?

#1 Post by delax »

Salutations,

Been a long time watcher, first time writing, blah blah blah...

Anyway, I can do like a bit of tweaking and I don't mind a little copy pasta in coding, but I have found myself unable to find much on the engine.generator.map.* classes.

Setting the zone's generator's class to Roomer, Forest, Maze, Cavern, Empty, or Static seems to work right off the bat (though I have barely a clue as of yet on how to use them).

This question is concentrating on the classes that I can't find much on:
  • engine.generator.map.Building
  • engine.generator.map.GOL
  • engine.generator.map.Heightmap
  • engine.generator.map.Octopus
  • engine.generator.map.Rooms
  • engine.generator.map.RoomsLoader
  • engine.generator.map.TileSet
  • engine.generator.map.Town
What are each of these?
How do I use them?
Are they supposed to be used, or are they rightfully ignored?

Also, how would I write a generator of my own?
I don't mean the the actual map generating code, but everything else after doing that:
What would the algorithm return?
Where do I put it?
Where is it supposed to return to?

For a simple user-defined generator, how do I make a map from a uniform random number generator?

Code: Select all

-- The simplest random map generator possible

local RNG = require("engine.rng") --I assume you need to do this to use the rng module

--- Randomly chooses each tile.
-- Each type of tile has an equal chance to appear at every point on the grid.
-- @param arguments What does the function get passed to it?
-- @return What does it return?
function utterly_random_generator(arguments)
	--insert code here
end
So far it seems I can modify the map generation using the file "\data\zones\dungeon\zone.lua", so if you show examples I would ask you use that (unless I am way off base and it is not applicable):

Code: Select all

return {
	name = "Old ruins",
	level_range = {1, 1},
	max_level = 10,
	decay = {300, 800},
	width = 50, height = 50,
	persistent = "zone",
	generator =  {
		map = {
			class = "engine.generator.map.Roomer",
			nb_rooms = 10,
			rooms = {"simple", "pilar"},
			lite_room_chance = 100,
			['.'] = "FLOOR",
			['#'] = "WALL",
			up = "UP",
			down = "DOWN",
			door = "DOOR",
		},
		actor = {
			class = "engine.generator.actor.Random",
			nb_npc = {20, 30},
--			guardian = "SHADE_OF_ANGMAR", -- The guardian is set in the static map
		},
	},
	levels =
	{
	},
}
Many thanks!

(Man, this is long...)

Goblinz
Module Developer
Posts: 163
Joined: Tue Dec 14, 2010 3:23 am
Location: Where I need to be

Re: How do I generate a map in various ways?

#2 Post by Goblinz »

So to see the files and such look at game\engines\default\engine\generator and that will have all the actual generators. For implementing them I suggest taking a look at tome. Generally you just need to add some extra parameters. They are supposed to be used so go a head. If you have a particular one you want to just ask. For writing your own there is one function that you need. its "generate" you pretty just get handed an array or tiles. Then you generate stuff. making anything complicated will be very tricky though. As with any t-engine stuff ask on irc.rizon.net #tome for real time help.
Those who complain are just Volunteering to fix the problem

<yufra> every vault designer should ask themselves exactly that: What Would Grey Do?

Massimiliano Marangio
Sher'Tul
Posts: 1120
Joined: Mon Sep 30, 2002 9:52 pm
Location: Germany

Re: How do I generate a map in various ways?

#3 Post by Massimiliano Marangio »

About some generators from the engine:
  • engine.generator.map.Building
    It's used to build a big building by subdividing a big room with horizontal or vertical walls into smaller rooms. It's used in the dreams zone.
  • engine.generator.map.GOL
    Game Of Life. It was used in tome2 for the Illusory Castle , but it's not used in the current game afaik.
  • engine.generator.map.Heightmap
    At first a heightmap is generated (each map square is represented by a numeric value, e.g. altitudes), and then these values are compared to the thresholds of a list of tiles (e.g. low values become plains, middle values become hills, high values become mountains). It was used in an old version of Daikara (or the ME equivalent).
  • engine.generator.map.Octopus
    Hearth of the Gloom - one big cavern with branching smaller caverns
  • engine.generator.map.TileSet
    It uses pre-defined tiles to randomly fill the level, but there are checks for consistency (opening only next to an opening). The tiles can be of different sizes (multiples of a base size). It's used to build maze like levels in Escape from Reknor, Thieves Tunnels, the first level of Ancient Elven Ruins. The second level with the boss shows how to use it with different sized tiles and a starting tile
  • engine.generator.map.Town
    Builds a town with smaller buildings or vaults. See Halfling ruins or orc prides.
There are also some generators for some specific zones in tome/class/generator/map/

benstox
Posts: 3
Joined: Sat Mar 16, 2013 4:48 pm

Re: How do I generate a map in various ways?

#4 Post by benstox »

I can't seem to find these generators at all, actually. My game\engines directory only has an empty 'Cores' directory and a file called te4-1.0.1.teae. There doesn't seem to be this directory anywhere: game\engines\default\engine\generator. Have I not installed the T-engine correctly or something? Thanks.

stinkstink
Spiderkin
Posts: 543
Joined: Sat Feb 11, 2012 1:12 am

Re: How do I generate a map in various ways?

#5 Post by stinkstink »

They're in the te4-1.0.1.team file, it's just a renamed zip archive.

Zireael
Archmage
Posts: 449
Joined: Tue Jun 18, 2013 7:24 pm

Re: How do I generate a map in various ways?

#6 Post by Zireael »

This thread ought to be stickied... I was trying to find something on various generators without success. Also, is BSP.lua used anywhere by the game?

Massimiliano Marangio
Sher'Tul
Posts: 1120
Joined: Mon Sep 30, 2002 9:52 pm
Location: Germany

Re: How do I generate a map in various ways?

#7 Post by Massimiliano Marangio »

BSP.lua is used inside of engine.generator.map.Building to subdivide the big building.

Post Reply