# Features

### Lobby System

#### Creating a Lobby

The lobby creator can configure all parameters: arena, game mode, weapon, team size, target score, duration, and more. An optional password can be set to make the lobby private.

#### Quick Play

Players can join a quick play queue. The system automatically creates a lobby when enough players are waiting, using the default settings.

#### Auto-Start

When `autoStart` is enabled, the match starts automatically as soon as the lobby is full and all players are ready. Otherwise, only the creator can start the match.

{% hint style="info" %}
A minimum of **2 players** is required to start a match.
{% endhint %}

***

### Combat System

#### Hit Detection

Hit detection is validated server-side with multiple checks:

1. The player is actually in a match
2. Both the victim and attacker are valid
3. The weapon used is correct for the mode
4. The distance is less than `MaxHitDistance` (65 units)
5. The hit cooldown is respected (1200ms)
6. Friendly fire rules are respected
7. Spawn protection is checked
8. Headshot is detected via the bone hit

#### Spawn Protection

After each respawn, the player receives **3 seconds** of protection (configurable) during which they cannot take damage. A visual effect indicates that protection is active.

#### Headshots

Headshots are automatically detected and award a **Headshot** medal. Headshots are tracked in the player's statistics.

***

### Medal System

Medals are awarded in real-time during matches with sound effects and visual popups.

| Medal         | Condition               |
| ------------- | ----------------------- |
| First Blood   | First kill of the match |
| Double Kill   | 2 kills within 4s       |
| Triple Kill   | 3 kills within 4s       |
| Multi Kill    | 4+ kills within 4s      |
| Killing Spree | 3 consecutive kills     |
| Rampage       | 5 consecutive kills     |
| Unstoppable   | 7 consecutive kills     |
| Headshot      | Kill with a headshot    |

Streaks are reset upon death. The multi-kill window is configurable via `Config.Medals.multiKillWindow`.

***

### Wager System

When enabled in the configuration, the lobby creator can set a wager amount.

**How it works:**

1. The creator sets the wager when creating the lobby
2. Each player who joins pays the wager (from cash or bank)
3. If a player doesn't have enough money, they cannot join
4. Winners split the pot
5. If the lobby is disbanded, all wagers are fully refunded

| Parameter   | Default value |
| ----------- | ------------- |
| Minimum bet | $100          |
| Maximum bet | $50,000       |
| Default bet | $500          |

***

### Spectator Mode

Players can spectate an ongoing match from the menu, or automatically enter spectator mode in Elimination after being eliminated.

**Two spectating modes:**

| Mode    | Description                                   |
| ------- | --------------------------------------------- |
| Freecam | Free camera with movement                     |
| Follow  | Camera attached to a player (cycle available) |

**Information displayed:**

* Name and team of the followed player
* Kills, deaths, points, and streak of the player

***

### Leaderboard

A persistent leaderboard stores each player's statistics:

| Statistic   | Description                 |
| ----------- | --------------------------- |
| Games       | Total matches played        |
| Wins        | Matches won                 |
| Points      | Total points scored         |
| Kills       | Total kills                 |
| Deaths      | Total deaths                |
| Headshots   | Total headshots             |
| Best streak | Longest kill streak         |
| Playtime    | Total time spent in matches |

The leaderboard displays the **Top 50** players, sorted by points. Data is cached server-side for 15 seconds for performance.

***

### MVP & Awards

At the end of each match, a results screen displays:

* **Result**: Victory / Defeat / Draw
* **MVP**: Player with the highest score (kills x2 + points - deaths)
* **Awards**:
  * Most Kills
  * Best K/D (best kill/death ratio)
  * Longest Streak
* **Scoreboard**: Full statistics for each player
* **Wager result**: Winnings or losses (if wagers are enabled)

***

### Team Uniforms

Each team has a distinct uniform applied automatically at the start of the match:

| Team | Color   |
| ---- | ------- |
| RED  | Red     |
| BLUE | Blue    |
| FFA  | Neutral |

Uniforms are defined by clothing components with male/female variants. The player's original appearance is saved and restored at the end of the match.

***

### Night Mode

When enabled in the lobby options, night mode reduces visibility in the arena by adding a darkness effect. Ideal for more tactical matches.

***

### Routing Buckets

Each match takes place in an isolated **routing bucket**, separating match players from the rest of the server. Spectators are temporarily moved into the match's bucket while watching.

***

### Discord Webhook

When configured, a Discord embed is automatically sent at the end of each match containing:

* Game mode and arena
* Final score
* Match duration
* MVP and top players
* Detailed statistics
