r/roguelikedev • u/aaron_ds Robinson • Jul 27 '21
RoguelikeDev Does The Complete Roguelike Tutorial - Week 5
Congrats to those who have made it this far! We're more than half way through. This week is all about setting up items and ranged attacks.
Part 8 - Items and Inventory
It's time for another staple of the roguelike genre: items!
Part 9 - Ranged Scrolls and Targeting
Add a few scrolls which will give the player a one-time ranged attack.
Of course, we also have FAQ Friday posts that relate to this week's material
- #7: Loot(revisited)
- #32: Combat Algorithms(revisited)
- #40: Inventory Management(revisited)
- #60: Shops and Item Acquisition
- #76: Consumables
Feel free to work out any problems, brainstorm ideas, share progress and and as usual enjoy tangential chatting. :)
35
Upvotes
9
u/pnjeffries @PNJeffries Jul 27 '21
Roli
Repo
Progress this week: .gif
Summary: Basic combat system, more enemy types, UI and message log done.
Combat
I wrote last week about how I wanted to make knockback a key part of the combat system. So I've been building out around that idea. Every attack in the game has some degree of knockback. Knockback is your primary method of defence; if you hit an enemy away on your turn then it can't hit you back on its own. Smaller objects get knocked further away and larger ones less. Knocking one enemy back into another will do some bonus damage to both of them. This is a simple system and hopefully will be easy for players to grasp while having some interesting interactions and requiring different approaches for different enemies. Items and special attacks will add some flavour on top of this but I wanted to get the basic bump-combat being at least semi-interesting first.
Log Messages
In the past I have sometimes fallen into the common gamedev trap of thinking 'hmm... I should make this game more data-driven' and then creating some kind of text format I can use to define game data. I then think 'hmm... I need to be able to define more complex types' and implement markup for that. I then think 'hmm... I really need to be able to specify random or conditional values...' and then I come back to my senses two weeks later having written half of a totally pointless new scripting language.
Nowadays, I've learned my lesson and mostly avoid this (having realised that provided I structure it cleanly,'hard coded' game data is actually fine - a .cs file is just a text data file, after all), only going the 'implement a whole new markup system' route when it actually provides some benefit. Mostly.
So anyway, my big sub-project this week was setting up a system to allow me to define log messages in a custom markup format. This is what it looks like. That may appear to be gibberish but essentially the stuff in curly braces is all custom markup functions to allow me to select between several different variations of the text either randomly or based on aspects of the subject(s) of the message such as their name, gender or grammatical person. Doing this has a number of advantages that makes this a not-dumb thing to have done (unlike every other time I have done something like this):
This is all to say, I have found a way of convincing myself that all of my past experience writing complicated text parsers for no real reason was not in vain.
Next job: items.
6
u/Gix Jul 27 '21
RT - Repo
Big things this week!
For part 8 it became quickly apparent that the old way of managing the event handler was not enough anymore. Now the event handler has a vtable which the various subclasses can implement. I didn't like the approach at first, but it proved extremely effective.
So effective, in fact, that it allowed me to progress faster through part 9, and also find some time to add a neat debug window made with ImGui:
Demo (Here the player is in the process of activating a fireball scroll.)
I don't know why I waited so long to add it, it was super easy and it helped immensely while fixing a bug related to scroll targeting: first I would've had to walk through the map to find a scroll, try to see if casting it caused the bug, rinse and repeat. It also helped finding a nasty buffer overflow bug when there were too many items on the ground... Oops...
The color pickers also helped iterating on color changes faster, and, after adding a new tileset, I'd say it's looking much prettier now.
6
u/Kehvarl Jul 27 '21
Roguelike 2021 (Common Lisp/BearLibTerminal) | Repo
Progress Thus Far
We're actually in a completely working state up through placing items on the map. Last week's hiccup with broken print functions was resolved by recompiling BearLibTerminal, as apparently the precompiled binaries exclude some of the low level functions which cl-blt relies on.
With working status bars, working message log, and the start of an inventory system, I'm feeling optimistic about polishing up Parts 8 and 9 over the next two days.
The World of Tomorrow
Now that there's a solid foundation in place, and I'm feeling more comfortable with Lisp, there are some features I want to implement which will divert me from the tutorial somewhat.
First up, I had an idea last time we did this event and I'm actually going to implement it: When a creature dies it will receive a
deadAI. For regenerating creatures (such as a Troll) thedead-trollAI will have a random chance of regaining HP every turn. If it rises about a threshold, it will return to life, but if it goes some number of rounds without reaching that threshold it will properly die. The normaldeadAI will just tick through a decay process that ends with the entity being removed from the map.My second idea will require some major work. During map creation, I'll designate one room as special, and keep track of every creature in that room. I'll also create an entity in another room which after a random countdown will select some subset of the creatures in that room, and spawn a new entity with its attributes randomly picked from those creatures. For example, if we pick an Orc and a Troll, the new creature will be an Orcll, might get the Troll's HP, the Orc's attack, and the Troll's AI. This will be especially interesting if the Player is selected for cloning.
5
u/mrhthepie Jul 27 '21
Short ones for me this week.
Part 8 - Items and Interface
Similar to previous parts, I did start off following the tutorial fairly closely. However as outlined previously my plan is to actual use a much simpler design where the player only has a single item at a time. I'm also not planning to do anything clever like monsters having/using items. So a lot of this stuff will get ripped out.
Part 9 - Ranged Scrolls and Targetting
Skimmed over a lot of this chapter as I'm not planning to have a targetting interface as presented here. Did implement a simple lightning scroll to add another type of item for testing purposes. Works fine.
5
u/haveric Jul 27 '21
Untitled 3d Ascii Game (I usually have a name by this point, but nothing is coming to me this year)
Repo | Play | Gallery
Language: JavaScript --- Library: Three.js
I once again had a very productive week and was able to get this week's parts done ahead of time and work on even more!
Part 8: I'm planning on implementing an inventory that is a mix of Diablo and Castle of the Winds, but for now it's looking a lot more like Diablo until I get to adding equipment. A lot of the time invested here was getting the item dragging and item preview working which as I was creating this week's gifs, I noticed a few things that could be improved. For now, goblins and trolls each have some gold in their inventory and drop it on death.
Part 9: Scrolls and targeting were pretty straight forward this time around. While the keyboard can be used for targeting, I find myself always using the mouse to do so. An addition to this might be to highlight different tiles differing colors based on the expected results (red for targets hit)
Notable Improvements: I really wanted to add the classic gelatinous cube into this game, which turned out really well... after several days of chasing down bugs that it created. As they walk around, they vacuum up items into their body and will drop them on death. Turns out keeping track of items attached to actors needed its own component, along with special handling of ghosts/remnants when they go out of vision. I'm very happy with the result, but this definitely took far longer than I expected.
Json Item Extension: I can now create base entities, such as scrolls and potions that define item stack size or shared properties of all entities and have other entities extend off of these. Extensions can also have extensions infinitely. This should make adding a lot of items down the road a lot easier.
Performance Improvement: I noticed that revealing the map (F2) was taking a long time, so I decided to analyze the performance and noticed that geometry centering was taking up 70+% of the time in rendering, which seemed insane to me. I moved the centering into my geometry caching system and revealing the 100x100 map went from 2+ seconds down to about 300ms, which feels like a nice improvement. I'll probably add some scrolls to take advantage of the reveal speed
Looking forward to next week, which I have already implemented a basic quicksave (F8) and quickload (F9), and will be improving it with ui, proper save slots, and autosaving.
5
u/anaseto Jul 27 '21
Parts 8 and 9 of gruid-rltuto in Go are ready! I just finished now, it's been a busy week, but I made it in the end.
5
u/redblobgames tutorials Jul 28 '21
I've fallen behind but don't regret it. On the west coast of the US, we have wildfires, and the smoke is covering much of the country. I think we have a few weeks left before the smoke spreads to the west coast cities, so I am spending a lot of time outdoors before I'm forced to hide inside. So I'm behind on this project :-)
Last week was a catchup week. I've been trying to revisit all the topics in the tutorial and try something different this year. I have been playing with room-based visibility instead of tile-based visibility. I built a room and edge (door) graph and tried it out. Lots of code refactoring along the way. I have mixed feelings with the results. It's exposed some problems with my map generator, and it's also made me want to implement open/closed doors. The map generator and enemy behavior isn't right for this type of visibility (for example, enemies rely on visibility, so you can walk into the next room to escape them easily). So this week I have to decide whether to work on last week's topic (enemies) or this week's topics (inventory, ranged attacks). Ideas I'm considering:
Writeup and playable game
5
u/TechniMan Jul 28 '21 edited Jul 28 '21
The tutorials have caught up, so I'll get on to parts 10 and 11 for next week! Here's my recent progress:
I made a tweak to the tutorial's dungeon generation which creates tunnels between nearby rooms instead of effectively random ones as it was doing (so it creates all the tunnels after creating all the rooms instead of as it goes). I checked my code a few times and didn't find anything wrong, and yet despite my initial attempt creating a tunnel for every single room to its nearest neighbour, it often ended up with the starting room not having any tunnels. No matter, as the rooms often paired up anyway so I decided to instead find the two nearest rooms for each room and tunnel to both of those. This had a far greater success rate of connecting all the dungeon rooms. I tried out with a tunnel to the third nearest as well, but this seemed to make it more messy again, so I decided to leave the addition of a third tunnel to random chance ('tis a roguelike, after all).
I think the dungeons look rather neater and nicer for it, for a fairly easy tweak to an easy algorithm. Once we get to extra floors, I'll see about adding some more wacky generation styles!
Screenshot
Repo
Addendum: I've been thinking about time systems since the link to the FAQ Friday in last week's thread. I was going to add a queue with turns keyed on the gametime they will happen so they can be sorted. I was thinking of using e.g. 20 time units as a base for a typical length turn, so actions could be faster/slower in 5% increments, and the gametime counter would be an integer. But I'm also wondering if a decimal gametime counter, where a typical length turn would be 1.0, would be any better or worse. I'd like to hear others' thoughts on this, and I'll go back to the FAQ Friday threads and read some more. I'm not sure whether it will make any real difference except to allow more precision.
2
u/princess420blaze Jul 28 '21
I went ahead and finished the tcod python tutorial.
Realized I didn't know what exactly I have written.
Spent the last two days writing mediocre documentation for the project =D
At least it's pretty documentation
2
u/KaizarNike Jul 30 '21
Defeating User Built Dungeon - Repo
I did a graphical revamp and I'm happy with the new font I'm now using.
Part 8: I already did the foundation for inventory weeks ago, but I redid a few things so each actor could have their own inventory and that those inventories could be accessed by the bodies left behind.
Part 9: Didn't do all the scrolls I wanted, just wanted some basics down. So far the only way to get these new items is by breaking crates.
I'm proud of my progress so far, and still thinking about making a roguelike MMO in Godot.
2
u/Larront Jul 30 '21
Crown of Vorona
Repo
This week I was able to implement a BSP version that could be used for interiors with one tile thick walls between each room, and started work on a Cellular Automata generator. I drew some inspiration from the Rust Roguelike tutorial and an implementation I found on Grid Sage Games designed by Andy “Evil Scientist” Stobirski. Now I'm stuck at the point of deciding whether to connect or cull unreachable areas :)
1
u/EmergencySpy Jul 31 '21
Repo | Web version
Part 8 and Part 9 - Items and Inventory
Finally, implemented (more or less) everything for this week! At the start of this project, I wanted to branch off a little and try to make a more interesting game, but now I'm thinking that I just want to finish the whole tutorial. And I'm happy with that! So hopefully I will be able to just follow along.
1
u/RivalRoman Aug 01 '21 edited Aug 02 '21
Untitled Urban Fantasy/Anime inspired project
Repo
Stuck to following the tutorial word for word once again this week, but am proud to have been able to keep up with it. I'm making fewer typing mistakes that cause lost time and frustration, and small victories are victories all the same. Beyond that, I think I'm starting to get a basic grip on how things are coming together, but still not really enough to feel confident venturing out on my own too much. It's more of a dim awareness of what might be coming next, which is still wrong as often as it's right. However, I'm going to try and implement another scroll this weekend, to try and keep taking those small steps. I think it's going to end up being an ice scroll which is targeted single target damage.
edit: Managed to get the ice scroll in and working! I know it's basically just kind of copying and pasting different parts of the lightning/confusion scrolls, but I'm proud of myself all the same lol.
1
u/usami33 Aug 01 '21
I stumbled a lot this week.
It took me a very long time to implement items like inventory and scrolls.
In the process of studying, I found out that my code is far from Godot's best practices.
I was tempted to relearn the basics and start from scratch.
For now, I've managed to create something that works, so I'll move on.
It looks something like this
8
u/[deleted] Jul 27 '21
[removed] — view removed comment