Compare commits

...

57 Commits

Author SHA1 Message Date
MSWS
2351ec55ec Wonky fix for CS specific issues 2025-10-27 22:34:35 -07:00
MSWS
4af1be95f4 Working 2025-10-27 22:10:22 -07:00
MSWS
fdb22c1090 Try using logic relay 2025-10-27 21:50:19 -07:00
MSWS
ddc309927f Add context as well for now 2025-10-27 20:51:55 -07:00
MSWS
7b657b1595 Working gamedata method 2025-10-27 20:22:13 -07:00
MSWS
05eed34ffd Try gamedata approach 2025-10-27 19:44:38 -07:00
MSWS
707a967445 Use contexts 2025-10-27 19:10:31 -07:00
MSWS
d6c6562d32 Additional safety check 2025-10-27 17:31:59 -07:00
MSWS
64e9332fa6 Add safety checks to avoid stuck states 2025-10-27 17:23:33 -07:00
MSWS
536f0eafb5 Merge branch 'dev' of github.com:MSWS/TTT into dev 2025-10-27 17:08:08 -07:00
MSWS
3e513cb611 Enhanced debugging 2025-10-27 17:08:02 -07:00
MSWS
cba8470f09 Increment version +semver:minor 2025-10-26 23:17:08 -07:00
MSWS
275404582f Merge branch 'main' into dev 2025-10-26 23:16:34 -07:00
MSWS
76dc717a8b Add settarget debug 2025-10-26 20:16:32 -07:00
Isaac
ff8d4dfc7e fix: Dont afk enforce unalive players (#151) 2025-10-26 18:50:36 -07:00
MSWS
f63acf24c4 Dont afk enforce unalive players 2025-10-26 18:43:03 -07:00
Isaac
678b9b0de6 fix: Map changing causing bugs (#150) 2025-10-26 18:35:05 -07:00
MSWS
18144f5827 Merge branch 'dev' of github.com:MSWS/TTT into dev 2025-10-26 18:21:29 -07:00
MSWS
e590ae2b7a Register map change handlers 2025-10-26 18:21:22 -07:00
Isaac
6bc0f57bed Bump actions/upload-artifact from 4 to 5 (#148)
Bumps
[actions/upload-artifact](https://github.com/actions/upload-artifact)
from 4 to 5.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/actions/upload-artifact/releases">actions/upload-artifact's
releases</a>.</em></p>
<blockquote>
<h2>v5.0.0</h2>
<h2>What's Changed</h2>
<p><strong>BREAKING CHANGE:</strong> this update supports Node
<code>v24.x</code>. This is not a breaking change per-se but we're
treating it as such.</p>
<ul>
<li>Update README.md by <a
href="https://github.com/GhadimiR"><code>@​GhadimiR</code></a> in <a
href="https://redirect.github.com/actions/upload-artifact/pull/681">actions/upload-artifact#681</a></li>
<li>Update README.md by <a
href="https://github.com/nebuk89"><code>@​nebuk89</code></a> in <a
href="https://redirect.github.com/actions/upload-artifact/pull/712">actions/upload-artifact#712</a></li>
<li>Readme: spell out the first use of GHES by <a
href="https://github.com/danwkennedy"><code>@​danwkennedy</code></a> in
<a
href="https://redirect.github.com/actions/upload-artifact/pull/727">actions/upload-artifact#727</a></li>
<li>Update GHES guidance to include reference to Node 20 version by <a
href="https://github.com/patrikpolyak"><code>@​patrikpolyak</code></a>
in <a
href="https://redirect.github.com/actions/upload-artifact/pull/725">actions/upload-artifact#725</a></li>
<li>Bump <code>@actions/artifact</code> to <code>v4.0.0</code></li>
<li>Prepare <code>v5.0.0</code> by <a
href="https://github.com/danwkennedy"><code>@​danwkennedy</code></a> in
<a
href="https://redirect.github.com/actions/upload-artifact/pull/734">actions/upload-artifact#734</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/GhadimiR"><code>@​GhadimiR</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/upload-artifact/pull/681">actions/upload-artifact#681</a></li>
<li><a href="https://github.com/nebuk89"><code>@​nebuk89</code></a> made
their first contribution in <a
href="https://redirect.github.com/actions/upload-artifact/pull/712">actions/upload-artifact#712</a></li>
<li><a
href="https://github.com/danwkennedy"><code>@​danwkennedy</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/upload-artifact/pull/727">actions/upload-artifact#727</a></li>
<li><a
href="https://github.com/patrikpolyak"><code>@​patrikpolyak</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/upload-artifact/pull/725">actions/upload-artifact#725</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/upload-artifact/compare/v4...v5.0.0">https://github.com/actions/upload-artifact/compare/v4...v5.0.0</a></p>
<h2>v4.6.2</h2>
<h2>What's Changed</h2>
<ul>
<li>Update to use artifact 2.3.2 package &amp; prepare for new
upload-artifact release by <a
href="https://github.com/salmanmkc"><code>@​salmanmkc</code></a> in <a
href="https://redirect.github.com/actions/upload-artifact/pull/685">actions/upload-artifact#685</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/salmanmkc"><code>@​salmanmkc</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/upload-artifact/pull/685">actions/upload-artifact#685</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/upload-artifact/compare/v4...v4.6.2">https://github.com/actions/upload-artifact/compare/v4...v4.6.2</a></p>
<h2>v4.6.1</h2>
<h2>What's Changed</h2>
<ul>
<li>Update to use artifact 2.2.2 package by <a
href="https://github.com/yacaovsnc"><code>@​yacaovsnc</code></a> in <a
href="https://redirect.github.com/actions/upload-artifact/pull/673">actions/upload-artifact#673</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/upload-artifact/compare/v4...v4.6.1">https://github.com/actions/upload-artifact/compare/v4...v4.6.1</a></p>
<h2>v4.6.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Expose env vars to control concurrency and timeout by <a
href="https://github.com/yacaovsnc"><code>@​yacaovsnc</code></a> in <a
href="https://redirect.github.com/actions/upload-artifact/pull/662">actions/upload-artifact#662</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/upload-artifact/compare/v4...v4.6.0">https://github.com/actions/upload-artifact/compare/v4...v4.6.0</a></p>
<h2>v4.5.0</h2>
<h2>What's Changed</h2>
<ul>
<li>fix: deprecated <code>Node.js</code> version in action by <a
href="https://github.com/hamirmahal"><code>@​hamirmahal</code></a> in <a
href="https://redirect.github.com/actions/upload-artifact/pull/578">actions/upload-artifact#578</a></li>
<li>Add new <code>artifact-digest</code> output by <a
href="https://github.com/bdehamer"><code>@​bdehamer</code></a> in <a
href="https://redirect.github.com/actions/upload-artifact/pull/656">actions/upload-artifact#656</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/hamirmahal"><code>@​hamirmahal</code></a> made
their first contribution in <a
href="https://redirect.github.com/actions/upload-artifact/pull/578">actions/upload-artifact#578</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="330a01c490"><code>330a01c</code></a>
Merge pull request <a
href="https://redirect.github.com/actions/upload-artifact/issues/734">#734</a>
from actions/danwkennedy/prepare-5.0.0</li>
<li><a
href="03f2824452"><code>03f2824</code></a>
Update <code>github.dep.yml</code></li>
<li><a
href="905a1ecb59"><code>905a1ec</code></a>
Prepare <code>v5.0.0</code></li>
<li><a
href="2d9f9cdfa9"><code>2d9f9cd</code></a>
Merge pull request <a
href="https://redirect.github.com/actions/upload-artifact/issues/725">#725</a>
from patrikpolyak/patch-1</li>
<li><a
href="9687587dec"><code>9687587</code></a>
Merge branch 'main' into patch-1</li>
<li><a
href="2848b2cda0"><code>2848b2c</code></a>
Merge pull request <a
href="https://redirect.github.com/actions/upload-artifact/issues/727">#727</a>
from danwkennedy/patch-1</li>
<li><a
href="9b511775fd"><code>9b51177</code></a>
Spell out the first use of GHES</li>
<li><a
href="cd231ca1ed"><code>cd231ca</code></a>
Update GHES guidance to include reference to Node 20 version</li>
<li><a
href="de65e23aa2"><code>de65e23</code></a>
Merge pull request <a
href="https://redirect.github.com/actions/upload-artifact/issues/712">#712</a>
from actions/nebuk89-patch-1</li>
<li><a
href="8747d8cd76"><code>8747d8c</code></a>
Update README.md</li>
<li>Additional commits viewable in <a
href="https://github.com/actions/upload-artifact/compare/v4...v5">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/upload-artifact&package-manager=github_actions&previous-version=4&new-version=5)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>
2025-10-26 18:11:56 -07:00
Isaac
83a1d0e3e3 Bump actions/download-artifact from 5 to 6 (#149)
Bumps
[actions/download-artifact](https://github.com/actions/download-artifact)
from 5 to 6.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/actions/download-artifact/releases">actions/download-artifact's
releases</a>.</em></p>
<blockquote>
<h2>v6.0.0</h2>
<h2>What's Changed</h2>
<p><strong>BREAKING CHANGE:</strong> this update supports Node
<code>v24.x</code>. This is not a breaking change per-se but we're
treating it as such.</p>
<ul>
<li>Update README for download-artifact v5 changes by <a
href="https://github.com/yacaovsnc"><code>@​yacaovsnc</code></a> in <a
href="https://redirect.github.com/actions/download-artifact/pull/417">actions/download-artifact#417</a></li>
<li>Update README with artifact extraction details by <a
href="https://github.com/yacaovsnc"><code>@​yacaovsnc</code></a> in <a
href="https://redirect.github.com/actions/download-artifact/pull/424">actions/download-artifact#424</a></li>
<li>Readme: spell out the first use of GHES by <a
href="https://github.com/danwkennedy"><code>@​danwkennedy</code></a> in
<a
href="https://redirect.github.com/actions/download-artifact/pull/431">actions/download-artifact#431</a></li>
<li>Bump <code>@actions/artifact</code> to <code>v4.0.0</code></li>
<li>Prepare <code>v6.0.0</code> by <a
href="https://github.com/danwkennedy"><code>@​danwkennedy</code></a> in
<a
href="https://redirect.github.com/actions/download-artifact/pull/438">actions/download-artifact#438</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/danwkennedy"><code>@​danwkennedy</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/download-artifact/pull/431">actions/download-artifact#431</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/download-artifact/compare/v5...v6.0.0">https://github.com/actions/download-artifact/compare/v5...v6.0.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="018cc2cf5b"><code>018cc2c</code></a>
Merge pull request <a
href="https://redirect.github.com/actions/download-artifact/issues/438">#438</a>
from actions/danwkennedy/prepare-6.0.0</li>
<li><a
href="815651c680"><code>815651c</code></a>
Revert &quot;Remove <code>github.dep.yml</code>&quot;</li>
<li><a
href="bb3a066a8b"><code>bb3a066</code></a>
Remove <code>github.dep.yml</code></li>
<li><a
href="fa1ce46bbd"><code>fa1ce46</code></a>
Prepare <code>v6.0.0</code></li>
<li><a
href="4a24838f3d"><code>4a24838</code></a>
Merge pull request <a
href="https://redirect.github.com/actions/download-artifact/issues/431">#431</a>
from danwkennedy/patch-1</li>
<li><a
href="5e3251c4ff"><code>5e3251c</code></a>
Readme: spell out the first use of GHES</li>
<li><a
href="abefc31eaf"><code>abefc31</code></a>
Merge pull request <a
href="https://redirect.github.com/actions/download-artifact/issues/424">#424</a>
from actions/yacaovsnc/update_readme</li>
<li><a
href="ac43a6070a"><code>ac43a60</code></a>
Update README with artifact extraction details</li>
<li><a
href="de96f4613b"><code>de96f46</code></a>
Merge pull request <a
href="https://redirect.github.com/actions/download-artifact/issues/417">#417</a>
from actions/yacaovsnc/update_readme</li>
<li><a
href="7993cb44e9"><code>7993cb4</code></a>
Remove migration guide for artifact download changes</li>
<li>Additional commits viewable in <a
href="https://github.com/actions/download-artifact/compare/v5...v6">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/download-artifact&package-manager=github_actions&previous-version=5&new-version=6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>
2025-10-26 18:11:48 -07:00
dependabot[bot]
4d0fdfa25e Bump actions/download-artifact from 5 to 6
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-27 00:26:03 +00:00
dependabot[bot]
9f673f9d8b Bump actions/upload-artifact from 4 to 5
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-27 00:25:38 +00:00
MSWS
3ad4339073 Buff bodypaint 2025-10-25 21:14:27 -07:00
Isaac
890ba71fdf Additional balancing (#147) 2025-10-25 02:50:17 -07:00
MSWS
c6fea1a21e Balances 2025-10-25 02:43:50 -07:00
MSWS
db9ad9303f Reduce M4 cost, reduce station health 2025-10-25 02:25:11 -07:00
Isaac
9224e823c0 Game balances (#146) 2025-10-25 02:05:03 -07:00
MSWS
4ab16d71db Handle map change interrupting rounds 2025-10-25 01:59:16 -07:00
MSWS
627c048183 Delay round effects for speedround due to race condition 2025-10-25 01:47:55 -07:00
MSWS
66d1106d4c Increase time, nerf camo and silent awp 2025-10-25 01:02:46 -07:00
Isaac
39c7a4762d Dev (#145) 2025-10-24 20:08:47 -07:00
MSWS
f2352ede1f Merge branch 'dev' of github.com:MSWS/TTT into dev 2025-10-24 20:06:20 -07:00
MSWS
f675a87ffd Additional hotpatch 2025-10-24 20:06:04 -07:00
Isaac
7f455d5354 Hotpatch 2025-10-24 19:19:44 -07:00
Isaac
d1972fc556 Merge branch 'main' into dev 2025-10-24 19:12:35 -07:00
MSWS
f2dbc72aee Use squared distance 2025-10-24 19:09:45 -07:00
MSWS
77a2289367 Reset special round on round end 2025-10-24 19:08:55 -07:00
Isaac
456ae22b12 feat: Auto RTD (#142) 2025-10-24 18:23:48 -07:00
Isaac
2616b231dc fix: Use Locale (#141) 2025-10-24 18:20:04 -07:00
MSWS
3cb86aa2f8 Working Auto RTD 2025-10-24 18:19:02 -07:00
MSWS
4c72f3dfff Fix duplicate spaces 2025-10-24 18:00:30 -07:00
MSWS
bc45f3fb74 fix: Use Locale 2025-10-24 17:58:15 -07:00
Isaac
2bcf436677 feat: Auto RTD (resolves #140) (#139) 2025-10-24 17:41:08 -07:00
Isaac
9dfb45583b feat: Special Rounds (resolves #133) (#138) 2025-10-24 17:36:55 -07:00
MSWS
3fa1558011 feat: Auto RTD 2025-10-24 17:36:36 -07:00
MSWS
6c7bc22395 Add vanilla round 2025-10-24 17:06:35 -07:00
MSWS
c95fba0fc5 Send messages 2025-10-24 16:44:09 -07:00
Isaac
40c7a6d471 Fix services (#137) 2025-10-24 16:03:35 -07:00
MSWS
b79519f6b4 Fix services 2025-10-24 16:01:56 -07:00
Isaac
bea87d20f3 Feat/special rounds (#136) 2025-10-24 15:23:48 -07:00
MSWS
5bbc621d86 Fix circular dependencies 2025-10-24 15:21:48 -07:00
MSWS
5ed244f84c Add list of special rounds to feedback 2025-10-24 15:16:54 -07:00
MSWS
31d2354e6f Basic work for special rounds 2025-10-24 15:16:03 -07:00
MSWS
44d9644694 Start work on special rounds 2025-10-24 01:38:14 -07:00
Isaac
f6d1b95a38 Update scope management (#135) 2025-10-22 16:02:12 -07:00
Isaac
5393920f95 Bug Fixes, Stats API +semver:minor (#134) 2025-10-22 09:18:27 -07:00
60 changed files with 865 additions and 39 deletions

View File

@@ -38,7 +38,7 @@ jobs:
- name: Publish Test Project
run: dotnet publish TTT/Test/Test.csproj --no-restore --no-build -o build_output -c Debug
- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v5
with:
name: build_output
path: build_output
@@ -59,7 +59,7 @@ jobs:
dotnet-version: '8.0.x'
- name: Download Build Output
uses: actions/download-artifact@v5
uses: actions/download-artifact@v6
with:
name: build_output
path: build_output

View File

@@ -0,0 +1,29 @@
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
using TTT.API;
using TTT.API.Events;
using TTT.Game.Events.Game;
using TTT.Locale;
namespace SpecialRoundAPI;
public abstract class AbstractSpecialRound(IServiceProvider provider)
: ITerrorModule, IListener {
protected readonly IServiceProvider Provider = provider;
protected readonly ISpecialRoundTracker Tracker =
provider.GetRequiredService<ISpecialRoundTracker>();
public void Dispose() { }
public void Start() { }
public abstract string Name { get; }
public abstract IMsg Description { get; }
public abstract SpecialRoundConfig Config { get; }
public abstract void ApplyRoundEffects();
[UsedImplicitly]
[EventHandler]
public abstract void OnGameState(GameStateUpdateEvent ev);
}

View File

@@ -0,0 +1,5 @@
namespace SpecialRoundAPI;
public record BhopRoundConfig : SpecialRoundConfig {
public override float Weight { get; init; } = 0.2f;
}

View File

@@ -0,0 +1,13 @@
namespace SpecialRoundAPI;
public interface ISpecialRoundStarter {
/// <summary>
/// Attempts to start the given special round.
/// Will bypass most checks, but may still return null if starting the round
/// is not possible.
/// </summary>
/// <param name="round"></param>
/// <returns></returns>
public AbstractSpecialRound?
TryStartSpecialRound(AbstractSpecialRound? round);
}

View File

@@ -0,0 +1,6 @@
namespace SpecialRoundAPI;
public interface ISpecialRoundTracker {
public AbstractSpecialRound? CurrentRound { get; set; }
public int RoundsSinceLastSpecial { get; set; }
}

View File

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Locale\Locale.csproj" />
<ProjectReference Include="..\..\TTT\API\API.csproj" />
<ProjectReference Include="..\..\TTT\Game\Game.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,5 @@
namespace SpecialRoundAPI;
public abstract record SpecialRoundConfig {
public abstract float Weight { get; init; }
}

View File

@@ -0,0 +1,8 @@
namespace SpecialRoundAPI;
public record SpeedRoundConfig : SpecialRoundConfig {
public override float Weight { get; init; } = 0.4f;
public TimeSpan InitialSeconds { get; init; } = TimeSpan.FromSeconds(60);
public TimeSpan SecondsPerKill { get; init; } = TimeSpan.FromSeconds(10);
}

View File

@@ -0,0 +1,5 @@
namespace SpecialRoundAPI;
public record VanillaRoundConfig : SpecialRoundConfig {
public override float Weight { get; init; } = 0.3f;
}

12
TTT.sln
View File

@@ -27,6 +27,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RTD", "TTT\RTD\RTD.csproj",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stats", "TTT\Stats\Stats.csproj", "{256473A2-6ACD-440C-83FA-6056147656C7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpecialRound", "TTT\SpecialRound\SpecialRound.csproj", "{5092069A-3CFA-41C8-B685-341040AB435C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpecialRoundAPI", "SpecialRoundAPI\SpecialRoundAPI\SpecialRoundAPI.csproj", "{360FEF16-54DA-42EE-995A-3D31C699287D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -84,6 +88,14 @@ Global
{256473A2-6ACD-440C-83FA-6056147656C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{256473A2-6ACD-440C-83FA-6056147656C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{256473A2-6ACD-440C-83FA-6056147656C7}.Release|Any CPU.Build.0 = Release|Any CPU
{5092069A-3CFA-41C8-B685-341040AB435C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5092069A-3CFA-41C8-B685-341040AB435C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5092069A-3CFA-41C8-B685-341040AB435C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5092069A-3CFA-41C8-B685-341040AB435C}.Release|Any CPU.Build.0 = Release|Any CPU
{360FEF16-54DA-42EE-995A-3D31C699287D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{360FEF16-54DA-42EE-995A-3D31C699287D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{360FEF16-54DA-42EE-995A-3D31C699287D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{360FEF16-54DA-42EE-995A-3D31C699287D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
EndGlobalSection

View File

@@ -9,6 +9,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\SpecialRoundAPI\SpecialRoundAPI\SpecialRoundAPI.csproj" />
<ProjectReference Include="..\API\API.csproj"/>
<ProjectReference Include="..\Game\Game.csproj"/>
<ProjectReference Include="..\Karma\Karma.csproj"/>

View File

@@ -67,6 +67,7 @@ public static class CS2ServiceCollection {
collection.AddModBehavior<TeamChangeHandler>();
collection.AddModBehavior<TraitorChatHandler>();
collection.AddModBehavior<PlayerMuter>();
collection.AddModBehavior<MapChangeCausesEndListener>();
// Damage Cancelers
collection.AddModBehavior<OutOfRoundCanceler>();
@@ -82,6 +83,7 @@ public static class CS2ServiceCollection {
collection.AddModBehavior<ScreenColorApplier>();
collection.AddModBehavior<KarmaBanner>();
collection.AddModBehavior<KarmaSyncer>();
collection.AddModBehavior<MapHookListener>();
// Commands
collection.AddModBehavior<TestCommand>();

View File

@@ -0,0 +1,33 @@
using System.Numerics;
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Memory;
using Microsoft.Extensions.DependencyInjection;
using TTT.API.Command;
using TTT.API.Player;
using TTT.CS2.Extensions;
using TTT.CS2.Utils;
using Vector = CounterStrikeSharp.API.Modules.Utils.Vector;
namespace TTT.CS2.Command.Test;
public class SetTargetCommand(IServiceProvider provider) : ICommand {
private readonly IPlayerConverter<CCSPlayerController> converter =
provider.GetRequiredService<IPlayerConverter<CCSPlayerController>>();
public void Dispose() { }
public void Start() { }
public string Id => "settarget";
public Task<CommandResult>
Execute(IOnlinePlayer? executor, ICommandInfo info) {
if (executor == null) return Task.FromResult(CommandResult.PLAYER_ONLY);
var csPlayer = converter.GetPlayer(executor);
if (csPlayer == null) return Task.FromResult(CommandResult.PLAYER_ONLY);
EntityNameHelper.SetEntityName(csPlayer, EntityNameHelper.Role.Traitor);
return Task.FromResult(CommandResult.SUCCESS);
}
}

View File

@@ -0,0 +1,41 @@
using Microsoft.Extensions.DependencyInjection;
using SpecialRoundAPI;
using TTT.API;
using TTT.API.Command;
using TTT.API.Player;
namespace TTT.CS2.Command.Test;
public class SpecialRoundCommand(IServiceProvider provider) : ICommand {
private readonly ISpecialRoundStarter tracker =
provider.GetRequiredService<ISpecialRoundStarter>();
public void Dispose() { }
public void Start() { }
public string Id => "specialround";
public Task<CommandResult>
Execute(IOnlinePlayer? executor, ICommandInfo info) {
if (info.ArgCount == 1) {
tracker.TryStartSpecialRound(null);
info.ReplySync("Started a random special round.");
return Task.FromResult(CommandResult.SUCCESS);
}
var rounds = provider.GetServices<ITerrorModule>()
.OfType<AbstractSpecialRound>()
.ToDictionary(r => r.GetType().Name.ToLower(), r => r);
var roundName = info.Args[1].ToLower();
if (!rounds.TryGetValue(roundName, out var round)) {
info.ReplySync($"No special round found with name '{roundName}'.");
foreach (var name in rounds.Keys) info.ReplySync($"- {name}");
return Task.FromResult(CommandResult.INVALID_ARGS);
}
tracker.TryStartSpecialRound(round);
info.ReplySync($"Started special round '{roundName}'.");
return Task.FromResult(CommandResult.SUCCESS);
}
}

View File

@@ -28,6 +28,8 @@ public class TestCommand(IServiceProvider provider) : ICommand, IPluginModule {
subCommands.Add("credits", new CreditsCommand(provider));
subCommands.Add("spec", new SpecCommand(provider));
subCommands.Add("reload", new ReloadModuleCommand(provider));
subCommands.Add("specialround", new SpecialRoundCommand(provider));
subCommands.Add("settarget", new SetTargetCommand(provider));
}
public Task<CommandResult>

View File

@@ -24,7 +24,7 @@ public class CS2GameConfig : IStorage<TTTConfig>, IPluginModule {
public static readonly FakeConVar<int> CV_ROUND_DURATION_PER_PLAYER = new(
"css_ttt_round_duration_per_player",
"Additional round duration per player in seconds", 10,
"Additional round duration per player in seconds", 15,
ConVarFlags.FCVAR_NONE, new RangeValidator<int>(0, 60));
public static readonly FakeConVar<int> CV_ROUND_DURATION_MAX = new(

View File

@@ -10,7 +10,7 @@ namespace TTT.CS2.Configs;
public class CS2ShopConfig : IStorage<ShopConfig>, IPluginModule {
public static readonly FakeConVar<int> CV_STARTING_INNOCENT_CREDITS = new(
"css_ttt_shop_start_innocent", "Starting credits for Innocents", 80,
"css_ttt_shop_start_innocent", "Starting credits for Innocents", 60,
ConVarFlags.FCVAR_NONE, new RangeValidator<int>(0, 10000));
public static readonly FakeConVar<int> CV_STARTING_TRAITOR_CREDITS = new(

View File

@@ -11,7 +11,7 @@ namespace TTT.CS2.Configs.ShopItems;
public class CS2M4A1Config : IStorage<M4A1Config>, IPluginModule {
public static readonly FakeConVar<int> CV_PRICE = new(
"css_ttt_shop_m4a1_price", "Price of the M4A1 item", 75,
"css_ttt_shop_m4a1_price", "Price of the M4A1 item", 50,
ConVarFlags.FCVAR_NONE, new RangeValidator<int>(0, 10000));
public static readonly FakeConVar<string> CV_CLEAR_SLOTS = new(

View File

@@ -30,6 +30,10 @@ public class DamageCanceler(IServiceProvider provider) : IPluginModule {
}
private HookResult onTakeDamage(DynamicHook hook) {
var playerPawn = hook.GetParam<CCSPlayerPawn>(0);
var player = playerPawn.Controller.Value?.As<CCSPlayerController>();
if (player == null || !player.IsValid) return HookResult.Continue;
var damagedEvent = new PlayerDamagedEvent(converter, hook);
bus.Dispatch(damagedEvent);

View File

@@ -0,0 +1,64 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using Microsoft.Extensions.DependencyInjection;
using TTT.API;
using TTT.API.Messages;
namespace TTT.CS2.GameHandlers;
public class EntityTargetHandlers(IServiceProvider provider) : IPluginModule {
private readonly IMessenger messenger =
provider.GetRequiredService<IMessenger>();
public void Dispose() { }
public void Start() { }
public void Start(BasePlugin? plugin) {
plugin?.HookEntityOutput("*", "*", handler);
}
private HookResult handler(CEntityIOOutput output, string name,
CEntityInstance activator, CEntityInstance caller, CVariant value,
float delay) {
if (caller.DesignerName == "prop_dynamic") return HookResult.Continue;
messenger.Debug("Entity Output Triggered: " + name);
messenger.Debug("Activator: " + activator.DesignerName);
messenger.Debug("Caller: " + caller.DesignerName);
messenger.Debug("Value: " + value + " " + value.GetType());
caller.AcceptInput("OnPass");
activator.AcceptInput("OnPass");
if (caller.DesignerName != "filter_activator_name")
return HookResult.Continue;
var csPlayer =
Utilities.GetPlayerFromIndex((int)activator.EntityHandle.Index);
if (csPlayer != null && csPlayer.IsValid) {
messenger.DebugAnnounce(
$"Filter Activator Name triggered by player: {csPlayer.PlayerName} {(int)csPlayer.Index}");
}
var ptrPlayer = new CCSPlayerController(activator.Handle);
if (ptrPlayer.IsValid) {
messenger.DebugAnnounce(
$"Filter Activator Name triggered by player controller: {ptrPlayer.PlayerName} {(int)ptrPlayer.Index}");
}
messenger.DebugAnnounce(output + " - " + output.Description);
var connections = output.Connections;
if (connections != null) debugConnection(connections);
caller.AcceptInput("OnPass");
return HookResult.Continue;
}
private void debugConnection(EntityIOConnection_t connection) {
messenger.DebugAnnounce("Connection:");
messenger.DebugAnnounce(" Target: " + connection.Target);
messenger.DebugAnnounce(" Input: " + connection.TargetInput);
messenger.DebugAnnounce(" Parameter: " + connection.ValueOverride);
messenger.DebugAnnounce(" Delay: " + connection.Delay);
messenger.DebugAnnounce(" Times to fire: " + connection.TimesToFire);
if (connection.Next != null) debugConnection(connection.Next);
}
}

View File

@@ -0,0 +1,26 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using Microsoft.Extensions.DependencyInjection;
using TTT.API;
using TTT.API.Game;
namespace TTT.CS2.GameHandlers;
public class MapChangeCausesEndListener(IServiceProvider provider)
: IPluginModule {
private readonly IGameManager games =
provider.GetRequiredService<IGameManager>();
public void Dispose() { }
public void Start() { }
public void Start(BasePlugin? plugin) {
plugin?.RegisterListener<CounterStrikeSharp.API.Core.Listeners.OnMapStart>(
onMapChange);
}
private void onMapChange(string mapName) {
games.ActiveGame?.EndGame(new EndReason("Map Change"));
Server.PrintToConsole("Detected map change, ending active game.");
}
}

View File

@@ -77,7 +77,8 @@ public class AfkTimerListener(IServiceProvider provider)
private List<CCSPlayerController> getAfkPlayers() {
return Utilities.GetPlayers()
.Where(p => p.PlayerPawn.Value != null
&& !p.PlayerPawn.Value.HasMovedSinceSpawn)
&& p is { Team: CsTeam.CounterTerrorist or CsTeam.Terrorist }
&& p.GetHealth() >= 0 && !p.PlayerPawn.Value.HasMovedSinceSpawn)
.ToList();
}
}

View File

@@ -0,0 +1,24 @@
using CounterStrikeSharp.API.Core;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
using TTT.API.Events;
using TTT.API.Player;
using TTT.CS2.Utils;
using TTT.Game.Events.Player;
using TTT.Game.Listeners;
namespace TTT.CS2.Listeners;
public class MapHookListener(IServiceProvider provider)
: BaseListener(provider) {
private readonly IPlayerConverter<CCSPlayerController> converter =
provider.GetRequiredService<IPlayerConverter<CCSPlayerController>>();
[UsedImplicitly]
[EventHandler(Priority = Priority.MONITOR, IgnoreCanceled = true)]
public void OnRoleAssign(PlayerRoleAssignEvent ev) {
var player = converter.GetPlayer(ev.Player);
if (player == null) return;
EntityNameHelper.SetEntityName(player, ev.Role);
}
}

View File

@@ -31,7 +31,7 @@ public class RoundTimerListener(IServiceProvider provider)
private readonly IPlayerConverter<CCSPlayerController> converter =
provider.GetRequiredService<IPlayerConverter<CCSPlayerController>>();
private IDisposable? endTimer;
public IDisposable? EndTimer;
[UsedImplicitly]
[EventHandler(IgnoreCanceled = true)]
@@ -63,14 +63,14 @@ public class RoundTimerListener(IServiceProvider provider)
player.Respawn();
});
if (ev.NewState == State.FINISHED) endTimer?.Dispose();
if (ev.NewState == State.FINISHED) EndTimer?.Dispose();
if (ev.NewState != State.IN_PROGRESS) return;
var duration = config.RoundCfg.RoundDuration(ev.Game.Players.Count);
Server.NextWorldUpdate(()
=> RoundUtil.SetTimeRemaining((int)duration.TotalSeconds));
endTimer?.Dispose();
endTimer = Scheduler.Schedule(duration,
EndTimer?.Dispose();
EndTimer = Scheduler.Schedule(duration,
() => {
Server.NextWorldUpdate(()
=> ev.Game.EndGame(EndReason.TIMEOUT(new InnocentRole(Provider))));
@@ -137,6 +137,6 @@ public class RoundTimerListener(IServiceProvider provider)
public override void Dispose() {
base.Dispose();
endTimer?.Dispose();
EndTimer?.Dispose();
}
}

View File

@@ -60,8 +60,12 @@ public class CS2AliveSpoofer : IAliveSpoofer, IPluginModule {
this.plugin = plugin;
plugin?.RegisterListener<CounterStrikeSharp.API.Core.Listeners.OnTick>(
onTick);
plugin?.RegisterListener<CounterStrikeSharp.API.Core.Listeners.OnMapStart>(
onMapStart);
}
private void onMapStart(string mapName) { _fakeAlivePlayers.Clear(); }
[UsedImplicitly]
[GameEventHandler]
public HookResult OnDisconnect(EventPlayerDisconnect ev, GameEventInfo _) {

View File

@@ -47,10 +47,6 @@ public class CS2Player : IOnlinePlayer, IEquatable<CS2Player> {
}
}
private int namePadding
=> Math.Min(Utilities.GetPlayers().Select(p => p.PlayerName.Length).Max(),
24);
public bool Equals(CS2Player? other) {
if (other is null) return false;
return Id == other.Id;
@@ -119,6 +115,11 @@ public class CS2Player : IOnlinePlayer, IEquatable<CS2Player> {
// Goal: Pad the name to a fixed width for better alignment in logs
// Left-align ID, right-align name
private string createPaddedName() {
var onlineLengths = Utilities.GetPlayers()
.Select(p => p.PlayerName.Length)
.ToList();
if (onlineLengths.Count == 0) return CreatePaddedName(Id, Name, 13);
var namePadding = Math.Min(onlineLengths.Max(), 24);
return CreatePaddedName(Id, Name, namePadding + 8);
}

View File

@@ -0,0 +1,21 @@
using CounterStrikeSharp.API.Core;
using Microsoft.Extensions.DependencyInjection;
using TTT.API.Player;
using TTT.Game.Roles;
namespace TTT.CS2.Roles;
public class CS2TraitorRole(IServiceProvider provider) : TraitorRole(provider) {
private readonly IPlayerConverter<CCSPlayerController> converter =
provider.GetRequiredService<IPlayerConverter<CCSPlayerController>>();
public override void OnAssign(IOnlinePlayer player) {
base.OnAssign(player);
var gamePlayer = converter.GetPlayer(player);
if (gamePlayer == null) return;
gamePlayer.AcceptInput("SetTargetName", null, null, "traitor");
if (gamePlayer.Pawn.Value != null) gamePlayer.Pawn.Value.Target = "traitor";
}
}

View File

@@ -0,0 +1,52 @@
using System.Runtime.InteropServices;
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Utils;
using TTT.API.Role;
using TTT.CS2.Extensions;
using TTT.Game.Roles;
namespace TTT.CS2.Utils;
public class EntityNameHelper {
public enum Role {
Innocent, Traitor, Detective
}
private static readonly Vector RELAY_POSITION = new(69, 420, -60);
public static void SetEntityName(CCSPlayerController player, IRole role) {
switch (role) {
case InnocentRole:
SetEntityName(player, Role.Innocent);
break;
case TraitorRole:
SetEntityName(player, Role.Traitor);
break;
case DetectiveRole:
SetEntityName(player, Role.Detective);
break;
}
}
public static void SetEntityName(CCSPlayerController player, Role role) {
Server.NextWorldUpdate(() => {
var name = role switch {
Role.Innocent => "ttt_innocent_assigner",
Role.Traitor => "ttt_traitor_assigner",
Role.Detective => "ttt_detective_assigner",
_ => "ttt_innocent_assigner"
};
var entity = Utilities
.FindAllEntitiesByDesignerName<CLogicRelay>("logic_relay")
.FirstOrDefault(e
=> e.Entity?.Name == name
&& e.AbsOrigin.DistanceSquared(RELAY_POSITION) < 100);
entity?.AcceptInput("Trigger", player, player);
});
}
}

View File

@@ -50,7 +50,8 @@ public static class RoundUtil {
public static void EndRound(RoundEndReason reason) {
var gameRules = ServerUtil.GameRulesProxy;
if (gameRules == null || gameRules.GameRules == null) return;
if (gameRules == null || gameRules.GameRules == null || !gameRules.IsValid)
return;
// TODO: Figure out what these params do
// TerminateRoundFunc.Invoke(gameRules.GameRules.Handle, 5f, reason, 0, 0);
VirtualFunctions.TerminateRoundFunc.Invoke(gameRules.GameRules.Handle,

View File

@@ -11,7 +11,9 @@ public static class ServerUtil {
.FindAllEntitiesByDesignerName<CCSGameRulesProxy>("cs_gamerules")
.FirstOrDefault();
return GameRulesProxy?.GameRules;
if (GameRulesProxy == null || !GameRulesProxy.IsValid) return null;
return GameRulesProxy.GameRules;
}
}

View File

@@ -33,5 +33,12 @@
"windows": "48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 40 48 8B 6C 24 70",
"linux": "55 4C 89 C1 48 89 E5 41 57 49 89 D7"
}
},
"CEntityIdentity_SetEntityNameFunc": {
"signatures": {
"library": "server",
"windows": "48 89 5C 24 10 57 48 83 EC 20 48 8B D9 4C 8B C2",
"linux": "55 48 89 F2 48 89 E5 41 55 41 54 53"
}
}
}

View File

@@ -14,6 +14,7 @@
<ProjectReference Include="..\Shop\Shop.csproj"/>
<ProjectReference Include="..\RTD\RTD.csproj"/>
<ProjectReference Include="..\Stats\Stats.csproj"/>
<ProjectReference Include="..\SpecialRound\SpecialRound.csproj"/>
</ItemGroup>
<ItemGroup>

View File

@@ -2,6 +2,7 @@ using System.Reactive.Concurrency;
using CounterStrikeSharp.API.Core;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SpecialRound;
using Stats;
using TTT.CS2;
using TTT.Game;
@@ -20,6 +21,7 @@ public class TTTServiceCollection : IPluginServiceCollection<TTT> {
serviceCollection.AddCS2Services();
serviceCollection.AddShopServices();
serviceCollection.AddRtdServices();
serviceCollection.AddSpecialRounds();
if (Environment.GetEnvironmentVariable("TTT_STATS_API_URL") == null) return;
serviceCollection.AddStatsServices();

107
TTT/RTD/AutoRTDCommand.cs Normal file
View File

@@ -0,0 +1,107 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Commands;
using JetBrains.Annotations;
using MAULActainShared.plugin.models;
using Microsoft.Extensions.DependencyInjection;
using TTT.API;
using TTT.API.Command;
using TTT.API.Events;
using TTT.API.Game;
using TTT.API.Messages;
using TTT.API.Player;
using TTT.CS2.Command;
using TTT.CS2.ThirdParties.eGO;
using TTT.Game.Events.Game;
using TTT.Locale;
using TTT.RTD.lang;
namespace TTT.RTD;
public class AutoRTDCommand(IServiceProvider provider) : ICommand, IListener {
public string Id => "autortd";
private ICookie? autoRtdCookie;
private readonly IPlayerFinder finder =
provider.GetRequiredService<IPlayerFinder>();
private readonly ICommandManager commands =
provider.GetRequiredService<ICommandManager>();
private readonly IMsgLocalizer localizer =
provider.GetRequiredService<IMsgLocalizer>();
public bool MustBeOnMainThread => true;
public void Dispose() { }
public void Start() {
Task.Run(async () => {
var api = EgoApi.MAUL.Get();
if (api != null) {
await api.getCookieService().RegClientCookie("ttt_autortd");
autoRtdCookie =
await api.getCookieService().FindClientCookie("ttt_autortd");
}
});
}
public string[] RequiredFlags => ["@ttt/autortd"];
private Dictionary<string, bool> playerStatuses = new();
public async Task<CommandResult> Execute(IOnlinePlayer? executor,
ICommandInfo info) {
if (executor == null) return CommandResult.PLAYER_ONLY;
if (autoRtdCookie == null) {
info.ReplySync("AutoRTD system is not available.");
return CommandResult.SUCCESS;
}
if (!ulong.TryParse(executor.Id, out var executorId)) {
info.ReplySync("Your player ID is invalid for AutoRTD.");
return CommandResult.SUCCESS;
}
var value = await autoRtdCookie.Get(executorId);
if (value == "1") {
await autoRtdCookie.Set(executorId, "0");
info.ReplySync(localizer[RtdMsgs.COMMAND_AUTORTD_DISABLED]);
} else {
await autoRtdCookie.Set(executorId, "1");
info.ReplySync(localizer[RtdMsgs.COMMAND_AUTORTD_ENABLED]);
}
playerStatuses[executor.Id] = value != "1";
return CommandResult.SUCCESS;
}
[UsedImplicitly]
[EventHandler]
public void OnRoundStart(GameInitEvent ev) {
var messenger = provider.GetRequiredService<IMessenger>();
Task.Run(async () => {
foreach (var player in finder.GetOnline()) {
if (!playerStatuses.TryGetValue(player.Id, out var status)) {
await fetchCookie(player);
status = playerStatuses.GetValueOrDefault(player.Id, false);
}
if (!status) continue;
var info = new CS2CommandInfo(provider, player, 0, "css_rtd") {
CallingContext = CommandCallingContext.Chat
};
await Server.NextWorldUpdateAsync(() => commands.ProcessCommand(info));
}
});
}
private async Task fetchCookie(IPlayer player) {
if (autoRtdCookie == null) return;
if (!ulong.TryParse(player.Id, out var playerId)) return;
var value = await autoRtdCookie.Get(playerId);
playerStatuses[player.Id] = value == "1";
}
}

View File

@@ -15,4 +15,10 @@
<ProjectReference Include="..\Shop\Shop.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="MAULActainShared">
<HintPath>..\CS2\ThirdParties\Binaries\MAULActainShared.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View File

@@ -26,7 +26,7 @@ public class RTDCommand(IRewardGenerator generator, IPermissionManager perms,
if (executor == null) return Task.FromResult(CommandResult.PLAYER_ONLY);
var bypass = perms.HasFlags(executor, "@css/root") && info.ArgCount == 2;
#if DEBUG
bypass = true;
bypass = info.ArgCount == 2;
#endif
if (!bypass && playerRewards.TryGetValue(executor.Id, out var existing)) {

View File

@@ -9,6 +9,7 @@ public static class RtdServiceExtensions {
services.AddModBehavior<IRewardGenerator, RewardGenerator>();
services.AddModBehavior<RtdStatsCommand>();
services.AddModBehavior<RTDCommand>();
services.AddModBehavior<AutoRTDCommand>();
services.AddSingleton<IMuted, Muted>();
}
}

View File

@@ -20,4 +20,10 @@ public class RtdMsgs {
public static IMsg CREDITS_REWARD_DESC(int amo)
=> MsgFactory.Create(nameof(CREDITS_REWARD_DESC), amo);
public static IMsg COMMAND_AUTORTD_ENABLED
=> MsgFactory.Create(nameof(COMMAND_AUTORTD_ENABLED));
public static IMsg COMMAND_AUTORTD_DISABLED
=> MsgFactory.Create(nameof(COMMAND_AUTORTD_DISABLED));
}

View File

@@ -4,4 +4,6 @@ RTD_CANNOT_ROLL_YET: "%RTD_PREFIX%You must wait until death to roll the die."
RTD_ROLLED: "%RTD_PREFIX%You rolled {default}{0}{grey}, {1}."
RTD_MUTED: "%RTD_PREFIX%You cannot speak due to your dice roll."
CREDITS_REWARD: "{0} %CREDITS_NAME%%s%"
CREDITS_REWARD_DESC: "you will receive {yellow}{0} %CREDITS_NAME%%s%{grey} next round"
CREDITS_REWARD_DESC: "you will receive {yellow}{0} %CREDITS_NAME%%s%{grey} next round"
COMMAND_AUTORTD_ENABLED: "%RTD_PREFIX%Auto-RTD has been {green}enabled{grey}."
COMMAND_AUTORTD_DISABLED: "%RTD_PREFIX%Auto-RTD has been {red}disabled{grey}."

View File

@@ -98,7 +98,7 @@ public class PeriodicRewarder(IServiceProvider provider) : ITerrorModule {
if (positions.Count < 2) return 0f;
var totalDistance = 0f;
for (var i = 1; i < positions.Count; i++)
totalDistance += positions[i].Distance(positions[i - 1]);
totalDistance += positions[i].DistanceSquared(positions[i - 1]);
return totalDistance;

View File

@@ -26,7 +26,7 @@ SHOP_ITEM_TASER: "Taser"
SHOP_ITEM_TASER_DESC: "A taser that allows you to identify the roles of players you hit."
SHOP_ITEM_HEALTHSHOT: "Healthshot"
SHOP_ITEM_HEALTHSHOT_DESC: "A healthshot that instantly heals you for 50 health."
SHOP_ITEM_HEALTHSHOT_DESC: "A healthshot that heals you gradually for 50 health."
SHOP_INSUFFICIENT_BALANCE: "%SHOP_PREFIX%You cannot afford {white}{0}{grey}, it costs {yellow}{1}{grey} %CREDITS_NAME%%s%, and you have {yellow}{2}{grey}."
SHOP_CANNOT_PURCHASE: "%SHOP_PREFIX%You cannot purchase this item."

View File

@@ -4,6 +4,6 @@ namespace ShopAPI.Configs;
public record BodyPaintConfig : ShopItemConfig {
public override int Price { get; init; } = 40;
public int MaxUses { get; init; } = 2;
public int MaxUses { get; init; } = 4;
public Color ColorToApply { get; init; } = Color.GreenYellow;
}

View File

@@ -2,5 +2,5 @@ namespace ShopAPI.Configs;
public record CamoConfig : ShopItemConfig {
public override int Price { get; init; } = 75;
public float CamoVisibility { get; init; } = 0.4f;
public float CamoVisibility { get; init; } = 0.6f;
}

View File

@@ -3,7 +3,7 @@
namespace ShopAPI.Configs.Detective;
public record HealthStationConfig : StationConfig {
public override string UseSound { get; init; } = "sounds/buttons/blip1";
public virtual string UseSound { get; init; } = "sounds/buttons/blip1";
public override int Price { get; init; } = 50;

View File

@@ -5,12 +5,11 @@ namespace ShopAPI.Configs;
public abstract record StationConfig : ShopItemConfig {
public virtual int HealthIncrements { get; init; } = 5;
public virtual int TotalHealthGiven { get; init; } = 0;
public virtual int StationHealth { get; init; } = 1000;
public virtual int StationHealth { get; init; } = 200;
public virtual float MaxRange { get; init; } = 256;
public virtual TimeSpan HealthInterval { get; init; } =
TimeSpan.FromSeconds(1);
public abstract string UseSound { get; init; }
public abstract Color GetColor(float health);
}

View File

@@ -6,7 +6,7 @@ public record DamageStationConfig : StationConfig {
public override int HealthIncrements { get; init; } = -25;
public override int TotalHealthGiven { get; init; } = -3000;
public override string UseSound { get; init; } = "sounds/buttons/blip2";
public virtual string UseSound { get; init; } = "sounds/buttons/blip2";
public override int Price { get; init; } = 65;

View File

@@ -3,9 +3,9 @@
namespace ShopAPI.Configs.Traitor;
public record SilentAWPConfig : ShopItemConfig, IWeapon {
public override int Price { get; init; } = 90;
public override int Price { get; init; } = 80;
public int WeaponIndex { get; } = 9;
public string WeaponId { get; } = "weapon_awp";
public int? ReserveAmmo { get; } = 0;
public int? CurrentAmmo { get; } = 2;
public int? CurrentAmmo { get; } = 1;
}

View File

@@ -0,0 +1,39 @@
using CounterStrikeSharp.API;
using Microsoft.Extensions.DependencyInjection;
using SpecialRound.lang;
using SpecialRoundAPI;
using TTT.API.Game;
using TTT.API.Storage;
using TTT.Game.Events.Game;
using TTT.Locale;
namespace SpecialRound.Rounds;
public class BhopRound(IServiceProvider provider)
: AbstractSpecialRound(provider) {
public override string Name => "BHop";
public override IMsg Description => RoundMsgs.SPECIAL_ROUND_BHOP;
public override SpecialRoundConfig Config => config;
private BhopRoundConfig config
=> Provider.GetService<IStorage<BhopRoundConfig>>()
?.Load()
.GetAwaiter()
.GetResult() ?? new BhopRoundConfig();
public override void ApplyRoundEffects() {
Server.NextWorldUpdate(() => {
Server.ExecuteCommand("sv_enablebunnyhopping 1");
Server.ExecuteCommand("sv_autobunnyhopping 1");
});
}
public override void OnGameState(GameStateUpdateEvent ev) {
if (ev.NewState != State.FINISHED) return;
Server.NextWorldUpdate(() => {
Server.ExecuteCommand("sv_enablebunnyhopping 0");
Server.ExecuteCommand("sv_autobunnyhopping 0");
});
}
}

View File

@@ -0,0 +1,89 @@
using System.Reactive.Concurrency;
using CounterStrikeSharp.API;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
using SpecialRound.lang;
using SpecialRoundAPI;
using TTT.API.Events;
using TTT.API.Game;
using TTT.API.Role;
using TTT.API.Storage;
using TTT.CS2.Listeners;
using TTT.CS2.Utils;
using TTT.Game.Events.Game;
using TTT.Game.Events.Player;
using TTT.Game.Roles;
using TTT.Locale;
namespace SpecialRound.Rounds;
public class SpeedRound(IServiceProvider provider)
: AbstractSpecialRound(provider) {
private readonly IScheduler scheduler =
provider.GetRequiredService<IScheduler>();
private readonly IGameManager games =
provider.GetRequiredService<IGameManager>();
private readonly IRoleAssigner roles =
provider.GetRequiredService<IRoleAssigner>();
public override string Name => "Speed";
public override IMsg Description => RoundMsgs.SPECIAL_ROUND_SPEED;
public override SpecialRoundConfig Config => config;
private SpeedRoundConfig config
=> Provider.GetService<IStorage<SpeedRoundConfig>>()
?.Load()
.GetAwaiter()
.GetResult() ?? new SpeedRoundConfig();
private IDisposable? endTimer;
public override void ApplyRoundEffects() {
Provider.GetService<RoundTimerListener>()?.EndTimer?.Dispose();
Server.RunOnTick(Server.TickCount + 2,
() => setTime(config.InitialSeconds));
}
private void addTime(TimeSpan span) {
Server.NextWorldUpdate(() => {
var remaining = RoundUtil.GetTimeRemaining();
var newSpan = TimeSpan.FromSeconds(remaining + (int)span.TotalSeconds);
setTime(newSpan);
});
}
private void setTime(TimeSpan span) {
Server.NextWorldUpdate(() => {
RoundUtil.SetTimeRemaining((int)span.TotalSeconds);
});
endTimer?.Dispose();
endTimer = scheduler.Schedule(span,
() => Server.NextWorldUpdate(() => games.ActiveGame?.EndGame(
EndReason.TIMEOUT(new InnocentRole(Provider)))));
}
public override void OnGameState(GameStateUpdateEvent ev) {
if (ev.NewState != State.FINISHED) return;
endTimer?.Dispose();
}
[UsedImplicitly]
[EventHandler]
public void OnDeath(PlayerDeathEvent ev) {
var game = games.ActiveGame;
if (game == null) return;
if (Tracker.CurrentRound != this) return;
var victimRoles = roles.GetRoles(ev.Victim);
if (!victimRoles.Any(r => r is InnocentRole)) return;
addTime(config.SecondsPerKill);
}
}

View File

@@ -0,0 +1,36 @@
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
using ShopAPI.Events;
using SpecialRound.lang;
using SpecialRoundAPI;
using TTT.API.Events;
using TTT.API.Storage;
using TTT.Game.Events.Game;
using TTT.Locale;
namespace SpecialRound.Rounds;
public class VanillaRound(IServiceProvider provider)
: AbstractSpecialRound(provider) {
public override string Name => "Vanilla";
public override IMsg Description => RoundMsgs.SPECIAL_ROUND_VANILLA;
private VanillaRoundConfig config
=> Provider.GetService<IStorage<VanillaRoundConfig>>()
?.Load()
.GetAwaiter()
.GetResult() ?? new VanillaRoundConfig();
public override SpecialRoundConfig Config => config;
public override void ApplyRoundEffects() { }
public override void OnGameState(GameStateUpdateEvent ev) { }
[UsedImplicitly]
[EventHandler(Priority = Priority.HIGH)]
public void OnPurchase(PlayerPurchaseItemEvent ev) {
if (Tracker.CurrentRound != this) return;
ev.IsCanceled = true;
}
}

View File

@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\SpecialRoundAPI\SpecialRoundAPI\SpecialRoundAPI.csproj" />
<ProjectReference Include="..\API\API.csproj" />
<ProjectReference Include="..\CS2\CS2.csproj" />
<ProjectReference Include="..\Game\Game.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,17 @@
using Microsoft.Extensions.DependencyInjection;
using SpecialRound.Rounds;
using SpecialRoundAPI;
using TTT.API.Extensions;
namespace SpecialRound;
public static class SpecialRoundCollection {
public static void AddSpecialRounds(this IServiceCollection services) {
services.AddModBehavior<ISpecialRoundStarter, SpecialRoundStarter>();
services.AddModBehavior<ISpecialRoundTracker, SpecialRoundTracker>();
services.AddModBehavior<SpeedRound>();
services.AddModBehavior<BhopRound>();
services.AddModBehavior<VanillaRound>();
}
}

View File

@@ -0,0 +1,72 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
using SpecialRound.lang;
using SpecialRoundAPI;
using TTT.API;
using TTT.API.Events;
using TTT.API.Game;
using TTT.API.Storage;
using TTT.Game.Events.Game;
using TTT.Game.Listeners;
namespace SpecialRound;
public class SpecialRoundStarter(IServiceProvider provider)
: BaseListener(provider), IPluginModule, ISpecialRoundStarter {
private readonly ISpecialRoundTracker tracker =
provider.GetRequiredService<ISpecialRoundTracker>();
private SpecialRoundsConfig config
=> Provider.GetService<IStorage<SpecialRoundsConfig>>()
?.Load()
.GetAwaiter()
.GetResult() ?? new SpecialRoundsConfig();
private int roundsSinceMapChange = 0;
public void Start(BasePlugin? plugin) {
plugin?.RegisterListener<Listeners.OnMapStart>(onMapChange);
}
private void onMapChange(string mapName) { roundsSinceMapChange = 0; }
[UsedImplicitly]
[EventHandler]
public void OnRound(GameStateUpdateEvent ev) {
if (ev.NewState != State.IN_PROGRESS) return;
roundsSinceMapChange++;
tracker.RoundsSinceLastSpecial++;
if (tracker.RoundsSinceLastSpecial < config.MinRoundsBetweenSpecial) return;
if (ev.Game.Players.Count < config.MinPlayersForSpecial) return;
if (roundsSinceMapChange < config.MinRoundsAfterMapChange) return;
if (Random.Shared.NextSingle() > config.SpecialRoundChance) return;
var specialRound = getSpecialRound();
TryStartSpecialRound(specialRound);
}
private AbstractSpecialRound getSpecialRound() {
return Provider.GetServices<ITerrorModule>()
.OfType<AbstractSpecialRound>()
.OrderBy(_ => Random.Shared.Next())
.First();
}
public AbstractSpecialRound?
TryStartSpecialRound(AbstractSpecialRound? round) {
round ??= getSpecialRound();
Messenger.MessageAll(Locale[RoundMsgs.SPECIAL_ROUND_STARTED(round)]);
Messenger.MessageAll(Locale[round.Description]);
round?.ApplyRoundEffects();
tracker.CurrentRound = round;
tracker.RoundsSinceLastSpecial = 0;
return round;
}
}

View File

@@ -0,0 +1,23 @@
using JetBrains.Annotations;
using SpecialRoundAPI;
using TTT.API;
using TTT.API.Events;
using TTT.API.Game;
using TTT.Game.Events.Game;
namespace SpecialRound;
public class SpecialRoundTracker : ISpecialRoundTracker, ITerrorModule,
IListener {
public AbstractSpecialRound? CurrentRound { get; set; }
public int RoundsSinceLastSpecial { get; set; }
public void Dispose() { }
public void Start() { }
[UsedImplicitly]
[EventHandler]
public void OnRoundEnd(GameStateUpdateEvent ev) {
if (ev.NewState != State.FINISHED) return;
CurrentRound = null;
}
}

View File

@@ -0,0 +1,8 @@
namespace SpecialRound;
public record SpecialRoundsConfig {
public int MinRoundsBetweenSpecial { get; init; } = 3;
public int MinPlayersForSpecial { get; init; } = 8;
public int MinRoundsAfterMapChange { get; init; } = 2;
public float SpecialRoundChance { get; init; } = 0.2f;
}

View File

@@ -0,0 +1,18 @@
using SpecialRoundAPI;
using TTT.Locale;
namespace SpecialRound.lang;
public class RoundMsgs {
public static IMsg SPECIAL_ROUND_STARTED(AbstractSpecialRound round) {
return MsgFactory.Create(nameof(SPECIAL_ROUND_STARTED), round.Name);
}
public static IMsg SPECIAL_ROUND_SPEED
=> MsgFactory.Create(nameof(SPECIAL_ROUND_SPEED));
public static IMsg SPECIAL_ROUND_BHOP
=> MsgFactory.Create(nameof(SPECIAL_ROUND_BHOP));
public static IMsg SPECIAL_ROUND_VANILLA
=> MsgFactory.Create(nameof(SPECIAL_ROUND_VANILLA)); }

View File

@@ -0,0 +1,4 @@
SPECIAL_ROUND_STARTED: "%PREFIX%This round is a {purple}Special Round{grey}! This round is a {lightpurple}{0}{grey} round!"
SPECIAL_ROUND_SPEED: " {yellow}SPEED{grey}: The round is faster than usual! {red}Traitors{grey} must kill to gain more time."
SPECIAL_ROUND_BHOP: " {Yellow}BHOP{grey}: Bunny hopping is enabled! Hold jump to move faster!"
SPECIAL_ROUND_VANILLA: " {green}VANILLA{grey}: The shop has been disabled!"

View File

@@ -133,11 +133,7 @@ public class RoundListener(IServiceProvider provider)
}
private async Task onRoundEnd(IGame game) {
Console.WriteLine("RoundListener: onRoundEnd fired");
if (CurrentRoundId == null) {
Console.WriteLine("RoundListener: currentRoundId is null, skipping");
return;
}
if (CurrentRoundId == null) return;
var ended_at = DateTime.UtcNow;
var winning_role = game.WinningRole != null ?

View File

@@ -9,10 +9,10 @@ public class StatsApi {
public static string ApiNameForRole(IRole role) {
return role switch {
_ when role is TraitorRole => "traitor",
_ when role is DetectiveRole => "detective",
_ when role is InnocentRole => "innocent",
_ => "unknown"
TraitorRole => "traitor",
DetectiveRole => "detective",
InnocentRole => "innocent",
_ => "unknown"
};
}
}

View File

@@ -1,2 +1,2 @@
API_ROUND_START: "%PREFIX% Round {yellow}#{0} {grey}has started!"
API_ROUND_END: "%PREFIX% Round end! Logs are available at {blue}http://localhost/rounds/{0}{grey}."
API_ROUND_END: "%PREFIX% Round end! Logs are available at {blue}http://ttt.localhost/round/{0}{grey}."