Simulation: Gacha System (BETA)
Add randomized loot boxes, booster packs, and gacha pulls to your game. Players open packs to receive random rewards from weighted pools, with pity counters, rarity guarantees, and new-item bias, all validated server-side.
This is a self-contained recipe. Everything you need (config, client code, and patterns) is on this page.
Where Config Goes
All JSON config on this page is simulation config: server-authoritative state, actions, and rewards. The CLI uploads it automatically when you rundot deploy.
Recommended: rundot/simulation/
Place simulation config in the rundot/simulation/ directory, one file per system. Each file holds raw simulation content with no {"simulation": {...}} wrapper (the directory implies it). Files are deep-merged alphabetically at deploy time with collision detection.
my-game/
├── rundot/
│ └── simulation/
│ └── boosters.json ← raw content, no "simulation" wrapper
├── game.config.prod.json ← game ID + build settings only (separate)
└── package.jsonCommit
rundot/to your repo: it's project config likepackage.json, not a build artifact. It's env-agnostic and takes priority over legacyconfig.{local,staging}.json.game.config.prod.jsonis for CLI metadata only; simulation config does not go there.
Also supported: legacy config.json / config/
Legacy layouts keep working indefinitely. Run rundot migrate-config (with --dry-run to preview) to move them into rundot/simulation/ automatically.
What You'll Build
Booster packs that players open for randomized rewards
Weighted loot tables with rarity tiers (common → legendary)
A pity system that guarantees rare drops after N unlucky opens
Minimum rarity guarantees per pack tier
New-item bias so players are more likely to get items they don't own yet
Server-side resolution: the client never determines drop results
Server Configuration
Step 1: Define Pack Entities
Each pack type is an entity that tracks how many the player owns:
Step 2: Define Reward Entities
The items players can receive. Tag them by rarity so loot tables can filter:
Step 3: Define Pity Counter Entities
Track how many opens since the last high-rarity drop:
Step 4: Define Loot Tables
Loot tables are the pools the server draws from when a pack is opened.
Rarity pool tables: one per rarity tier, using tag-based filtering:
uniform tables automatically include all entities matching the tags. When you add a new rarity:common unit entity, it's automatically part of the common pool, no table edits needed.
Rarity selection tables: weighted roll to pick which pool, per pack tier:
Each entry uses tableRef to chain into a rarity pool. Weights determine the odds of rolling each rarity. For common_pack_cards: 75% common, 20% rare, 4.5% epic, 0.5% legendary.
Bonus coin tables: guaranteed currency alongside card drops:
Step 5: Define Pack-Opening Recipes
Each recipe consumes 1 pack and rolls from the appropriate loot tables:
How Rolls Work
Each roll entry:
table: Which loot table to draw fromcount: How many draws.{ "min": 3, "max": 5 }means 3–5 random draws.guarantees: After all random draws, if the results don't include at leastminCountitems with the specified tag, extra draws are forced. E.g.,{ "tag": "rarity:rare", "minCount": 1 }ensures at least one rare in every rare pack.pity: IncrementscounterEntityeach time the pack is opened. When the counter reachesthreshold, the next roll guarantees an item withguaranteedTag.resetOnHit: trueresets the counter when the guaranteed rarity drops naturally (before hitting the threshold).
How New-Item Bias Works
When newItemBias.enabled is true, items the player doesn't own yet get their selection weight multiplied by biasMultiplier. A multiplier of 2.0 means unowned items are twice as likely to be selected. This helps new players build a collection quickly.
Client-Side Implementation
Step 1: Read Pack Inventory
Step 2: Subscribe to Pack Count Changes
Step 3: Open a Pack
The executeRecipeAsync response (ExecuteRecipeResponse) carries the open result:
success
boolean
Whether the open succeeded.
outputs
Record<string, number | string>
What the player was granted: entity ID to quantity. This is the rolled loot.
randomSeed
string
Server seed used to resolve the roll. Useful for provably-fair displays or replaying the open animation deterministically.
message
string
Failure reason when success is false.
Step 4: Display Results
After opening a pack, read updated state to show the player what they received:
Step 5: Check if Player Can Open
getRecipeRequirementsAsync takes a single Recipe object ({ recipeId, entity?, nonce?, batchAmount? }), not positional arguments. Use batchAmount to check whether the player can afford several opens at once.
Purchasing Packs
With Premium Currency (Wallet)
Free Booster on Cooldown
Grant a free pack every 4 hours:
The pack is granted immediately via beginEffects, while the 4-hour cooldown runs. The player can claim again after the cooldown expires.
Common Variations
Faction-Specific Packs
Use weighted loot tables with explicit entity entries for curated faction packs:
Wildcard Conversion
A small chance to replace a drop with a wildcard (trade-in) token:
When a drop triggers conversion, the player receives the wildcard entity instead of the original item. Higher rarities have higher conversion rates.
Curated Starter Pack
Fixed contents with no randomization:
Displaying Drop Rates
For legal compliance and player trust, you'll often need to show players the odds. Loot tables are server-only and never reach the client.
You have two ways to surface published rates on the client:
Option A: clientConfig passthrough. Anything under the clientConfig key in your simulation config passes through to the client unchanged. Mirror your published rates there:
Option B: hardcode the published rates in your game build. Keep the displayed odds in your client code and match them to the server loot tables when you deploy. Simplest to ship, but you must keep both in sync by hand.
Best Practices
All randomization happens server-side: the client never determines drop results.
Use
uniform(tag-filtered) tables for pools that grow over time. New entities with matching tags are automatically included.Use
weightedtables when you need explicit control over individual item probabilities.Chain tables with
tableRefto separate "which rarity" from "which item within that rarity."Implement a pity system for high-rarity items to prevent frustrating dry streaks.
Set
newItemBiasto help new players build collections faster.Display drop rates to players. Loot tables are server-only, so surface published odds through the
clientConfigpassthrough ongetConfigAsync()or hardcode them in your build (see "Displaying Drop Rates").Use
beginEffectsfor free-booster cooldowns so the pack is granted instantly while the timer runs.
Last updated