Page 1 of 1

How do I generate a map in various ways?

Posted: Fri Feb 01, 2013 12:18 am
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...)

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

Posted: Fri Feb 01, 2013 12:45 am
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.

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

Posted: Sat Feb 02, 2013 4:01 am
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/

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

Posted: Sat Mar 16, 2013 5:45 pm
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.

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

Posted: Sat Mar 16, 2013 8:47 pm
by stinkstink
They're in the te4-1.0.1.team file, it's just a renamed zip archive.

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

Posted: Thu Apr 24, 2014 1:38 pm
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?

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

Posted: Fri Apr 25, 2014 12:00 am
by Massimiliano Marangio
BSP.lua is used inside of engine.generator.map.Building to subdivide the big building.