Proximity chat for modders

Proximity chat lets players in a Cosmic Helm voice bay hear the people near them in a game, louder the closer they are. Cosmic Helm does the voice and the hearing. The game only needs a Cosmic Helm-compatible mod or plugin on its server that sends where each player is. Cosmic Helm doesn’t make these mods: server owners and modders build and share their own. This page is everything a mod needs.

How it fits together

  1. A crew owner turns Proximity chat on for a voice bay in that bay’s settings, picks the game and presses Generate key. Each bay with Proximity chat has its own key (it starts with chgs_), so one crew can run several games at once. The key is shown once; resetting it stops the old one at once.
  2. The server owner puts the key in your mod’s config, with the address https://cosmichelm.com (let people change it).
  3. Your mod connects: it calls GET /api/game/hello with the key, then sends player positions several times a second while anyone is online.
  4. Players link their character: they type your link command in the game, your mod asks Cosmic Helm for a 6-character code and shows it, and they enter it in Cosmic Helm under Settings → Linked games. From then on their voice in the bay follows their character.

The calls

Every call sends the bay’s key: Authorization: Bearer chgs_…. JSON in, JSON out.

CallBody or queryAnswer
GET /api/game/hellonone{ server, game, game_name, unit, bay, range, lobby, max_players, per_second }: which bay the key belongs to and its limits. Log “Connected” when it answers 200.
POST /api/game/positions{ players: [{ playerUid, x, y, z, dimension }] }{ ok, players, listeners }
POST /api/game/link{ playerUid, playerName }{ code, expires_in }: a 6-character code (10 minutes) to show the player
POST /api/game/unlink{ playerUid }{ ok }
GET /api/game/status?playerUid=none{ linked, account, bay, in_voice, hearing, range, lobby, server }, for a status command

Positions

Limits

Errors

Errors are { error: "plain words" } with a status:

On network errors, wait longer after each failure (1 second, then longer, up to 30 seconds) and log once. Never make the game wait for Cosmic Helm.

Privacy and safety

Send only player ids, names (for the link code) and positions. Never chat, IP addresses or anything else. Keep the key out of logs.

An example

A server-side mod for Vintage Story was written as an example. This is its loop, in short (C#): about 4 times a second it sends everyone online.

// every 250 ms, on the server
var players = sapi.World.AllOnlinePlayers.OfType<IServerPlayer>().Select(p => new {
    playerUid = p.PlayerUID,
    x = p.Entity.Pos.X, y = p.Entity.Pos.Y, z = p.Entity.Pos.Z,
    dimension = p.Entity.Pos.Dimension
});
var req = new HttpRequestMessage(HttpMethod.Post, endpoint + "/api/game/positions");
req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", key);
req.Content = JsonContent.Create(new { players });
var res = await http.SendAsync(req);   // 401: stop; 429: slow down; network error: back off

Its link command calls POST /api/game/link and shows the code in the game’s chat. The config holds the key and the address:

{ "Key": "chgs_…", "Endpoint": "https://cosmichelm.com" }

What players see

Once your mod is connected, the bay’s settings show Connected, and people in the bay who have linked their character hear each other by distance. Everyone else in the bay hears as in a normal voice bay.