Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
139 changes: 139 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: CI

on: [push, pull_request, workflow_dispatch]

jobs:
translations:
name: Translations
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: srcdslab/smtranslate@v1
with:
# Set the TRANSLATIONS_FAIL_ON repository variable to "warning" to make warnings blocking
fail-on: ${{ vars.TRANSLATIONS_FAIL_ON || 'error' }}

build:
name: Build (SM ${{ matrix.sm-label }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- sm-version: "1.12.x"
sm-label: "1.12"
# Pinned to 1.13.0.7427, the build our servers run (2026-11-11),
# not the latest 1.13 snapshot. setup-sp names it "1.13.7427".
- sm-version: "1.13.7427"
sm-label: "1.13"
steps:
- uses: actions/checkout@v7

- name: Setup SourcePawn compiler
uses: rumblefrog/setup-sp@v1.3.1
with:
version: ${{ matrix.sm-version }}
github-token: ${{ secrets.GITHUB_TOKEN }}

# Compile-time includes only: GunGame and VIP-Core are optional at run time.
# CustomChatColors is not needed (only its library name is checked, see README).
- name: Fetch dependencies
run: |
set -euo pipefail
git clone --depth=1 https://github.com/srcdslab/sm-plugin-GunGame.git deps/gungame
git clone --depth=1 https://github.com/srcdslab/sm-plugin-MultiColors.git deps/multicolors
git clone --depth=1 https://github.com/srcdslab/sm-plugin-VIP-Core.git deps/vip-core
cp deps/gungame/addons/sourcemod/scripting/include/gungame.inc addons/sourcemod/scripting/include/
cp -R deps/multicolors/addons/sourcemod/scripting/include/* addons/sourcemod/scripting/include/
cp deps/vip-core/addons/sourcemod/scripting/include/vip_core.inc addons/sourcemod/scripting/include/

- name: Build sourcemod plugin
working-directory: addons/sourcemod/scripting
run: |
set -euo pipefail
mkdir -p ../plugins
spcomp -E -i include -o ../plugins/GunGameProgression.smx GunGameProgression.sp

- name: Create package
run: |
set -euo pipefail
mkdir -p /tmp/package/addons/sourcemod/plugins /tmp/package/addons/sourcemod/scripting/include
cp addons/sourcemod/plugins/*.smx /tmp/package/addons/sourcemod/plugins/
cp -R addons/sourcemod/configs addons/sourcemod/translations /tmp/package/addons/sourcemod/
# API include for companion plugins (winner MOTD...)
cp addons/sourcemod/scripting/include/gungame_progression.inc /tmp/package/addons/sourcemod/scripting/include/

- name: Upload build archive for test runners
uses: actions/upload-artifact@v7
with:
name: package-sm${{ matrix.sm-label }}
path: /tmp/package

tag:
name: Tag
needs: [translations, build]
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- name: Delete existing "latest" release and tag
run: |
set -euo pipefail
gh release delete latest --cleanup-tag --yes || true
# The tag may exist without a release, so delete it explicitly
git push origin :refs/tags/latest || true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: rickstaa/action-create-tag@v1
with:
tag: latest
github_token: ${{ secrets.GITHUB_TOKEN }}

release:
name: Release
needs: [translations, build, tag]
if: |
always() &&
needs.translations.result == 'success' &&
needs.build.result == 'success' &&
(needs.tag.result == 'success' || needs.tag.result == 'skipped') &&
(startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v8
with:
pattern: package-sm*
path: artifacts

- name: Versioning
run: |
set -euo pipefail
version="latest"
if [[ "${{ github.ref_type }}" == "tag" ]]; then
version="${GITHUB_REF_NAME}"
fi
echo "RELEASE_VERSION=$version" >> "$GITHUB_ENV"

# One archive per SourceMod version:
# <repo>-<version>-sm1.12.tar.gz and <repo>-<version>-sm1.13.tar.gz
- name: Package
run: |
set -euo pipefail
for dir in artifacts/package-sm*/; do
label="$(basename "$dir")"
label="${label#package-}"
tar -czf "${{ github.event.repository.name }}-${{ env.RELEASE_VERSION }}-${label}.tar.gz" -C "$dir" .
done
ls -l *.tar.gz

- name: Release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: "*.tar.gz"
tag: ${{ env.RELEASE_VERSION }}
file_glob: true
overwrite: true
24 changes: 24 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Dependabot auto-merge

on:
pull_request_target:
branches:
- master
- main
types:
- opened

permissions:
pull-requests: write
contents: write

jobs:
enableAutoMerge:
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'dependabot[bot]'
steps:
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
build/
release/

.DS_Store
.vscode

*.smx
plugins/
.venv
214 changes: 214 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,217 @@

SourceMod plugin for Counter-Strike: Source GunGame servers that adds long-term progression:
players earn XP by playing GunGame, climb 50 ranks and unlock cosmetics as they rank up: a chat
tag, a trail, a color for their HE grenades and a kill effect.

There is no currency and nothing to buy: every unlock comes from playing, and no unlock changes
the gameplay (no damage, health, speed, weapon or visibility advantage). The optional VIP
multiplier only speeds up the progression.

Written for the [srcdslab GunGame:SM fork](https://github.com/srcdslab/sm-plugin-GunGame) (2.0.x),
whose forwards and natives it uses. Pure SourcePawn, no extension, no gamedata. Every material
and sound comes with the game: clients download nothing.

## How it works

### XP

| Source | Default | Cvar |
| - | - | - |
| Kill (bots count as victims) | 10 | `sm_ggp_xp_kill` |
| Headshot kill, on top of the kill | +5 | `sm_ggp_xp_headshot` |
| GunGame knife steal, on top of the kill | +15 | `sm_ggp_xp_knifesteal` |
| GunGame level gained by a kill or a knife steal, per level | 5 | `sm_ggp_xp_levelup` |
| Match win | 200 | `sm_ggp_xp_win` |
| End of match placement 1st / 2nd / 3rd (GunGame ranking by level, bots included) | 75 / 50 / 25 | `sm_ggp_xp_place1..3` |
| Each full minute on T or CT during the match | 5 | `sm_ggp_xp_playtime` |
| Participation: on T or CT at the end of the match, after 3 minutes on a team | 20 | `sm_ggp_xp_participation`, `sm_ggp_participation_time` |

- Bots never earn XP, but killing a bot gives XP (the server is mostly bots).
- No XP while the GunGame warmup runs, before the match starts, after it ended, or when GunGame
is not loaded or disabled (`gungame_enabled 0`). Cosmetics keep working at all times.
- Handicap, reconnect, admin and native GunGame levels give no level XP. Team kills give nothing,
except in GunGame FFA mode.
- The match ends with the GunGame winner (`GG_OnWinner`), or with the time limit
(`cs_win_panel_match`) when nobody won: there is no win XP then, but placement and
participation XP are still given.
- VIP players (VIP-Core, optional) get `sm_ggp_vip_multiplier` times the XP (1.25 by default).
- At the end of the match, every player gets a summary: XP earned in the match, rank, XP left to
the next rank and the next unlock.

### Ranks

50 ranks with generic military names (Recruit, Private I-III, ..., General, Field Marshal, Hero,
Champion, Legend), defined in the config with the total XP each one needs. The default curve is
`xp(rank) = 100 * (rank - 1) ^ 2.1`: with about 350 XP per 10 minutes of play, a regular player
reaches rank 10 after about 5 hours and rank 50 after about 170 hours (150 to 200 hours between
400 and 300 XP per 10 minutes). The details are in the config file.

A rank up is announced in chat to everyone, with a sound and the list of new unlocks for the player.

### Cosmetics

| Category | What it does |
| - | - |
| Chat tag | `[Tag]` before the name in chat, in the tag color. By default the current rank name, or the name of any rank already reached, a special tag of the config, or no tag. See [Chat tags and CustomChatColors](#chat-tags-and-customchatcolors). |
| Trail | `env_spritetrail` parented to the player. Created on spawn, removed on death, team change and disconnect: never on spectators or dead players. |
| HE grenade color | The thrown `hegrenade_projectile` gets the item color, plus a beam that follows it in the same color. |
| Kill effect | A small temp entity effect where the victim dies: sparks, energy splash, colored shockwave ring, lightning strike from the ceiling (or 400 units above), confetti (5 short colored tracers) or a glow. |

Kill effects are limited to `sm_ggp_kill_effects_cooldown` seconds per player and
`sm_ggp_kill_effects_max` effects per second on the whole server, and are only sent to the players
who can see the spot. The heaviest effect is 5 temp entities.

Trail materials are stock CS:S sprites. The default config uses `sprites/laserbeam`, `bluelaser1`,
`physbeam`, `purplelaser1`, `crystal_beam1`, `xbeam2`, `plasmabeam` and `lgtning`, all listed in
`hl2/hl2_misc_dir.vpk` (vmt) and `hl2/hl2_textures_dir.vpk` (vtf) of the current CS:S install. Only use
materials that ship with the game, or clients see missing textures.

### Persistence

Data is saved in the `databases.cfg` entry of `sm_ggp_database` (`gungame` by default, the
SQLite entry GunGame stats already uses), in its own `ggp_players` table, keyed by the Steam
account ID. MySQL works too. Clients without a Steam account ID (some NoSteam clients) have no
progression. Players are loaded after the admin check, and saved every 60 seconds (only if
something changed), on disconnect, at map end and at match end. Every query is threaded. If the
database cannot be reached, the error is logged once and the connection is retried every minute.

| Column | Content |
| - | - |
| `account_id` | Steam account ID (primary key) |
| `name` | Last name seen |
| `xp` | Total XP |
| `tag`, `trail`, `he_color`, `kill_effect` | Equipped item keys (`tag`: empty = current rank, `none`, `rank:N` or a tag key) |
| `last_seen` | Unix time of the last save |

## Chat tags and CustomChatColors

Without [CustomChatColors](https://github.com/srcdslab/sm-plugin-CustomChatColors) (CCC), the
plugin adds the tag itself: CS:S sends the chat line as one `SayText2` user message per recipient.
For a player with a tag, these messages are blocked and sent again on the next frame to the same
recipients, with the same message name and parameters (so the dead / team / location prefixes and
the language of each client stay right); only the name parameter becomes `[Tag] Name`.

With CCC loaded (`ccc` library), the plugin never touches the chat user messages: CCC already blocks
every chat `SayText2` and sends its own line (with `USERMSG_BLOCKHOOKS`), so rebuilding lines too would
print each one twice. Instead, CCC 8.2.0 and newer call the `CCC_OnSenderPrefix` forward while they build
the sender name of a chat line, for every author (CCC flags or not), and the plugin returns the tag there:
`[Tag]` comes before the name and before the player's own CCC tag (VIP tags...), which stays untouched and
is never saved with the rank tag. With an older CCC the forward is never called and no rank tag is shown.

## Requirements

- SourceMod 1.12 or newer (built for 1.12 and 1.13).
- [srcdslab/sm-plugin-GunGame](https://github.com/srcdslab/sm-plugin-GunGame) 2.0.x. Without
GunGame the plugin loads, but nobody earns XP.
- Optional: [srcdslab/sm-plugin-VIP-Core](https://github.com/srcdslab/sm-plugin-VIP-Core) for the
VIP multiplier.
- A `databases.cfg` entry (SQLite or MySQL).

## Installation

Extract the release archive matching your SourceMod version (`-sm1.12` or `-sm1.13`) into `cstrike/`:

- `addons/sourcemod/plugins/GunGameProgression.smx`
- `addons/sourcemod/configs/gungame_progression.cfg`
- `addons/sourcemod/translations/gungame_progression.phrases.txt`
- `addons/sourcemod/scripting/include/gungame_progression.inc` (only to build other plugins)

The config `cfg/sourcemod/plugin.GunGameProgression.cfg` is created on first load.

## Cvars

| Cvar | Default | Description |
| - | - | - |
| `sm_ggp_enable` | `1` | Enable XP gains (cosmetics keep working when disabled) |
| `sm_ggp_database` | `gungame` | `databases.cfg` entry used to store the progression (tables `ggp_*`) |
| `sm_ggp_xp_kill` | `10` | XP for a kill (bots included) |
| `sm_ggp_xp_headshot` | `5` | Extra XP when the kill is a headshot |
| `sm_ggp_xp_knifesteal` | `15` | Extra XP for a GunGame knife steal |
| `sm_ggp_xp_levelup` | `5` | XP per GunGame level gained by a kill or a knife steal |
| `sm_ggp_xp_win` | `200` | XP for winning the match |
| `sm_ggp_xp_place1` | `75` | XP for the 1st place at the end of the match (on top of the win XP) |
| `sm_ggp_xp_place2` | `50` | XP for the 2nd place |
| `sm_ggp_xp_place3` | `25` | XP for the 3rd place |
| `sm_ggp_xp_playtime` | `5` | XP per full minute spent on T or CT during the match |
| `sm_ggp_xp_participation` | `20` | XP at the end of the match for players on a team who played long enough |
| `sm_ggp_participation_time` | `180` | Seconds on T or CT during the match needed for the participation XP |
| `sm_ggp_vip_multiplier` | `1.25` | XP multiplier for VIP players (VIP-Core), `1.0` = none |
| `sm_ggp_chat_tags` | `1` | Show the chosen tag before the name in chat (only without CCC) |
| `sm_ggp_trails` | `1` | Enable player trails |
| `sm_ggp_he_colors` | `1` | Enable HE grenade colors |
| `sm_ggp_kill_effects` | `1` | Enable kill effects |
| `sm_ggp_kill_effects_cooldown` | `2.0` | Seconds before the kill effect of the same player can play again |
| `sm_ggp_kill_effects_max` | `4` | Most kill effects played per second on the whole server |
| `sm_ggp_rankup_sound` | `items/gift_pickup.wav` | Sound played to a player who ranks up (stock sound, empty = none) |

## Commands

| Command | Access | Description |
| - | - | - |
| `sm_xp`, `sm_progress`, `sm_cosmetics` | Everyone | Menu with the rank, XP, progress bar to the next rank, next unlock, and one submenu per cosmetic category (locked items are shown with the rank they need) |
| `sm_ggp_toprank` | Everyone | The 10 players with the most XP |
| `sm_ggp_givexp <target> <amount>` | Root | Give (or remove, with a negative amount) XP, for tests |
| `sm_ggp_reload` | Config | Reload `configs/gungame_progression.cfg` |

The GunGame commands (`rank`, `top`, `top10` from GunGame stats, `level`, `score`, `leader`...)
are left alone.

## Config

`addons/sourcemod/configs/gungame_progression.cfg`:

```
"GunGameProgression"
{
"ranks"
{
"1" { "name" "Recruit" "xp" "0" "color" "200 200 200" }
"2" { "name" "Private I" "xp" "100" "color" "200 200 200" }
}
"tags"
{
"veteran" { "name" "Veteran" "rank" "12" "text" "Veteran" "color" "139 195 74" }
}
"trails"
{
"laser_red" { "name" "Red laser" "rank" "5" "material" "materials/sprites/laserbeam.vmt" "color" "255 60 60" }
}
"he_colors"
{
"red" { "name" "Red" "rank" "4" "color" "255 40 40" }
}
"kill_effects"
{
"confetti" { "name" "Confetti" "rank" "23" "type" "confetti" "color" "random" }
}
}
```

- Ranks: `name`, `xp` (total XP needed, the lowest rank must need 0) and `color` (`R G B`, rank
tag color). Rank names are not translated.
- Every item needs `rank` (unlocked from that rank on) and a `name` (shown in menus, not
translated). The section name is the key saved in the database: renaming it unequips the item.
`none` and keys containing `:` are reserved.
- `tags`: `text` and `color`.
- `trails`: `material` (stock `.vmt`), `color`, `width` (1-16, default 6), `end_width` (0-16,
default 1), `lifetime` (0.1-3 seconds, default 1).
- `he_colors`: `color`.
- `kill_effects`: `type` (`sparks`, `energy`, `ring`, `lightning`, `confetti`, `glow`) and `color`
(`R G B` or `random`; sparks, energy and glow are not colored).

## API

`addons/sourcemod/scripting/include/gungame_progression.inc` (library `gungame_progression`):

```sourcepawn
native int GGP_GetClientXP(int client);
native int GGP_GetClientRank(int client);
native bool GGP_IsClientLoaded(int client);
native int GGP_GetRankCount();
native bool GGP_GetRankName(int rank, char[] buffer, int maxlen);
forward void GGP_OnClientRankUp(int client, int oldRank, int newRank);
```

## License

GPL-3.0, see [LICENSE](LICENSE).
Loading