
Two weeks, seventy releases
In mid-October I started modding Legend of Mortal, a Chinese wuxia life-sim RPG built in Unity, beginning from a small open-source helper mod. Two weeks later it was a 36,000-line mod called Coffee Companion, with seventy releases. It draws the whole story as a route map and each quest as a flowchart, saves anywhere and replays from any point in the story, lets you pick dice outcomes, edits stats, affinity and story flags, and has an AI companion that reads the game's scripts before it answers. Almost none of the hard parts were the code. They were deciding what to build, what to refuse, and how to work with a collaborator that writes code much faster than I can check it.
Coffee Companion is open source at kevinnie2003/LOMAssistant. I wrote it together with Claude Code over one long run of sessions. Player reports are described in general terms only; nothing here comes from anyone's save or machine.
I test, it writes
The division of labour settled on day one and never changed. Claude Code read the decompiled game, wrote the patches, built the DLL and copied it into my game folder. I launched the game, played to the place that mattered, and reported back. The sentence that shipped a version was always some form of "tested, no problems, commit it." Everything outward-facing waited for that: commits, pushes, release notes, replies to players.
That split is what made the pace possible. The first public release went out on October 16. By October 29 there had been 395 commits and seventy releases, ten of them on a single day. The model could implement a feature in minutes. What it could not do was see the screen: a tooltip that overflowed, a portrait cropped through the face, a gamepad cursor that skipped the last option in a menu. Those were mine to find, and most of my messages were exactly that kind of report.
The few times I said "didn't test, commit anyway," it sometimes backfired. One early build let players "pass time" from inside conversation menus, not just from the action menus where that makes sense. In a conversation it advanced the calendar, so story events fired early. A player found it within hours. The fix took minutes, which is the other half of the lesson: shipping fast is fine as long as fixing fast comes with it, and a ten-minute release pipeline makes both cheap.
Reading a game without its source
There is no source code and no documentation, only decompiled C# and a few thousand Lua story scripts. The mod is a BepInEx plugin that patches the game at runtime with Harmony; by the end it had more than 230 patches. Most features started with the same question: where in the decompiled code does the game decide this, and what else depends on that decision?
The scripts turned out to be the real specification. I had Claude parse all 2,200-odd of them into one structure: every branch with its condition, every flag with every place it is set and every place it is checked, every quest with its trigger window. That structure became the backbone for most of what came after: a calendar route map of the main and side quests, a flowchart for every quest, each choice's real unlock condition shown next to it, and later the AI's knowledge base.
It also explained bugs that looked impossible. A player asked for an option where every ten-day turn has exactly one action. It seemed harmless. It was not: more than forty story scenes check how many actions you have left, and some main quests can only start in one specific ten-day window. If a household meeting at the start of the turn spent your only action, the game advanced the calendar before checking quests, and that main quest never fired. Every later chapter stalled behind it. The fix was to check before advancing: if a main quest is due in this turn, keep one action and stay. The README also got a plain warning that these modes can break the story, because "use with care" in small print was not enough.
Not every win was clever. Getting from launch to a clickable title screen took 21 seconds, most of it an eleven-second intro animation and a splash logo. Playing the animation six times faster, plus an installer option that removes the logo, brought it to 6.
A save system built on replay
The game only lets you save at certain points. Players wanted to save anywhere, including in the middle of a dialogue, a step before a dice roll. You cannot simply serialise a paused Lua coroutine. The approach I took instead, starting from a design a player shared, is to record and replay.
Every story script is rewritten as it loads: dialogue lines, choices, dice rolls and condition checks go through recording wrappers. An anytime save stores the game state from the start of the current script plus the trace of what happened since. Loading restores that state and runs the script again from the top. Dialogue is fast-forwarded, every choice and roll is fed back from the trace, and every write to game data is skipped, because the stored state already contains it. When the trace runs out, the player is exactly where they saved, with the right music playing.
Replay is only correct if the script is the same one that was recorded. The first game patch after release broke every anytime save, because scripts had changed underneath them. A contributor sent the first fix. The lasting one was a compatibility contract: each save records a hash of every script it passed through and of the game code it depends on, and a load that does not match stops with a clear message instead of desyncing quietly.
Ten days later the same idea solved a bug in the game's own saves. A player reported that their main story had silently stopped. From their save files I found the cause. The script for arriving at the second-year school runs an autosave and then advances the calendar a month. A manual save made later in that scene stored the new date. Loading it replays the scene from the autosave point, so the month advanced twice, and the one quest that only fires in the skipped window was gone for good. That is a vanilla bug, not the mod's. The fix used the replay idea again: when a manual save happens after the script has moved the clock, write the time as it was at the replay point.
What not to build
Most of my decisions were refusals. A pull request that rewrote a story script to remove a jealousy event was well made, and I declined it: the mod improves how you play the story, it does not change what the story is. I suggested the author publish it as a separate mod, and promised to keep Coffee Companion compatible with it.
The interface follows the same rule. I don't change the game's own UI, and I don't add mod UI to the game's screens. During story dialogue, for example, nothing from the mod stays pinned anywhere on screen, since that would break immersion, unless the player turns on something like the branch panel.
Another popular mod for the same game had features players liked. Looking at it was useful; copying it was not. When an early version of the story tree came back looking and working like theirs, I sent it back: same goal, but a structure of my own. The calendar-lane layout I ended up with is better for this game, because its quests are tied to dates. After one session where Claude fixed a layout bug and also brought in three of the other mod's extras on the side, the standing rule became: list what they do differently, then ask which to borrow.
Some features were simply wrong, and the cheapest move was to delete them. Markers on the map for one-off events looked fine in the spec and, in the game, were mostly invisible and occasionally misleading, so they went. A redesigned save screen went through several rounds of portraits cropped through the face before I reverted the part that would not come right and kept the rest. Each revert cost less than another round of patches.
Words for players
About a third of my corrections were about text, not code. Release notes say what changed, in one sentence, without the example a player reported and without a little selling point attached. Nothing from a player's report ever appears in public: one early release note quoted a real install path as an example, and that became a rule the same day. Traditional Chinese, Japanese and Korean are each written as their own text. A one-click Simplified-to-Traditional conversion produces wrong characters and word choices that Traditional Chinese readers notice immediately.
Each of these corrections went into Claude Code's persistent memory as a short rule with the reason attached: version bumps, what goes in which release file, never deleting old files from the cloud drive. By the end there were about two dozen rules, and I rarely had to say the same thing twice. That turned out to be the most valuable habit of the whole project. A correction made once and remembered is worth more than a smarter first draft.
3.0: an AI that looks things up
The headline of version 3.0 is an in-game AI. It works as a strategy assistant, and also as nine of the game's love interests plus the eldest senior brother, each speaking in their own voice. Players bring their own API key. The rule from the start was that it answers from the game, not from memory: search, quest, script, routes, usage and ten other tools all read the parsed scripts and the live save. Characters know only the story the player has actually read. Any change to the save is proposed as a card and applied when the player confirms it. It is deliberately not a role-play engine, so there is no long-term memory system and no anti-repetition rules; anything that does not tie a character more closely to the game's data was out of scope.
To find out whether it was right, I built a graded set of twenty real questions, with expected and forbidden phrases, and turned on a debug trace that logs every tool call and its result. On the first run with a mid-tier model it got fifteen. Reading the traces for the five failures was the most instructive hour of the project, because the model was rarely the problem:
- Retrieval ranking. Asked how to save a character who dies, the model searched the right name, but search listed only the first eight matching flags, unsorted. The one flag that mattered, "survived," was ninth. Sorting flags by how often the scripts use them fixed it.
- Missing names. Random events on the school map belonged to pools called
Section_01_01. Nobody searches for that, so a question about a temple event found nothing. Mapping pools to the place names players actually see fixed it. - Missing facts. How you "wake" a possessed character in a key fight was not in any data table. It lived in one decompiled class: each verbal attack while a certain status is active advances a counter. Once I added that line to the fight's description, the model could answer the question.
- The grader. One answer was correct but said "channelling qi" instead of the expected word. The fix there was to the test, not the model.
Only after those did I add prompt rules: list every route you found instead of the first one, and check the relevant flags before saying something is impossible. The stronger model in deep mode then scored eighteen of twenty.
Cost was the other half. Each question takes several rounds of lookups, and each round resends the whole conversation, so the prompt cache decides the bill. A cache is a contract: the prefix has to be byte-identical every time. That meant a fixed system prompt for each question, long histories compressed at stable points instead of trimmed every turn, and the model's own reasoning blocks passed back unchanged. Dropping those blocks had also been the cause of a bug where Claude sometimes replied with nothing at all, and other providers have their own versions of the same requirement. One remaining leak was the final round: when a question ran out of lookups, the forced answer dropped the tool definitions, and with them the entire cached prefix. Keeping the tools and forbidding calls fixed it. Across the latest run, 80 to 86 percent of input tokens were cache hits.
Later I added a proactive companion: one character stays in a corner of the screen and says a line or two after the player makes a choice, rolls the dice or finishes a fight. Most "desktop pet" style companion agents work from screenshots, handing the screen to a vision model every so often. I did not go that way. This one never looks at an image; it reads only what the game already has as data: dialogue, choices, dice results, and changes to stats and affinity. Images cost more tokens than text. Reading them is also slow, so by the time the line comes out the story has moved on. And screenshots are taken on a timer, so there is no way to know whether anything worth mentioning just happened. Reading game events lets code decide first whether to speak at all: which events are worth a remark, merging ones that come close together, skipping repeats, a cooldown after each line, and how much of the token budget is left for this launch. Only when all of that passes does the mod send one short request with no tools.
After launch: players I can't read
Once Korean-speaking and Traditional Chinese-speaking players found the mod, a new stream of feedback appeared, not on GitHub, Bilibili or the QQ group but in threads on the Korean forum DC Inside and the Traditional Chinese forums Bahamut and PTT, in languages I read slowly or not at all. So I built a small page that collects every post about the mod on those boards, gives each one a Chinese title and summary, sorts it into praise, problem, help request, guide or news, and checks for new posts every day. Most of the lessons in this section came out of that page. It also turned up a Korean player's translated fork of an earlier version, with about 320 downloads of its patch. That is good evidence that non-Chinese players want the mod, and a reminder of what a fork costs once upstream keeps moving.
"Gemini doesn't work." More than a dozen Korean posts said the AI would not connect: the connection test did nothing, sending a message did nothing, reinstalling did not help. Most blamed the free Gemini tier or a local Ollama model. In fact every provider was broken for those players. The mod built its requests with a Newtonsoft.Json overload, JToken.ToString(Formatting), that is missing from the copy of the library some players' setups load. The resulting MissingMethodException was swallowed before it reached the screen. Switching to an overload that exists in every version fixed all providers at once. In a mod, the player's install decides which version of your dependencies you run against, and when a failure is silent, users name it after whatever they changed last.
The model kept answering in Chinese. With the interface in English and a question asked in English, a heroine would still reply in Chinese, even on a strong model. The system prompt, the persona, the quoted game lines and the retrieved story data are all Chinese, and one rule saying "reply in the player's language" lost to thousands of tokens of context. Prompting alone never fixed it:
- A line in the middle of the rules: "reply in the player's language." No effect.
- Marking the part the player actually said with its own tag. That fixed a different bug, the model treating the choices on screen as the player's question, but the language stayed Chinese.
- The same requirement, written in the target language, at both the start of the system prompt and the end of the message. It sometimes held for questions that needed no lookups. As soon as the model fetched story data, which is all Chinese, it drifted back. A reminder placed after the fetched data did not help either.
- Rewriting the whole rule set in the interface language: Simplified Chinese, Traditional Chinese, English, Korean and Japanese, with the Traditional version written on its own rather than converted. Some answers still came back in Chinese, or with English stage directions around Chinese dialogue. The quoted game lines, the character's experiences and the retrieved data are still Chinese, and those cannot be translated away.
What finally made it reliable was a check in code. When the interface is English, Korean or Japanese and the player did not write in Chinese, but the answer is mostly Chinese characters, the mod sends one more request that only asks the model to rewrite that answer in the interface language. The request names the speaker and their gender, so pronouns come out right. A Traditional Chinese interface that gets an answer in Simplified Chinese is converted directly. While an answer is still streaming, text that is clearly Chinese is held back, so it never flashes on screen before the rewrite. The lookup steps shown during an answer, like "searching" or "reading a script", now follow the interface language too.
When the data is in one language and the output must be in another, a prompt cannot hold the line, even on a strong model. Checking the output in code and rewriting it when it is wrong is what made the result stable. A related lesson came from the same work. The interface splits an answer into two panels at a marker, and the model sometimes wrote the marker with the wrong brackets, so the split failed. Every variant is now normalised in code as the answer arrives. Anything the UI depends on structurally should be enforced in code; asking for it in the prompt is not enough.
Room for free tiers and small models. At first I decided free API keys and small local models were not worth special effort. I changed my mind, because many players have nothing else. Free Gemini queues and thinks for a long time, and small local models pick the wrong tool when they have fifteen to choose from and run out of context quickly. So there is now a fast mode:
- Fewer lookups: at most 6 rounds instead of 20, with only the 5 most used tools.
- Shorter prompts: a seven-rule strategy prompt, 10 quoted lines per persona instead of 30, and only the 20 most recent experiences.
- Less context: history and each lookup result are cut to about a third.
- Less thinking: reasoning effort set to none on Ollama. Gemini 3's thinking cannot be turned off, so it stays at low, as in standard mode.
The interface mattered as much as the limits. Fast and deep used to be two separate switches, and new players could not tell there were three modes. Now one row above the chat reads "Answer mode: Fast / Standard / Deep". The spoiler level and strategy tips moved into the same row, and every option explains itself on hover.
Presets come from the docs, not from memory. Every default model is checked against the provider's own documentation. Some OpenAI models can only call tools through a newer API than the one the mod speaks, so they are not offered as presets. Others need reasoning set to none to call tools at all. Google's newest Gemini is open only to paid keys, so it is not the default either; a free key gets a model that answers almost instantly. When a provider's model list could not confirm a name, the preset went back to one it could confirm.
Measure the text you actually draw. Tabs, version labels, titles and the suggested-question buttons were sized by measuring the Chinese source string, then drawn in English, so the English interface overflowed and got clipped. They now measure the translated string that will actually be shown, and the title and persona bars tighten their spacing when space runs short.
Diagnostic bundles. Both the installer and the in-game ESC menu can export diagnostics: the mod log, the BepInEx log, the game log, the config, the plugin list, and the game and system versions, packed into one zip. A player sends me that file, and I can look into the problem without touching their computer.
For one player, the mod loaded when the game was started by double-clicking Mortal.exe, but not when it was launched from Steam, and antivirus and file verification were both clean. The loader, Doorstop, sets an environment variable, DOORSTOP_DISABLE, inside the game process. If Steam was started by a modded game, steam.exe inherits that variable, and every game Steam launches after that quietly skips the loader. Setting ignore_disable_switch to true in the loader's config fixed it, and the installer now does that for existing installs too. Since then the installer's diagnostics include a loader check: which proxy DLLs the game actually loaded, which program started it, and the command line. A later error on an old version of the game was found through a diagnostic bundle as well: one field used a type that only exists in newer versions, so the whole class failed to load and the same error showed up in the log more than a thousand times.
Not just me anymore
A lot of the Korean localization was reworked together with Korean-speaking players. Untranslated strings in the Korean interface, character names, condition descriptions and terminology were all checked together, and Korean-speaking players send pull requests with the fixes themselves.
Many other players have opened pull requests on their own, adding features they wanted or improving existing ones. One built a floating memo window: you set a goal such as "meet this condition before a given year, month and ten-day turn in the game", for example a technique's training progress, an item, or someone's affinity, and the window shows the progress live and alerts you when the goal is met, when it slips back, or when the deadline is close. Another proposed choosing a branch before a check: when the story reaches a condition on stats, affinity or flags, it stops and lists each branch's condition, the current value, which part of the story it leads to and whether you have read that dialogue, and you pick the branch to take. Someone else reorganized the trigger conditions and links in the story map.
I usually merge these pull requests first and follow up myself. After merging I check whether the result matches what the game itself shows, whether it slows down the life-sim map, whether all five languages are filled in, and whether its style matches the other small windows. If something is off, I add another commit.
Working with an AI pair
A few things I would tell anyone starting a project like this:
- Keep every irreversible step for yourself. Commits, pushes, releases, replies, uploads. Claude once pushed when I had only asked for a commit; nothing broke, but that is exactly the kind of step that should wait for a yes.
- Turn corrections into rules. Say it once, have it written down with the reason, and expect it to hold.
- Make sure you can see what you are approving. My desktop client only showed the final message of a turn, so twice I was asked to approve a draft "below" that I could not see. The fix was a rule: drafts go in the final message.
- Know where automation does not belong. Letting a browser agent repeatedly edit a Steam community guide most likely tripped Steam's spam filter, and the guide could not be saved for a while. Now the files are prepared automatically and I paste them by hand.
- Read the data first. Logs, saves and traces settled more arguments than any amount of reasoning about what might be happening.
By now the mod has had 92 releases (the latest is 3.7.0) and 588 commits, with 130 stars on GitHub and about 40,000 downloads across all channels, in five interface languages. What I am proudest of is how few of those releases were caused by a mistake in the release before. The model brought the speed. The process kept it from turning into churn: one person in the game testing, a short list of things that always wait for approval, and every correction written down so it does not have to be made twice.