• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Generating maps?

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
3,323
Solutions
26
Reaction score
2,690
Location
Poland
What do you think about generating areas such as surfaces or dungeons as other games did before?
Imagine spawning different structures on certain places and changing it without restarting the server.
All we need are good structure spawners and even greater auto-border.
However, I wanted to go one step further.
What if we used seeds so we can get same math.random pattern everytime as in Minecraft?
We can even generate structures, but it's a bit more complicated proccess(it conflicts with auto-border, but it's possible). It works even better with dungeons, imagine the possibilities.

map generator in my evo datapack, test run
(if you have slow internet or limited plan: picture size: 6 MB!)
https://i.imgur.com/Q6vz1d9.gif

So...
What do you think? Do you find a system like that useful?




Goals:
(keep in mind that those are planned features, not promised ones)
Let me know if I missed something mentioned in this thread

miscellaneous:
- improve threading, reduce RAM consumption *Done!*
- make it possible to draw the map identical everytime the same seed is on input of certain config - *Done!*
- move rand to lua and rework math random *Done!*
- use layers instead of some functions to make core more flexible *Done!*
- standarize files structure for both distributions *Done!*
- move initialization to onStartup *Done!*
- lightweight spawn system (tracking monsters existence)

save game:
- function to save in-game objects as structures (requested)
- save maps as otbm (requested, easy to implement)
- dump dungeon data to a file

quests, tasks and riddles:
- daily dungeon mission with reward (requested)
- complex quest with riddle example (requested) - will serve as an example
- chests generator

autoborder:
- 3x3 scanning *Done!*
- use rme brushes *Done!*
- bordering order *Done!*
- fix outer border *Done!*
- test inner border *Done!*
- smooth algorhytm for unstackable borders (like earth brush and port hope wooden tiles) *Done!*
- gray mountain custom border to match every case

bring back features from EvoRPG map generator:
- manual conversion of EvoRPG dungeons to new format
- later - the generator is still missing many important functions
- rework/bring back mapgen management channel (make build command safe, add more commands) (requested)

terrain brushes:
- random grounds *Done!*
- cave (hunt and kill for mazes based algorhythm, using cells for reference)
- firework-shaped cave curves
- tunnels (EvoRPG algorhythm) *Done!*
- mazes (hunt and kill algorhythm in 2d and 3d modes)
- island (split perlin noise to events?)
- mountains (modified EvoRPG cave algorhythm)

single brushes:
- create entry/exit (to do: entry, use structures as spawns) *In Progress*
- details placing

structures:
- premade structures (requested)
- structures with negative offset support
- structured maze (with premade cell chunks)
- stairs/ladders/ropespots/pickholes/teleports/multi-floor structures
- villages / towns (cells highly possible)

mapgen management window(modal):
- open/close map
- generate/remove map
- get players in dungeon
- kick/ban players from the map
- enable/disable map whitelist, manage whitelist
- broadcast message to players in specific dungeon
- broadcast message to players in all dungeons
- set time to end (shorten/extend)
- change monsters spawntime
- temporary rename dungeon
- change seed
- save current state as otbm, send lag warning, split to events if possible

mods support (requested):
- *partially implemented* (to install drop files and restart ot)

rme brushes loader (requested):
- load brushes from XML file *Done!*
- convert brushes to Lua *Done!*
- make it possible to merge basic brushes with extensions

backwards compability with 0.4 (8.6 support): *Done!*
- auto detect tfs branch (0.4, 1.x) *Done!*
- 0.4 compat file *Done!*
- adapt the code to weird lib loading *Done!*


*rejected* multiple instances of a dungeon - not likely to happen until I come up with an idea of perfect map space management (or until someone write multiple instances system for TFS)
 
Last edited:
looks legit, perhaps for an event or a special quest
 
Nice, perhaps it could be implemented to RME and used to implement filler areas.
 
I want it to be in game, just different dungeon per... let's say 2 hours.
It's possible, but we need to split map to chunks and use addEvents to avoid 20 sec lag during generating proccess

Basically I'm looking for ideas to build best possible core for this system, because it's too hard to configure it so far. It doesn't have to be fast, it has to run smoothly.
Dunno, something to use modules or idk. Need ideas to make it simple.

I managed to build binary-based autoborder(based on my first simple dungeon generator so it refers to different table), which... maps better than amateur mappers o_O

9mwz.png


autoborder code used:
http://pastebin.com/bt7MtgP2
+two custom functions
Code:
function isPathable(pos)
if queryTileAddThing(getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).uid, {x = pos.x, y = pos.y, z = pos.z}) == RETURNVALUE_NOERROR then
return true
else
return false
end
end

function doCreateItem_Pathable(id, count, pos)
if isPathable(pos) then
doCreateItem(id, count, pos)
return true
else
return false
end
end
 
Last edited:
Have you analysed any rouge-like games algorithms or dungeon generator for pen and paper games(mainly D&D)? Probably you did but if not they will be quite good source for solutions. This however will probably not help you with speed for lua events but for shaping maps.
Actually you could do mapping in parts creating just enough for player to move around and no notice that area is not completed. Create a few rooms, then create next ones or if player is too close to end of content quickly map needed parts. Creator would check for possible entrances and create new areas or lock them. It would also need to check for generated map x,y,z restrictions and pathing. Removing mountains filling would bring boost to speed, but as I barely having any experience I don't know how big. Naturally this gives feeling of caves deep below earth instead caves in mountains.

One interesting approach is pre-generate segments(dungeon/town tiles) and place them. This does not bring complete randomness and forces to exits and entrances be in same places, for each tiles with variation of having it blocked or unblocked, and also might prove to be hard to implement for OT engine. However it would quite interesting to use in combined with normal generation of content. It would bring more sophisticated content to places and ironically dungeon would benefit from greater number of possibilities.
 
Last edited by a moderator:
You could generate a random map for example 1 player that says !dungeon, then he will get teleported there and he will randomized mobs and if he manages to complete it he gets rewarded and he can do this once every day
 
@Gall
They have client-sided autoborder, it'd be pain in ass to write something like this (it's not impossible, but it's huge waste of time).
My work is inspired by Minecraft vanilla generator and Vestia instances
ofc nobody would share their unique code to random dude so I won't even dare to ask.
I am skilled enough to write one myself, but it'd be nice to work with someone to write core and customizable modules folder with many scripts instead of simple messy longcat-sized LUA file.

I split basic shaping to chunks(addEvent loop) like this:
Code:
spawn_new_delay = 0 -- it's part of generating sequence, but let's put 0 as example
generate_border = 500
for i = 1, 3 do
   for chunk_x = 0, inst_tier.map_chunks - 1 do
   for chunk_y = 0, inst_tier.map_chunks - 1 do
   addEvent(generateBorders, (spawn_new_delay + generate_border), {inst_tier.nw_corner.x + ((inst_tier.map_size[1] / inst_tier.map_chunks) * chunk_x), inst_tier.nw_corner.y + ((inst_tier.map_size[2] / inst_tier.map_chunks) * chunk_y), inst_tier.nw_corner.z}, {(inst_tier.map_size[1] / inst_tier.map_chunks), (inst_tier.map_size[2] / inst_tier.map_chunks), (inst_tier.map_size[3])}, tier, i)
   generate_border = generate_border + 500
   end
   end
end

Dynamic generating proccess would be tricky - you'd have to make a complex onStepIn function.
I decided to limit that idea to single dungeons, because nobody would play unlimited fully generated OT which changes map every restart.
Shape generator was nice too, I'll use it as main cave generator mixed with random tunnels(1-5 x 1-7).

Main idea is to do everything in LUA to show TFS 1.0 possibilities.

You also asked for ready parts. It was my first idea - to copy pre-mapped chunks. I managed to do it perfectly, but those areas were weird, very small and very boring(average 3-11 walkable chunks on cave with size 16x16 chunks, single chunk size was also 16x16), the script was very laggy also.
It isn't that hard to implement that, but it's just easier and better to let script form these shapes and then auto-border them.

XYZ restrictions are configurable in map size, that's already done in first script, path-checking function for TFS 1.0 is in my recent post.

Structures are nice idea(such as Minecraft "dungeons" with two chests and mobspawner),
this is how I see they could be placed:
Code:
for x = map_start_x + 20, map_end_x - 20 do -- to avoid spawning part of it outside the map
for y ... same as above
if math.random(1, 1000) <= structure_chance then
doSpawnStructure(number or something)-- let's generate structure there
end
end
end

You could generate a random map for example 1 player that says !dungeon, then he will get teleported there and he will randomized mobs and if he manages to complete it he gets rewarded and he can do this once every day

I'll write globalevent later, I want it to be full-auto
Here is what I have so far:
Code:
function placeSpawn(tier, output)
if output ~= nil then
place_spawn_log = output
else
place_spawn_log = false
end
if place_spawn_log then
io.write("> Setting up spawn... ")
end
inst_tier = dungeon[tier]
inst_dist_from_border = 20
inst_spawn_generate_x = math.random(inst_tier.nw_corner.x + inst_dist_from_border, (inst_tier.nw_corner.x + inst_tier.map_size[1]) - inst_dist_from_border)
inst_spawn_generate_y = math.random(inst_tier.nw_corner.y + inst_dist_from_border, (inst_tier.nw_corner.y + inst_tier.map_size[1]) - inst_dist_from_border)
inst_spawn_generate_z = math.random(inst_tier.nw_corner.z, (inst_tier.nw_corner.z + inst_tier.map_size[3] - 1))
inst_spawn_mid = {x = inst_spawn_generate_x, y = inst_spawn_generate_y, z = inst_spawn_generate_z}
for inst_spawn_x = -inst_tier.spawn_radius, inst_tier.spawn_radius do
for inst_spawn_y = -inst_tier.spawn_radius, inst_tier.spawn_radius do
spawn_current_pos = {x = inst_spawn_mid.x + inst_spawn_x, y = inst_spawn_mid.y + inst_spawn_y, z = inst_spawn_mid.z}
doCreateItem(inst_tier.tiles[math.random(1, #inst_tier.tiles)],1,spawn_current_pos)
end
end
doCreateTeleport(1387, inst_tier.map_exit, inst_spawn_mid)
-- set global storage of x, y + 2, z here which are readed later by movement that lets you in
if place_spawn_log then
io.write("[done]\n")
end
end

Send me a pm if anyone is interested in co-working on it with me.
 
Last edited:
Looking really good there, if you need any kind of help with it, I'd gladly contribute to it.
For your Dungeon idea, I've been writing an indication system quite a while ago for an auto generating training area.
http://otland.net/threads/infinity-training-room-0-3-6-0-4.179468/#post-1759936
You can feel free to use the indication system, so you can concentrate on other things.


kind regards, Evil Hero.
 
@Evil Hero
Thank you, but main functions are done already. I'll write boss rooms spawner later.
I'm thinking of some mini-quests or challenges or even missions, but I need some inspiration.
Anyone playd on something similiar already(it don't has to be generated)?

btw. if there is too much players on certain area(in your script) aren't rooms overlayed/bugged?

I'll also pm you later.
 
Last edited:
128 x 128 x 3, 20 actions/s, took me few days to rewrite core
Even I am surprised by effects it makes

This looks amazing.
Being able to play a server with randomly generated maps would be insanely fun.
That last cave you generated looks stunning.

Red
 
Back
Top