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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["crates/funrounds-core", "crates/funrounds-plugin"]
resolver = "3"

[workspace.package]
version = "0.2.0-alpha.test"
version = "0.3.0-alpha.test.2"
edition = "2024"
rust-version = "1.99"
authors = ["Mai Ooizumi"]
Expand Down
241 changes: 133 additions & 108 deletions README.md

Large diffs are not rendered by default.

159 changes: 98 additions & 61 deletions README_EN.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,64 @@
# FunRounds-CS2

<div align="center">

# FunRounds-CS2

[![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL--3.0-blue.svg)](LICENSE)
[![Version](https://img.shields.io/badge/Version-0.2.0--alpha-informational.svg)](Cargo.toml)
[![Version](https://img.shields.io/badge/Version-0.3.0--alpha-informational.svg)](Cargo.toml)
[![Rust Version](https://img.shields.io/badge/Rust-1.99.1+-orange.svg)](rust-toolchain.toml)
[![Platform](https://img.shields.io/badge/Platform-Windows%20%7C%20Linux%20x64-lightgrey.svg)]()
[![Framework](https://img.shields.io/badge/Framework-Plugify%20%2B%20S2SDK%203.0.1-success.svg)](https://github.com/untrustedmodders/plugify)
[![Framework](https://img.shields.io/badge/Framework-Plugify%20%2B%20S2SDK%203.0.6-success.svg)](https://github.com/untrustedmodders/plugify)

**A high-performance, safe, and modular special rounds plugin for Counter-Strike 2 dedicated servers.**

[Bilingual (README.md)](README.md) • [English Only (README_EN.md)](README_EN.md) • [简体中文 (README_ZH.md)](README_ZH.md)
[English](README_EN.md) • [简体中文](README_ZH.md)

</div>

---

### Overview

**FunRounds-CS2** is a modern Counter-Strike 2 server plugin developed in Rust and native C++, built atop the [Plugify](https://github.com/untrustedmodders/plugify) framework and [S2SDK](https://github.com/untrustedmodders/plugify-plugin-s2sdk).
**FunRounds-CS2** is a modern Counter-Strike 2 server plugin developed in Rust and native C++20, built atop the [Plugify](https://github.com/untrustedmodders/plugify) framework and [S2SDK](https://github.com/untrustedmodders/plugify-plugin-s2sdk).

It revitalizes the classic "Fun Rounds" gameplay concept for Source 2. Each round (or upon administrative selection), the plugin seamlessly applies distinctive gameplay mutators—altering player attributes, loadouts, physics, combat rules, and bomb mechanics—while maintaining strict engine stability and zero-leak state restoration.
At the start of each round (or on administrative demand), it seamlessly applies multi-dimensional gameplay mutators—altering player attributes, physics, dynamic loadouts, recoil/camera mechanics, combat rules, chicken ecology, and bomb systems—with zero-leak state restoration and crash isolation.

---

### Key Features

- **Three-Tier Modular Architecture**:
- `funrounds-core`: Pure, engine-agnostic Rust library handling state machines, round queues, math, rules, `[defaults]` inheritance, and strictly validated TOML configurations.
| Category | Description |
| :--- | :--- |
| **Attributes & Physics** | Health (1–10,000 or random range), armor/helmets, gravity scaling, speed multiplier, friction, auto-bunnyhopping, ground acceleration, ground reverse walking (`ground_reverse`), time scale (`time_scale`), and periodic speed/gravity oscillation. |
| **Visuals & Camera** | Third person camera (`third_person`), stealth ghost mode with breathing audio cues and distance awareness (`ghost`), night vision (`fr_nvg`), crosshair/radar hiding (`hide_hud`), model RGB tinting, translucency, and scope restrictions. |
| **Recoil & Knockback** | Weapon recoil self-push knockback (`fr_knock` supports ground and air modes), recoil & spread suppression, view-punch intensity/decay (`recoil_view` / `view_punch_decay`), fast switch (`fast_switch`), and shooting dropped grenades. |
| **Loadouts & Ammunition** | Team-specific weapon clearing and granting, 4 ammo modes (inherit / reserve / clip / single-shot), taser recharge intervals, automatic grenade replenishment (HE/flash/smoke/decoy/molotov), kill progression (`kill_loadout`), and random draws. |
| **Combat Modifiers** | Vampiric lifesteal, reflect damage (`reflect_damage`), HP-scaled damage/speed/decay, energy absorption shield, miss penalty self-damage, decoy dodgeball collisions (`dodgeball`), throwing knives with bouncing, and afterburn damage. |
| **C4 Objectives & Suicide** | 3 bomb types (native, chicken, carry), custom timers, bomb bouncing, 4-color wire cutting minigame (`fr_wire`), C4 cash purchasing (`fr_c4`), and C4 suicide explosions (`fr_suicide`). |
| **Chicken & Healthshots** | Chicken population scaling, eating chickens with digestion risk & chain explosions; custom healthshot healing ratios with cash purchase (`fr_healthshot`). |
| **Economy & i18n** | Buy anywhere, team purchase access, round money floor, passive income; built-in bilingual i18n (`zh-CN` / `en`) automatically matching client language. |

<details>
<summary><b>Click to expand Architecture & Reliability</b></summary>

- **Three-Tier Architecture**:
- `funrounds-core`: Pure, engine-independent Rust library handling state machines, round queues, math, rules, `[defaults]` template inheritance, and strictly validated TOML configurations.
- `funrounds-plugin`: Native Plugify Rust plugin interacting safely with the CS2 engine on the game thread via S2SDK.
- `funrounds-native`: Native C++ companion module handling low-level engine hooks, entity collision, projectile touch detection, and gamedata offsets.
- **Rich Round Mutators**:
- **Player Physics & Attributes**: Configurable health (up to 10,000), armor/helmets, gravity scaling, speed multiplier, player RGB tint, auto-bunnyhop, dynamic over-health decay, and periodic gravity/speed oscillation.
- **Recoil & Knockback**: Custom weapon recoil view-punch, view-punch decay, recoil/spread suppression, scope restriction, custom FOV, delayed crosshair hiding, and shooting self-push / knockback physics (`fr_knock`).
- **Weapons & Dynamic Loadouts**: Whitelisted CS2 weapons, infinite reserve/clip/single-shot ammo, taser recharge timers, automatic grenade replenishment (HE & Decoy), team-based weapon distribution/clearing, independent random loadouts, and kill-streak weapon progression.
- **Combat Modifiers**: Vampiric lifesteal, headshot restrictions, damage/speed scaling by player HP, decoy dodgeball physics, and throwing knives with bouncing mechanics.
- **Custom C4 / Bomb & Suicide Mechanics**: Support for native bombs, chicken-carried bombs, portable carry bombs, custom plant/explode/defuse timers, bouncing bomb physics, C4 purchasing (`fr_c4`), and C4 suicide explosions (`fr_suicide`).
- **Respawns & Server Rule Overrides**: Round-start and delayed team respawns, plus per-mode overrides for buy time, cash limits, friendly fire scaling, and random spawn points.
- **Fail-Safe & Fault-Tolerant Design**:
- `funrounds-native`: Native C++20 companion module handling low-level engine hooks, entity collision, projectile touch detection, chicken interactions, ghost radar occlusion, and gamedata offsets.
- **Strict Fault Isolation**:
- **FFI Panic Containment**: All engine callbacks wrap in `catch_unwind` at the C ABI boundary to prevent server crashes.
- **Transactional State Restoration**: Tracks player/round generations to guarantee only hijacked properties and ConVars are restored without corrupting native server settings.
- **Dynamic Capability Quarantine**: Automatically excludes modes requiring missing SDK hooks or engine features without impacting other modes.
</details>

---

### Project Layout

```text
├── bindings/ # Plugify S2SDK provider bindings (123 methods)
├── config/ # Reference configurations (funrounds.example.toml)
├── config/ # Reference configurations and i18n catalogs
│ ├── funrounds.example.toml # Reference configuration
│ └── i18n/ # Localization files (zh-CN.toml, en.toml)
├── crates/
│ ├── funrounds-core/ # Engine-independent gameplay logic, rules & config parser
│ └── funrounds-plugin/ # Native Plugify runtime plugin implementation
Expand All @@ -55,22 +69,28 @@ It revitalizes the classic "Fun Rounds" gameplay concept for Source 2. Each roun
└── rust-toolchain.toml # Fixed toolchain configuration (Rust 1.99.1)
```

---

### Installation

#### Prerequisites

- Counter-Strike 2 Dedicated Server (Windows x64 or Linux x64)
- [Plugify](https://github.com/untrustedmodders/plugify) installed on your CS2 server
- [S2SDK](https://github.com/untrustedmodders/plugify-plugin-s2sdk) plugin (version `3.0.1`) active in Plugify
- [Plugify](https://github.com/untrustedmodders/plugify) installed and active on your CS2 server
- [S2SDK](https://github.com/untrustedmodders/plugify-plugin-s2sdk) plugin (version `3.0.6`) active in Plugify

#### Deployment

Copy the built artifacts to the server's `game/csgo/addons/plugify/` directory:
Copy compiled binaries and configurations to the server's `game/csgo/addons/plugify/` directory:

```text
game/csgo/addons/plugify/
├── configs/
│ └── funrounds.toml # Copied from config/funrounds.example.toml
│ ├── funrounds.toml # Copied from config/funrounds.example.toml
│ └── funrounds/
│ └── i18n/ # Copy catalogs from config/i18n/
│ ├── zh-CN.toml
│ └── en.toml
└── envs/
├── funrounds/ # Main Rust Plugin
│ ├── bin/
Expand All @@ -84,6 +104,36 @@ game/csgo/addons/plugify/
└── funrounds-native.jsonc # Gamedata offsets
```

---

### Commands Reference

#### Server & Administrator Commands (Console / RCON)

| Command | Arguments | Description |
| :--- | :--- | :--- |
| `fr_status` | None | Displays current mode, phase, engine capabilities, and fault diagnoses. |
| `fr_list` | None | Lists all loaded and enabled round modes in the pool. |
| `fr_next` | `<id \| random>` | Queues a specific mode ID or random mode for the next round. |
| `fr_reload` | None | Validates and schedules configuration and i18n reload for the next round. |
| `fr_enable` | `<0 \| 1>` | Master switch: disables (`0`) or enables (`1`) the plugin. |

#### Player Commands (Console & Chat)

| Console Command | Chat Alias | Arguments | Description |
| :--- | :--- | :--- | :--- |
| `fr_info` | `!info` / `!frinfo` | None | Displays the current round mode, ID, and description in chat. |
| `fr_help` | `!help` / `!frhelp` | None | Displays available player commands and usage instructions. |
| `fr_knock` | `!knock` | `[0\|1\|2]` | Sets or cycles shooting self-push (`0`: off, `1`: ground & air, `2`: airborne only [default]; cycle without args). |
| `fr_c4` | `!c4` | None | Purchases an extra C4 at the configured price when allowed. |
| `fr_suicide` | `!suicide` | None | Triggers a suicide explosion with held or purchased C4 when allowed. |
| `fr_chicken` | `!chicken` | None | Buys an ordinary chicken at the configured price. |
| `fr_healthshot` | `!healthshot` | None | Buys a healthshot at the configured price. |
| `fr_nvg` | `!nvg` | None | Toggles night vision. |
| `fr_wire` | `!wire` | `<color>` | Selects planting or quick-defusing wire color (`blue`, `yellow`, `red`, `green`). |

---

### Configuration

The configuration uses strict TOML format with support for global `[defaults]` template inheritance:
Expand All @@ -92,6 +142,10 @@ The configuration uses strict TOML format with support for global `[defaults]` t
# Top-level settings
diagnostics = false # Diagnostic logging (default: false)

# Internationalization
[i18n]
default_language = "en" # Server default language ("zh-CN" or "en")

# Global default template (mode-level fields take precedence)
[defaults]
gravity = 1.0
Expand All @@ -100,58 +154,41 @@ bunnyhop = false
[[modes]]
id = "example" # Unique mode identifier (ASCII, alphanumeric, '_' or '-')
enabled = true # Whether this mode enters the round pool
name = "Scout Jump" # Display name
description = "Low gravity sniper battle"
weapons = ["weapon_ssg08", "weapon_glock"]
name_key = "mode.example.name" # Localized name key
description_key = "mode.example.description" # Localized description key
weapons = ["weapon_famas", "weapon_p250"]

# Team loadout control
clear_weapons = "all" # Team to clear weapons before granting (none / all / terrorists / counter_terrorists)
give_weapons = "all" # Team to receive candidates
give_knife = "all" # Team to receive knife

# Attributes & movement
health = 100 # Initial health (1-10000)
armor = 100 # Initial armor (0-255)
gravity = 0.5 # Gravity multiplier (0.0 < g <= 10.0)
speed = 1.0 # Speed multiplier
bunnyhop = true # Auto-bunnyhopping
health = 120 # Initial health (1-10000, or random range { min = 100, max = 150 })
armor = 50 # Initial armor (0-255, or random range { min = 0, max = 100 })
gravity = 1.0 # Gravity multiplier ((0, 10], 1.0 is normal gravity)
speed = 1.0 # Speed multiplier ((0, 10])
self_push = true # Weapon recoil self-push

# Recoil & view
no_spread_recoil = false # Suppress spread and recoil
recoil_view = 2.0 # Recoil view-punch intensity
view_punch_decay = 5.0 # View-punch decay

# Combat & ammo
ammo = "reserve" # Ammo mode (inherit / reserve / clip / single_shot)
lifesteal = false # Vampiric lifesteal
health_damage = false # Scale damage with current attacker HP

# Optional Bomb Rules (Native, Chicken, or Carry)
# bomb = { kind = "native", plant_time = 3.0, explode_time = 45.0, defuse_kit_time = 5.0, defuse_time = 10.0, bounce = false }
headshots = "normal" # Headshot rule (normal / only / disabled)
fast_switch = true # Fast weapon switch

# Optional mutators
# lifesteal = true # Vampiric lifesteal
# suicide = true # Suicide blast gameplay
# third_person = { distance = 64.0, follow_eyes = true, return_strength = 2.0 }
# bomb = { kind = "native", plant_time = 3.0, explode_time = 45.0, bounce = false }
```

### Commands Reference
<details>
<summary><b>View Full Configuration Reference</b></summary>

#### Server & Administrator Commands (Console / RCON)
Refer to [config/funrounds.example.toml](config/funrounds.example.toml) for full documentation of chicken ecology, health curves, ghost stealth, custom bombs, and economy rules.
</details>

| Command | Arguments | Description |
| :--- | :--- | :--- |
| `fr_status` | None | Displays current mode, phase, engine capabilities, and fault diagnoses. |
| `fr_list` | None | Lists all loaded and enabled round modes in the pool. |
| `fr_next` | `<id \| random>` | Queues a specific mode ID or random mode for the next round. |
| `fr_reload` | None | Validates and schedules configuration reload for the next round. |
| `fr_enable` | `<0 \| 1>` | Master switch: disables (`0`) or enables (`1`) the plugin. |

#### Player Commands (Console & Chat)

| Console Command | Chat Alias | Arguments | Description |
| :--- | :--- | :--- | :--- |
| `fr_info` | `!frinfo` | None | Displays the current round mode, ID, and description in chat. |
| `fr_help` | `!frhelp` | None | Displays available player commands and usage instructions. |
| `fr_knock` | `!knock` | `[0\|1\|2]` | Sets or cycles shooting self-push (`0`: off, `1`: ground & air, `2`: airborne only [default]; cycle without args). |
| `fr_c4` | `!c4` | None | Purchases an extra C4 for $10,000 when allowed by mode (`c4_buy`). |
| `fr_suicide` | `!suicide` | None | Triggers a suicide explosion with held or purchased C4 when allowed. |
---

### Building from Source

Expand All @@ -164,7 +201,7 @@ Requires Rust `1.99.1` (automatically managed by `rust-toolchain.toml`):
cargo fmt --all -- --check
cargo clippy --workspace --all-targets --locked -- -D warnings

# Execute test suite (119+ unit tests)
# Execute test suite
cargo test --workspace --locked

# Build optimized release binaries
Expand Down
Loading