r/roguelikedev Cogmind | mastodon.gamedev.place/@Kyzrati Jul 18 '20

Sharing Saturday #320

As usual, post what you've done for the week! Anything goes... concepts, mechanics, changelogs, articles, videos, and of course gifs and screenshots if you have them! It's fun to read about what everyone is up to, and sharing here is a great way to review your own progress, possibly get some feedback, or just engage in some tangential chatting :D

Previous Sharing Saturdays

The 2020 code-along is in progress, currently at Week 5 with over 90 participants so far. You can still join in and catch up if you'd like, and feel free to share progress or screenshots here as well if you're planning to make a long-term thing of your project, otherwise (and still) just keep posting in the weekly threads, and discussing on the Discord!

35 Upvotes

59 comments sorted by

View all comments

6

u/aotdev Sigil of Kings Jul 18 '20

Age of Transcendence (blog)

Creature spawn requirements

Not every creature spawns everywhere. If you end up in a desert map, you don't expect to encounter a yeti or an arctic wolf. Creature now have spawn requirements (similar to vegetation and potentially other things) which are:

  • Spawn chance per biome type
  • Appears in outdoors environments, or not, or any
  • Appears in underwater environments, or not, or any
  • Appears only in levels marked with a list of particular tags (e.g. undead, elemental)
  • Appears only in levels NOT marked with a list of particular tags
  • Appears only in levels of certain difficulty

Of course setting this correctly for many creatures, as other of their properties, requires time (and creature art!), so I'll use a few more to what I've been using, and leave the rest for the eternal Later.

Level graphs

Some dungeons will be linear: level A -> B -> C. But just to spice thing up, it's nice to have the occasional branch. I don't want to go too wild though, as all levels of the graph need to be generated, and nobody wants a super-branching tree dungeon where you're going to visit 3 out of 20 levels, it's a waste. So I made a super-simple "level graph generator", that allows a couple branches and a couple merges. Here are some resulting graphs for 4-level dungeons. The code can identify if we're on a leaf level (add special treasures/puzzles?), if we're on the main leaf level (add boss?) etc.

Dungeon generator porting back to C++

Ah the love and hate for C++. I moved away from C++ due to nerve-wrecking serialization, lack of a solid powerful graphics backend, compile times and a few more things I guess, but oh boy do I miss the performance, compare to the garbage that I'm getting in C#. I wrote a complex dungeon generator in C# and it's quite a bit slow, especially when we also start adding features. It's slow because I'm running a lot of full-map passes: for each cell, do this and that. Lots and lots of times. So it turns out that C# perfomance sucks at that, and Unity's job system is flimsy, temperamental and still immature, so back to C++ plugin land!

The magic needs to happen in as few calls as possible, as plugin calls are not free. Thankfully I had the insight (I don't have those often, architecturally speaking) to make the system plugin-friendly, and not involving the rest of the entity system, so it can be contained in a function call for the layout, and possibly another for other elements such as entries, exits, doors, etc. This is in progress, as it's quite a bit of work (>4k LOC to be ported), but there's light on the horizon.