I'm chipping away at implementing the dialogue system. It's daunting; sometimes it feels like trying to build a house all at once. Once you start to sort out what the foundation is, what part depends on what other part, etc, a build order starts to become clear and the whole implementation becomes more manageable. If you can sort that out on paper and think through most if not all of the possible issues, implementation is really straightforward.
Some of the key features like choice selection, tracking dialogue states (e.g. remembering how many times you've interacted with that speaker), and speaker tracking are demoed below:
I discussed an ambient dialogue system in a previous post and made some headway on implementing it. The off-screen dialogue box handling needs more work (really janky atm), but I have the dialogue box "blurring" (which fuzzes dialogue boxes as you get further from then, to mimic those voices becoming harder to hear) more or less working.
I had to compromise a bit though. I originally envisioned a gaussian blur effect, where at sufficient distances the dialogue boxes were basically smeared into nothingness. But blurring individual UI element is really complicated. It looked like the only approach was to setup separate viewports for each dialogue box, render those to textures, and then apply a blur shader to those textures. Way too complicated.
Here's the current implementation of dialogue "blurring". As the player gets further from the speakers, the dialogue boxes scale down and become transparent. It needs some tweaking, e.g. the transparency change looks awkward as a linear function, maybe should be using squared distance to feel more organic. But I think this works well as a general approach. This also means that distant dialogue takes up less screen space, so there'll be less clutter.
Here's the handling of off-screen/ambient dialogue. I ended overcomplicating it, spending too much time trying to implement this unnecessarily complicated version, then found that the simpler approach worked better anyways (just clamping off-screen dialogue boxes to screen space). There was some weirdness that needed fixing—basically, off-screen objects in perspective cameras are positioned counterintuitively, so the y-positioning of the dialogue boxes can look unexpected. The most noticeable case is when off-screen dialogue boxes are positioned at the top the screen for things that are behind the camera. It feels more "natural" to have those at the bottom of the screen; so there's a small snippet that ensures that's the case.
The other feature, which is also a bit janky right now, is interrupting ongoing NPC dialogue. Discussions where the player isn't involved, i.e. among a group of only NPCs, advance automatically. If the player enters the vicinity of any of the NPCs involved in that discussion, and the player can speak with at least one of those NPCs, they will pause their discussion and address the player. If the player leaves the vicinity, they resume their discussion from wherever they left off.
There's a lot to tweak here, like timing around the discussion pausing and resuming, checking for race conditions (always a possibility when timers are involved), and figuring out how best to handle the lead-in/lead-out snippets (here: "Do you need something?" when the player interrupts and "What was I saying..." when the discussion resumes).
Aside from cleaning up the implementations of these features, I'm mostly finished with this first pass at the dialogue system. Still many things to figure out about how dialogue is best triggered and how it should be associated with entities and so on. No doubt things will need fixing and I'll want to do things the system doesn't support as-is. And the tools will also change; I'm already finding pain points with the dialogue editor that need improving.
The next step is to start reviewing all of my notes for the game's world and story and start putting together a more concrete draft/design document. That'll help me figure out what other key mechanic systems are required.
Not a lot of coding today, but a lot more work on the dialogue system. Sketching the manager render sequence out, figuring out the speaker tracking, dialog box placement, etc.
I've tried to think through all possible cases but surely some have been overlooked. I just hope that none are serious enough to require a complete restructuring. There are so many cases to consider, but a few that are trickier include:
Should multiple on-screen decisions be allowed? If so, how do players select between decisions? Right now I'm thinking that only one decision be allowed, but don't know of a robust way of enforcing that constraint in the dialogue editor validator.
Should time stop/player movement be locked while in dialogue? I like the idea of being able to move around, break off from conversations, etc. Makes it feel more lively. But it adds in complications of pausing and resuming dialogue. And fixing the player in place while in a conversation feels like a reasonably "real" constraint to have.
That being said, pausing and resuming is necessary for ambient conversations. For example, two people having a conversation, then pausing to address the player when they get close enough (e.g. "Can I help you?"), and resuming their conversation once the player leaves their vicinity. This is part of a broader question of whether or not the ambient dialogue system should be distinct from the "player" dialogue system. Ideally they are one and the same, and the player's involvement is a special case (e.g. time stops/player movement stops only if an active script includes the player as a speaker; dialogue always auto-advances/times out if the player isn't involved, etc).
How should dialogue progression be handled? There are a lot of potentially conflicting cases here. In general there are three ways a statement can advance: the player hits the next dialogue input, the player selects a choice (if the statement is a decision), or the statement times out (if it has a timeout specified). This is straightforward if there's one statement on-screen. But if there are multiple, as with simultaneous dialogue, then what? If some statements have timeouts and some don't, does pressing the next dialogue input advance them all? Or do they wait for the timeouts to finish? There isn't really a clear answer here. I may just have to pick something and be ready to change it as the rest of the game develops.
This last point is kind of the case with the dialogue system more broadly. I won't really know how well any of this works until I implement it and start working through test cases.
I did get a very basic version of the speaker tracking implemented, was pretty straightforward to do in Godot. Basically I calculate the full bounding box ("AABB") of a spatial node and use that to determine its center x coordinate and maximum y coordinate. Then unproject that point to the camera/screen space. It will get more complicated with multiple speakers and potentially overlapping dialogue boxes, though I think I have a decent solution to that in the sketches above.
I also learned a bit of Blender scripting (which uses Python). Most people I know who do a lot of 3d modeling use Rhino/Grasshopper, and I've seen a lot of really amazing work done with scripting in that tool. It looks like Blender is just as capable, which is cool.
I made a big button for quickly exporting the current file to my Godot model folder. Normally I have to go to the export dialogue, navigate to the appropriate folder, then save. Navigating through folders is slow...it's a small thing but smoothes out the workflow a lot.
I'm also really impressed by the environment Blender provides for scripting. It has a console for trying things out and logs every interaction you have with the UI so that you can easily figure out what functions do what. There are also several templates provided that make it easy to quick prototype an idea.
This week: Alternative RPG systems, race and anime, heavy bike cargo, farmland consolidation and ESG.
Alternative RPG systems
A comment on a thread about an upcoming tabletop RPG called Coyote & Crow led to me to look at a couple alternative tabletop RPG systems to D&D. The only other system I'd read anything about was the one for Cyberpunk 2020 which iirc isn't all that much different from D&D.
Anyway, that's not really what the linked thread is about. The commenter points that D&D and similar games usually encourage violent or other morally-compromising "solutions" to problems that come up. Having played a bit now, yes, violence, whether intentional or not, is the outcome of most scenarios in D&D. The mechanics probably do encourage it but that may also just be part of the fun of role-playing. The commenter points to some other rule systems that are designed to encourage other approaches to problem-solving (this is the context of solarpunk; cheating and murdering people is decidedly not solarpunk).
ORBITAL has a lot of interesting elements. It uses a system called "No Dice, No Masters", originally from Dream Askew. Instead of dice, players earn tokens by doing things and they can spend those tokens to take certain actions, and everyone acts as game master collectively. The way the game structures scenarios is also very clear and helpful. Characters aren't built around particular combat proficiencies like in D&D. It doesn't even look like there's a combat system.
Ryuutama basic system is much closer to D&D (dice-based skill checks) but also has a less clear delineation between game master and player. While there is combat, players gain experience through travelling long distances (their site says it's sometimes called "Hayao Miyazaki's Oregon Trail"), and the magic system has a greater focus on weird utility spells (e.g. "turn any biological matter into a bottle of jam"), which are way more interesting than combat-focused spells. Classes are also more along the lines of "farmer" and "merchant" rather than around combat roles.
Mechanics that don't rely on indiscriminate violence are something I'm thinking a lot about while developing Fugue. A handy term is here "ludonarrative dissonance" which describes the inconsistency between the game's narrative (you're a hero doing good things, or whatever) and the mechanics (but you're going around murdering hundreds if not thousands of people). I'm still on the fence about including combat in the game. Even if combat is a part of the game, only one or two characters will have any combat proficiency.
For what it's worth the D&D campaign I'm in is successfully minimal on combat! It's all the better for it.
An aside on dice systems: I've always found dice-based games and general randomness in games interesting. True randomness doesn't vibe well and paradoxically feels unfair, so game designers often tweak true randomness to align more with our poorly-attuned perception of randomness. If you sit someone down and tell you to write out a random sequence of heads and tails, people will under-represent streaks of heads or tails. Our vulgar understanding of randomness is some like "having no pattern" but in an independent random sequence like coin flips a streak is just as likely as any other combination of flips (though, depending on length, may be rare among all sequences of flips).
Anime character design
Among anime enthusiasts I probably only rank as a "casual" consumer of anime, but I've always wondered why anime characters look so "Western". I only recently learned of the term "mukokuseki", which translates to "without nationality", and at the time the hand-wavy answer I got was more or less "well they look Japanese to Japanese people". Clearly there's a lot more going on, and anime is generally terrible when it comes to issues of race. I have no doubt that this has been thoroughly explored in academia. But I haven't ever really encountered discussion of the topic "in the wild", but again I'm not very plugged into internet anime spheres. The most only recent memory I have of the topic is reading comments around The Last Airbender live-action adaptation, with many people arguing that Aang is white. That just feels wrong, but I don't know if the show runners ever came out with an official statement on that. One of the many, many disappointments of The Legend of Korra is that Aang's descendants are more heavily coded white in their features, so maybe that more or less communicates the show runners' stance on it.
This topic came back to mind after coming across this post on the topic while looking for Satoshi Kon character design images. The post points a bit more to how big the iceberg really is, but still doesn't go into much depth.
Japanese propaganda art during Imperial Japan's military aggression towards China and Korea is notable for featuring Japanese people looking more "European" with their larger eyes and white skin in contrast to the Chinese and Koreans, who were depicted with smaller eyes and stereotypical yellow skin (which is not a real East Asian trait). This artistic racialization was done by the Japanese to distance themselves from the rest of the Asian continent, particularly other East Asians, whom they viewed as inferior to them, and to put themselves on the same level as the West (white people) even though Japanese people obviously bore more cultural and physical similarities to neighbouring East Asian nations than, say, the French.
I love biking with cargo. I've never had a trailer or one of those bikes with the platform on it (I do have a small rear basket though) so I'm usually jury-rigging milkcrates and strapping tons of stuff to my backpack (and/or wearing a front backpack). I had to move out of two studios last summer this way (though for one of the moves I did borrow a truck for the bigger furniture pieces). Anyway this is an IG filled with images of people hauling cargo on bikes. It looks like these are mostly from North America or Europe because tbh this is kind of nothing compared to the cargo you see in China, such as cooking stalls and gravity-defying loads on 三轮车 (sānlúnchē; Kira and Crystal had a cupcake stand on one). But some are still pretty impressive. I'd love to get one of those cargo bicycles one day and haul stuff for people.
There was a moment of a lot of attention on "land grabs"; basically foreign private companies buying up large swathes of land throughout the world for speculative purposes (land being one of the fundamental resources and in fixed supply), for export-oriented industrial agriculture (increasingly seen as a good investment beyond the land itself, driven primarily by pension funds—people will always need to eat), for food security (e.g. countries with wealth but little arable land). Many of the projects on the purchased land puttered out. A report by GRAIN in 2016, "The global farmland grab in 2016: how big, how bad?", reflects on that moment. We can throw climate change into that mix for probably two reasons:
Climate change will probably exacerbate productivity differences across land, making land that remains productive through those changes even more valuable.
On the "green capitalism" front, if services like carbon sequestration become profitable (e.g. through government subsidies or mandates requiring companies purchase offsets), many of the sequestration options have big land requirements (re/afforestation and carbon sequestering agriculture).
Rich people owning a lot of land isn't really new, but Bill Gates is trying to spin it off as something socially beneficial. That also isn't necessarily new (e.g. land dispossession because people weren't using the land well/correctly or whatever) but this is a strong indication of where greenwashing is headed.
From the piece:
Investment firms are making the argument farmlands will meet “carbon-neutral” targets for sustainable investment portfolios while anticipating an increase of agricultural productivity and revenue.
ESG has gained a lot of popularity over the past couple years, basically the idea that you invest keeping environmental and social impacts in mind. The "governance" aspect of ESG is, as far as I know, already a part of most investment analysis. It's not quite the same as ethical investing (which excludes entire categories of investments, e.g. weapons manufacturers) or impact investing (which invests with particular outcomes in mind). My understanding of ESG is that it's a risk-based framework: for example, on the environmental front a company may be exposed to a lot of risk if they are heavy polluters and it's likely that some strong pollution regulation is coming down the pipeline. They'd bear a high cost in fines or purchasing new equipment/changing their processes to meet the new pollution limits.
As far as I know most of the risk in ESG is regulatory, at least if you only consider it in the typical 5 year or less time horizons that analysts usually do. Some might be cultural, e.g. if a company does something racist that goes viral, but I have a feeling that doesn't affect their bottom line that much (the people who make purchasing decisions on that basis are probably a much smaller fraction of a major company's overall market than we'd like to believe). The more important externalities like climate change take a much longer time to play out. If it's true that ESG risk is mostly regulatory, then ESG is really only as risky as the political environment the company operates in. And companies already take great measures to minimize political/regulatory risk.
The other way ESG goes is with this kind of greenwashed investing that's pointed out in the piece. Regulatory risk is one side of ESG, the other is regulatory opportunity. As I mentioned above, things like subsidies for carbon sequestration or carbon offset mandates. Out of those two sides, this is of course the better one, but it still treats climate change as only a technical problem i.e. a matter of carbon accounting.
Dialogue is a key part to Fugue, so I'm taking care to design those systems well from the start. The challenge is trying to imagine all the potential scenarios I might want to play out with the dialogue system beforehand. I'm probably going to get it wrong but I tried my best to design for maximum flexibility/minimum regret.
There are three main pieces that go into the system:
The schema: how is the data that describes a dialogue/conversation encounter (a "script") structured?
The editor: if I'm going to be writing and tweaking a lot of these scripts, I need a tool that's robust, quick, and intuitive.
The manager: the system that handles running scripts in the game, e.g. figuring out where/how to render the text, handle choice selection, etc.
But first, what features am I looking for in a dialogue system?
Branching and dynamic dialogue: choices in dialogue and factors outside that specific encounter influence the course of a conversation.
Choices that depend on other variables (either hidden or shown but not selectable until the criteria is met)
Pick up at different points depending on previous conversations
Circular conversations (e.g. that let you return to a menu of questions to ask someone)
Time-limited decisions, especially because managing time will be an important part of the game
Rich formatting: colors, bold, italic, and whatever else I can get
Entity agnostic: Conversations can be had with both objects and NPCs (without needing to classify objects as NPCs or anything hacky like that)
Flexible in triggering: A conversation can be triggered by player choice (e.g. approaching an object/NPC and interacting), by entering the proximity of something, or after some other action is taken
Integrate into broader scenes: triggering other actions/animations and events, capture the cadence and rhythm of a conversation with pauses (delays and timeouts) and by revealing the text over time (the "typing" effect)
Feels well integrated into the surrounding ambient environment: less "we are locked into having a conversation now"
Handle multiple simultaneous speakers: For example, to convey the feeling of everyone talking over each other in a large group
In terms of developing the game and editing dialogue, there are a couple other quality-of-life features, like making it easy to attach a script to an object, NPC, or trigger area and supporting validation/tests to minimize bugs.
The script schema
This is the schema that's currently in place.
A dialogue script has two top-level keys:
root: The root note that determines how the dialogue starts. It's just an array of "Outcomes" (see below)
events: An array of "Events", which are the basic unit of a dialogue script. This is a flat array, though represents and is parsed into a graph.
An "Event" has the following structure:
id: Used to keep track of event relationships. Only needs to be unique to its parent dialogue.
type: There are two types of Events:
thought: An internal dialogue statement, italicized, and has no associated speaker
verse: A spoken dialogue statement, spoken by a speaker
text: The actual statement that's shown. Can use BBCode, which means colors and other styles can be applied.
speaker: An optional speaker name to show with the rendered text.
delay: Optional delay in seconds before the next event is rendered. For pacing a conversation.
timeout: Optional timeout in seconds the player has to make a choice or to auto-progress the dialogue. If there are choices, letting the time run out is a "null" choice.
signal: Optional signal name (signals are Godot's way of having nodes communicate with each other without direct references) to emit when this event starts. This can be used to trigger things like other actions/animations in the environment (I think, I haven't tested it yet).
outcomes: An array of "Outcomes". An Outcome is a link to another Event, with zero or more conditions attached to it.
The order of the array matters. Outcomes have their conditions evaluated in the array order; the first to evaluate to true (or to have no conditions) is selected as the next Event.
An Outcome with no conditions is the "default" Outcome; there can be only one.
An Outcome has:
ids: The next events to load if this Outcome is selected. Something I'm thinking through now is whether this should only be a single id or multiple ids (the current implementation); the relevance is for the simultaneous speakers feature. Not sure how to do that yet without making the progression of the conversation hard to anticipate.
conditions: An array of Conditions that must evaluate to true for the Outcome to be selected
choices: An array of "Choices". When selected a Choice sets a local variable called choice; Outcomes can condition on this variable (i.e. a Choice can lead to a specific Outcome but more complex behaviors are also supported). A choice consists of:
id: This is what the choice variable is set to if the Choice is selected
required: An array of Conditions that have to be satisfied for this Choice to be selectable
show_required: An array of Conditions that have to be satisfied for this Choice to be visible (e.g. for secret choices)
text: The text displayed for the Choice. Supports BBCode, so colors and other styles can be applied.
The other piece are Conditions, which have the following recursive schema broken into two types:
variable: The variable name for the left side of the comparison
value: The value or variable name for the right side of the comparison
type: Indicates if value is a "value" or a "variable"
comparator: One of ==, !=, <, <=, >, >=, for comparing the left and right sides
op: An and or or operation
a: A Condition
b: Another Condition
Thus JointComparisons can contain more JointComparisons and so on.
The dialogue editor
I shouldn't be editing dialogue scripts by hand but through an editor that keeps things valid where possible. This is implemented as a "main screen" EditorPlugin for Godot using its built-in GraphEdit node and other UI elements. I was surprised at how much can be done with just the built-in components, though it was a struggle at times. I learned a lot in the process but some of Godot's UI behavior is unusual coming from frontend web development.
An additional feature is a validator. It runs through the script and identifies common errors, checking that:
In the script root:
There's one default entrypoint. That is, the script has to have some default starting event.
Each entrypoint is connected to an event.
Each entrypoint eventually leads to a terminal event (i.e. no conversations that loop forever).
For all Conditions:
All values and variables are defined.
All variables reference existing global state variables or choice.
For each Event:
The text is not empty.
Must have a parent (which can be the root).
Each Outcome must be connected to another event.
Has one default Outcome.
Has one default Choice, if it has any Choices.
There are some other small quality-of-life features, like highlighting all events a given event is connected to. The editor will also automatically layout nodes, but it's not very good at the moment. It also gets very dense, very quickly given how many properties there are for an events. I want to figure out how to make that representation more compact and support faster free-flow writing.
The dialogue manager
The dialogue manager is what reads a dialogue script and plays it out in-game. So it needs to render and position the text, render the choices and handle their interactions, etc. So far it's relatively simple (if the schema does its job well, the dialogue manager shouldn't have to do much). But it will probably get more complicated with more advanced features like speaker position tracking, simultaneous dialogue, and ambient dialogue.
Sound cues won't be important in Fugue, but maybe something like this can give a sense of ambient snippets of conversation happening around you. In general I want conversations to feel less like you're fixed in a place with a big block of text at the bottom of the screen and more weaved into the environment, which I think this helps with.
I need to implement and experiment with this kind of approach. It might get way too cluttered or be otherwise overwhelming. One way I could approach that is not showing snippets of speech as the visual cue except when you're close enough where you'd be able to make out what they're saying. At further distances I could group further conversations away into a more abstract representation of speech happening off-screen.
Working out and implementing the rest of the dialogue system is enough to keep me occupied for awhile. Figuring out the ambient dialogue system, a better way to do simultaneous dialogue, and dynamically positioning dialogue boxes based on the speaker position are the next challenges. Then testing everything, fixing any issues, and feeling confident in its robustness and expressiveness.
After that, I want to try building an exterior environment and work on player movement/scene transitions.
Bigger tasks off the top of my head: an inventory system and building out more object interaction, then thinking through some of the more specialized systems. Right now that includes: a card game, a legal system, and character ability puzzles. But what of those remain and what they ultimately need to do depends on figuring out the rest of the world and story in more detail.
A lot of progress this weekend. I put together some larger objects, such as this pharmacy cabinet:
And built out an interior test environment to figure out the built-in physics system (mainly collisions) and develop player movement/control and object interaction. Not sure if I have the best practices down there (e.g. the walls are separate planes, when I should maybe use an inverted cube. But I'm happy with out it turned out:
The player movement and control still need a lot of tweaking. I'm not sure of the best relationship between the player direction and camera direction...this is easier to figure out on console because you have joysticks to control each separately, but not so clear on PCs.
The object interaction using raycasting (key for object interaction/talking to NPCs) was very straightforward, as was object proximity detection (for triggering events when you come near something, for example).
In general I'm getting more familiar with Godot and the workflow with Blender. So far I'm really enjoying Godot; a few small snags here and there but overall it's been intuitive and powerful. I haven't yet felt like I needed to do any clunky or hacky; there's always been a clean solution.
I originally anticipated using Rust as the foundation for the game (was looking at bevy originally as the framework for the game). I even set up an integration between Godot and Rust (using godot-rust). But I've found GDScript to be really nice, and probably performs well enough for my needs. The game logic is straightforward; any bottlenecks would probably come from graphics/rendering/etc which the scripting language wouldn't help much with. Anyways, I'm using relatively small textures and simple models, so I'm not worried about that.
I'm currently sketching out the dialogue system. There are many different scenarios that it needs to handle; I'm hoping to design it so that it basically can run "cutscenes" (really just sequences of dialogue, animations, audio cues, etc) in addition to a more conventional choice-driven system. So I'm taking care to design a system and schema for representing dialogue scripts that will avoid painful re-writes in the future.
I'm using one of my favorite bitmap fonts here, UW ttyp0. Unfortunately it doesn't get much bigger than this, so I'll eventually need to find an alternative.