In testing
Brewing, aging and intoxication
A brewing and aging system with designer-tuned probabilities, plus a blood-alcohol model that drives intoxication effects and police testing.
- Role
- Design and implementation
- Stack
- Lua (GLua)
- Context
- Crafting and economy on Diverge Networks’ roleplay server
- Status
- In testing
The problem
The server wanted alcohol to be something players make, not just buy: a barrel where your ingredients decide what you might get, aging that rewards patience, and drinking with consequences the police can test for. The recipes had to be tunable by the server’s designers without touching code.
Brewing
A base ingredient defines the possible results. Grapes, for example, can become red wine, white wine or vinegar, the bad outcome. Each extra ingredient adds weight to the results it shares with the base, and an ingredient that shares nothing pushes the brew toward the bad outcome. Sealing the barrel rolls a weighted result, ready after a set time.
Players see the possible results and their odds before they seal. Designers edit recipes in-game through a rank-gated configuration panel that validates every value.
Video coming soon
Placing the barrel, adding a base ingredient so the possible results appear, adding ingredients while the odds update, then sealing it and collecting the result.
assets/projects/brewing/brewing-seal.mp4 (30 to 45 seconds)
Screenshot coming soon
The brewing interface with ingredients in place and the odds visible.
assets/projects/brewing/brewing-ui.png (tight crop to the panel)
Aging
Each possible result of aging is a bell curve over time: when it peaks, how strong it gets, and how quickly it falls off. At any moment the curves give the odds of each result, and the configuration panel graphs them so a designer can see exactly what a 30-minute age will produce. Leave a drink too long and the vinegar curve takes over.
Video coming soon
The aging configuration panel with its graph, then one aging cycle.
assets/projects/brewing/aging.mp4 (about 15 seconds)
Screenshot coming soon
The aging configuration panel, hovering the graph.
assets/projects/brewing/aging-config.png (tight crop to the panel)
Code excerpt coming soon
The aging module: one bell curve per result, and a weighted roll with a floating-point safety net.
assets/excerpts/aging-curves.lua
Drinking and testing
Every character has a blood alcohol level from 0 to 100. Each drink adds 2.5 times the square root of its ABV, so strong drinks hit harder without scaling linearly: a beer adds about 6 to 8, wine 9 to 10, and a 40% cocktail 16. Intoxication effects scale with that level.
Alcohol clears from the system after 15 minutes and other substances after 30. Breathalyzers read actual drunkenness, and a new blood analyzer handles drug tests.
Video coming soon
A few drinks as the effects build, then a breathalyzer or blood analyzer test and its result.
assets/projects/brewing/intoxication.mp4 (15 to 20 seconds)
Screenshot coming soon
A blood analyzer or breathalyzer result.
assets/projects/brewing/analyzer-result.png (tight crop)
Keeping it server-authoritative
When a player seals a barrel, the client sends only the barrel’s ID. The server checks that it really is a brewing barrel, that this player is currently using it, and that every ingredient is valid and in a valid slot, then computes the result itself. The timer that pays out re-checks that the barrel and its state are still valid before delivering anything.
Code excerpt coming soon
The seal handler: everything validated on the server, the outcome rolled on the server.
assets/excerpts/brewing-seal.lua