CapySR
A Honkai: Star Rail server reimplementation rewritten in C#.
Current version: CNBETAWin4.5.52
Goals: a full combat system including combat events, and srtools support. Currency Wars and Divergent Universe might be focused on in the far future.
Requirements
- .NET 10 SDK
protoc(only to regenerate the protocol)
Running
dotnet run --project src/CapySR.SdkServer # dispatch + sdk, port 21000
dotnet run --project src/CapySR.GameServer # kcp gateway, port 23301
Or just run.bat.
What works
- Teams: six squads, join/quit/swap/leader/rename/switch, virtual lineups for challenges, shared technique points (Phainon and Himeko Nova raise the cap), all remembered between runs.
- Overworld fights: hitting a monster resolves its own stage for your world level, the attacker's element breaks toughness on entry, ambushes work, destructible props break, and fodder-clearing techniques (Acheron, Phainon, Silver Wolf 999, Himeko Nova) skip the fight. Won fights remove the monsters; HP and energy carry over until you teleport.
- Calyxes, Stagnant Shadows / Caverns, Battle College (trial characters), story stages by event.
- Memory of Chaos, Pure Fiction, Apocalyptic Shadow with both nodes, scores, stars, records; Anomaly
Arbitration with saved mob teams, hard mode and settle screens. Every floor reports as cleared so
none sit locked behind the one before them; set
GameServer.UnlockAllChallengesto false to report only what has actually been played. - Position, paths, gender, head icon, server-side settings and challenge records persist in
data/player.json.
Chat commands
The friend list has one entry, CapySR. Message it:
| command | effect |
|---|---|
/help |
list the commands |
/tp <entryId> [teleportId] |
travel to a map entrance |
/unstuck |
respawn at the current map's anchor |
/heal |
full health and technique points |
/mp [n] |
set technique points |
/wl <0-6> |
set the equilibrium level (monsters scale with it) |
/stage <stageId> |
the next fight you start plays that stage |
/sync |
reload freesr-data.json now |
/lineup, /pos, /clear |
show the team, show where you are, clear the map |
srtools
Point srtools at http://127.0.0.1:21000/srtools and upload. The game server watches
data/freesr-data.json and pushes the new roster, gear and teams to a logged-in client without a relog.
GameServer.BattleSource in config/config.json decides what the uploaded battle_config drives:
| value | behaviour |
|---|---|
auto (default) |
every non-challenge fight plays the srtools battle |
srtools |
the same, and never falls back to the encounter's own stage |
stage |
everything plays its real stage |
So a calyx runs whatever stage freesr-data.json names. That is how an older Apocalyptic
Shadow, Pure Fiction or Memory of Chaos floor gets replayed, while F4 keeps the current
rotation. Challenges always play their own stage.
Hotfix URLs
For OS:
{
"OSBETAWin4.5.51": {
"asset_bundle_url": "https://autopatchos.starrails.com/asb/...",
"ex_resource_url": "https://autopatchos.starrails.com/design_data/...",
"lua_url": "https://autopatchos.starrails.com/lua/...",
"ifix_url": "https://autopatchos.starrails.com/ifix/..."
}
}
Tests
dotnet test tests/CapySR.Tests
FlowTests drive a real gateway end to end: login, team edits, an overworld fight, technique
points, and a two-node Memory of Chaos floor.
Regenerating the protocol
dotnet run --project tools/CapySR.ProtoGen
The generated protocol is committed, so this is only needed after a proto dump changes. Clone
TurnBaseGameProto next to the solution first;
game data (turnbasedgamedata, pearl-sr/resources) and the reference servers are separate
checkouts too and are not tracked here.
Reads TurnBaseGameProto/Raw/StarRail.proto, resolves the 11 duplicate type names the dump's
translation pass produces, runs protoc, and writes CmdId.g.cs / CmdIdTable.g.cs. Duplicate
resolution is scored against the CmdXxxType service enums and packetIds.txt; deliberate calls
live in DuplicateResolver.Overrides.
Credits
- capyb2222
- Various other server reimplementation.