mirror of
https://github.com/MSWS/TTT.git
synced 2025-12-06 06:22:44 -08:00
Compare commits
79 Commits
0.20.0-dev
...
0.22.1-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57ef5e3e24 | ||
|
|
9c99d316aa | ||
|
|
e679c5193b | ||
|
|
6ece0450bb | ||
|
|
daa24a0e87 | ||
|
|
1c8785b388 | ||
|
|
a80c36e3c5 | ||
|
|
ba6b6c448f | ||
|
|
d30e916319 | ||
|
|
9f275fa189 | ||
|
|
40bdcac4b0 | ||
|
|
6b3ae03ab3 | ||
|
|
9e8e1d1fb0 | ||
|
|
fba875f098 | ||
|
|
38fa801c15 | ||
|
|
b21fed3ff8 | ||
|
|
0e02d66350 | ||
|
|
7f6ac62348 | ||
|
|
f44e57215f | ||
|
|
ce48f5a5ac | ||
|
|
4f258e55dd | ||
|
|
b0ba6baac9 | ||
|
|
4d052f31c6 | ||
|
|
7c5e7c3f68 | ||
|
|
23e08134c8 | ||
|
|
16d9335292 | ||
|
|
840e04fd71 | ||
|
|
70c416bbe6 | ||
|
|
b85a3a415d | ||
|
|
2351ec55ec | ||
|
|
4af1be95f4 | ||
|
|
fdb22c1090 | ||
|
|
ddc309927f | ||
|
|
7b657b1595 | ||
|
|
05eed34ffd | ||
|
|
707a967445 | ||
|
|
d6c6562d32 | ||
|
|
64e9332fa6 | ||
|
|
536f0eafb5 | ||
|
|
3e513cb611 | ||
|
|
cba8470f09 | ||
|
|
275404582f | ||
|
|
76dc717a8b | ||
|
|
ff8d4dfc7e | ||
|
|
f63acf24c4 | ||
|
|
678b9b0de6 | ||
|
|
18144f5827 | ||
|
|
e590ae2b7a | ||
|
|
6bc0f57bed | ||
|
|
83a1d0e3e3 | ||
|
|
4d0fdfa25e | ||
|
|
9f673f9d8b | ||
|
|
3ad4339073 | ||
|
|
890ba71fdf | ||
|
|
c6fea1a21e | ||
|
|
db9ad9303f | ||
|
|
9224e823c0 | ||
|
|
4ab16d71db | ||
|
|
627c048183 | ||
|
|
66d1106d4c | ||
|
|
39c7a4762d | ||
|
|
f2352ede1f | ||
|
|
f675a87ffd | ||
|
|
7f455d5354 | ||
|
|
d1972fc556 | ||
|
|
f2dbc72aee | ||
|
|
77a2289367 | ||
|
|
456ae22b12 | ||
|
|
2616b231dc | ||
|
|
3cb86aa2f8 | ||
|
|
4c72f3dfff | ||
|
|
bc45f3fb74 | ||
|
|
2bcf436677 | ||
|
|
9dfb45583b | ||
|
|
3fa1558011 | ||
|
|
6c7bc22395 | ||
|
|
c95fba0fc5 | ||
|
|
f6d1b95a38 | ||
|
|
5393920f95 |
4
.github/workflows/dotnet.yml
vendored
4
.github/workflows/dotnet.yml
vendored
@@ -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
|
||||
|
||||
@@ -17,6 +17,7 @@ public abstract class AbstractSpecialRound(IServiceProvider provider)
|
||||
public void Dispose() { }
|
||||
public void Start() { }
|
||||
|
||||
public abstract string Name { get; }
|
||||
public abstract IMsg Description { get; }
|
||||
public abstract SpecialRoundConfig Config { get; }
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
namespace SpecialRoundAPI;
|
||||
|
||||
public record SpeedRoundConfig : SpecialRoundConfig {
|
||||
public override float Weight { get; init; } = 0.4f;
|
||||
public override float Weight { get; init; } = 0.5f;
|
||||
|
||||
public TimeSpan InitialSeconds { get; init; } = TimeSpan.FromSeconds(60);
|
||||
public TimeSpan InitialSeconds { get; init; } = TimeSpan.FromSeconds(40);
|
||||
public TimeSpan SecondsPerKill { get; init; } = TimeSpan.FromSeconds(10);
|
||||
}
|
||||
5
SpecialRoundAPI/SpecialRoundAPI/VanillaRoundConfig.cs
Normal file
5
SpecialRoundAPI/SpecialRoundAPI/VanillaRoundConfig.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace SpecialRoundAPI;
|
||||
|
||||
public record VanillaRoundConfig : SpecialRoundConfig {
|
||||
public override float Weight { get; init; } = 0.3f;
|
||||
}
|
||||
@@ -11,6 +11,7 @@ public interface IAction {
|
||||
string Id { get; }
|
||||
string Verb { get; }
|
||||
string Details { get; }
|
||||
string Prefix => "";
|
||||
|
||||
public string Format() {
|
||||
var pRole = PlayerRole != null ?
|
||||
@@ -20,7 +21,7 @@ public interface IAction {
|
||||
$" [{OtherRole.Name.First(char.IsAsciiLetter)}]" :
|
||||
"";
|
||||
return Other is not null ?
|
||||
$"{Player}{pRole} {Verb} {Other}{oRole} {Details}" :
|
||||
$"{Player}{pRole} {Verb} {Details}";
|
||||
$"{Prefix}{Player}{pRole} {Verb} {Other}{oRole} {Details}" :
|
||||
$"{Prefix}{Player}{pRole} {Verb} {Details}";
|
||||
}
|
||||
}
|
||||
19
TTT/CS2/Actions/TaserAction.cs
Normal file
19
TTT/CS2/Actions/TaserAction.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using TTT.API.Game;
|
||||
using TTT.API.Player;
|
||||
using TTT.API.Role;
|
||||
|
||||
namespace TTT.CS2.Actions;
|
||||
|
||||
public class TaserAction(IRoleAssigner roles, IPlayer victim,
|
||||
IPlayer identifier) : IAction {
|
||||
public IPlayer Player { get; } = identifier;
|
||||
public IPlayer? Other { get; } = victim;
|
||||
|
||||
public IRole? PlayerRole { get; } =
|
||||
roles.GetRoles(identifier).FirstOrDefault();
|
||||
|
||||
public IRole? OtherRole { get; } = roles.GetRoles(victim).FirstOrDefault();
|
||||
public string Id { get; } = "cs2.action.tased";
|
||||
public string Verb { get; } = "tased";
|
||||
public string Details { get; } = "";
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ShopAPI.Configs;
|
||||
using ShopAPI.Configs.Detective;
|
||||
using ShopAPI.Configs.Traitor;
|
||||
using TTT.API.Command;
|
||||
using TTT.API.Extensions;
|
||||
@@ -50,6 +52,18 @@ public static class CS2ServiceCollection {
|
||||
.AddModBehavior<IStorage<PoisonSmokeConfig>, CS2PoisonSmokeConfig>();
|
||||
collection.AddModBehavior<IStorage<KarmaConfig>, CS2KarmaConfig>();
|
||||
collection.AddModBehavior<IStorage<CamoConfig>, CS2CamoConfig>();
|
||||
collection.AddModBehavior<IStorage<StickersConfig>, CS2StickersConfig>();
|
||||
collection.AddModBehavior<IStorage<BodyPaintConfig>, CS2BodyPaintConfig>();
|
||||
collection
|
||||
.AddModBehavior<IStorage<DnaScannerConfig>, CS2DnaScannerConfig>();
|
||||
collection
|
||||
.AddModBehavior<IStorage<HealthStationConfig>, CS2HealthStationConfig>();
|
||||
collection
|
||||
.AddModBehavior<IStorage<ClusterGrenadeConfig>, CS2ClusterGrenadeConfig>();
|
||||
collection.AddModBehavior<IStorage<GlovesConfig>, CS2GlovesConfig>();
|
||||
collection
|
||||
.AddModBehavior<IStorage<OneHitKnifeConfig>, CS2OneHitKnifeConfig>();
|
||||
collection.AddModBehavior<IStorage<SilentAWPConfig>, CS2SilentAWPConfig>();
|
||||
|
||||
// TTT - CS2 Specific optionals
|
||||
collection.AddScoped<ITextSpawner, TextSpawner>();
|
||||
@@ -67,6 +81,8 @@ public static class CS2ServiceCollection {
|
||||
collection.AddModBehavior<TeamChangeHandler>();
|
||||
collection.AddModBehavior<TraitorChatHandler>();
|
||||
collection.AddModBehavior<PlayerMuter>();
|
||||
collection.AddModBehavior<MapChangeCausesEndListener>();
|
||||
// collection.AddModBehavior<EntityTargetHandlers>();
|
||||
|
||||
// Damage Cancelers
|
||||
collection.AddModBehavior<OutOfRoundCanceler>();
|
||||
@@ -82,6 +98,7 @@ public static class CS2ServiceCollection {
|
||||
collection.AddModBehavior<ScreenColorApplier>();
|
||||
collection.AddModBehavior<KarmaBanner>();
|
||||
collection.AddModBehavior<KarmaSyncer>();
|
||||
collection.AddModBehavior<MapHookListener>();
|
||||
|
||||
// Commands
|
||||
collection.AddModBehavior<TestCommand>();
|
||||
|
||||
34
TTT/CS2/Command/Test/SetTargetCommand.cs
Normal file
34
TTT/CS2/Command/Test/SetTargetCommand.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
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);
|
||||
|
||||
Server.NextWorldUpdate(() => {
|
||||
var gamePlayer = converter.GetPlayer(executor);
|
||||
if (gamePlayer == null) return;
|
||||
gamePlayer.Pawn.Value?.AcceptInput("AddContext", null, null, "TRAITOR:1");
|
||||
});
|
||||
return Task.FromResult(CommandResult.SUCCESS);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@ public class SpecialRoundCommand(IServiceProvider provider) : ICommand {
|
||||
public void Dispose() { }
|
||||
public void Start() { }
|
||||
|
||||
public string Id => "specialround";
|
||||
|
||||
public Task<CommandResult>
|
||||
Execute(IOnlinePlayer? executor, ICommandInfo info) {
|
||||
if (info.ArgCount == 1) {
|
||||
|
||||
@@ -29,6 +29,7 @@ public class TestCommand(IServiceProvider provider) : ICommand, IPluginModule {
|
||||
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>
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
52
TTT/CS2/Configs/ShopItems/CS2BodyPaintConfig.cs
Normal file
52
TTT/CS2/Configs/ShopItems/CS2BodyPaintConfig.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Drawing;
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Cvars;
|
||||
using CounterStrikeSharp.API.Modules.Cvars.Validators;
|
||||
using ShopAPI.Configs;
|
||||
using TTT.API;
|
||||
using TTT.API.Storage;
|
||||
|
||||
namespace TTT.CS2.Configs.ShopItems;
|
||||
|
||||
public class CS2BodyPaintConfig : IStorage<BodyPaintConfig>, IPluginModule {
|
||||
public static readonly FakeConVar<int> CV_PRICE = new(
|
||||
"css_ttt_shop_bodypaint_price", "Price of the Body Paint item", 40,
|
||||
ConVarFlags.FCVAR_NONE, new RangeValidator<int>(0, 10000));
|
||||
|
||||
public static readonly FakeConVar<int> CV_MAX_USES = new(
|
||||
"css_ttt_shop_bodypaint_max_uses",
|
||||
"Maximum number of times the Body Paint can be applied per item", 4,
|
||||
ConVarFlags.FCVAR_NONE, new RangeValidator<int>(1, 100));
|
||||
|
||||
public static readonly FakeConVar<string> CV_COLOR = new(
|
||||
"css_ttt_shop_bodypaint_color",
|
||||
"Color to apply to the player's body (HTML hex or known color name)",
|
||||
"GreenYellow", ConVarFlags.FCVAR_NONE);
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
public void Start() { }
|
||||
|
||||
public void Start(BasePlugin? plugin) {
|
||||
ArgumentNullException.ThrowIfNull(plugin, nameof(plugin));
|
||||
plugin.RegisterFakeConVars(this);
|
||||
}
|
||||
|
||||
public Task<BodyPaintConfig?> Load() {
|
||||
Color parsedColor;
|
||||
try { parsedColor = ColorTranslator.FromHtml(CV_COLOR.Value); } catch {
|
||||
try { parsedColor = Color.FromName(CV_COLOR.Value); } catch {
|
||||
parsedColor = Color.GreenYellow;
|
||||
}
|
||||
}
|
||||
|
||||
var cfg = new BodyPaintConfig {
|
||||
Price = CV_PRICE.Value,
|
||||
MaxUses = CV_MAX_USES.Value,
|
||||
ColorToApply = parsedColor
|
||||
};
|
||||
|
||||
return Task.FromResult<BodyPaintConfig?>(cfg);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ public class CS2CamoConfig : IStorage<CamoConfig>, IPluginModule {
|
||||
public static readonly FakeConVar<float> CV_CAMO_VISIBILITY = new(
|
||||
"css_ttt_shop_camo_visibility",
|
||||
"Player visibility multiplier while camouflaged (0 = invisible, 1 = fully visible)",
|
||||
0.4f, ConVarFlags.FCVAR_NONE, new RangeValidator<float>(0f, 1f));
|
||||
0.6f, ConVarFlags.FCVAR_NONE, new RangeValidator<float>(0f, 1f));
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
|
||||
57
TTT/CS2/Configs/ShopItems/CS2ClusterGrenadeConfig.cs
Normal file
57
TTT/CS2/Configs/ShopItems/CS2ClusterGrenadeConfig.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Cvars;
|
||||
using CounterStrikeSharp.API.Modules.Cvars.Validators;
|
||||
using ShopAPI.Configs.Traitor;
|
||||
using TTT.API;
|
||||
using TTT.API.Storage;
|
||||
|
||||
namespace TTT.CS2.Configs.ShopItems;
|
||||
|
||||
public class CS2ClusterGrenadeConfig : IStorage<ClusterGrenadeConfig>,
|
||||
IPluginModule {
|
||||
public static readonly FakeConVar<int> CV_PRICE = new(
|
||||
"css_ttt_shop_clustergrenade_price",
|
||||
"Price of the Cluster Grenade item (Traitor)", 90, ConVarFlags.FCVAR_NONE,
|
||||
new RangeValidator<int>(0, 10000));
|
||||
|
||||
public static readonly FakeConVar<int> CV_GRENADE_COUNT = new(
|
||||
"css_ttt_shop_clustergrenade_count",
|
||||
"Number of grenades released upon explosion", 8, ConVarFlags.FCVAR_NONE,
|
||||
new RangeValidator<int>(1, 50));
|
||||
|
||||
public static readonly FakeConVar<string> CV_WEAPON_ID = new(
|
||||
"css_ttt_shop_clustergrenade_weapon",
|
||||
"Weapon entity ID used for the Cluster Grenade", "weapon_hegrenade",
|
||||
ConVarFlags.FCVAR_NONE);
|
||||
|
||||
public static readonly FakeConVar<float> CV_UP_FORCE = new(
|
||||
"css_ttt_shop_clustergrenade_up_force",
|
||||
"Upward force applied to cluster fragments", 200f, ConVarFlags.FCVAR_NONE,
|
||||
new RangeValidator<float>(0f, 1000f));
|
||||
|
||||
public static readonly FakeConVar<float> CV_THROW_FORCE = new(
|
||||
"css_ttt_shop_clustergrenade_throw_force",
|
||||
"Forward throw force applied to cluster fragments", 250f,
|
||||
ConVarFlags.FCVAR_NONE, new RangeValidator<float>(0f, 1000f));
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
public void Start() { }
|
||||
|
||||
public void Start(BasePlugin? plugin) {
|
||||
ArgumentNullException.ThrowIfNull(plugin, nameof(plugin));
|
||||
plugin.RegisterFakeConVars(this);
|
||||
}
|
||||
|
||||
public Task<ClusterGrenadeConfig?> Load() {
|
||||
var cfg = new ClusterGrenadeConfig {
|
||||
Price = CV_PRICE.Value,
|
||||
GrenadeCount = CV_GRENADE_COUNT.Value,
|
||||
UpForce = CV_UP_FORCE.Value,
|
||||
ThrowForce = CV_THROW_FORCE.Value
|
||||
};
|
||||
|
||||
return Task.FromResult<ClusterGrenadeConfig?>(cfg);
|
||||
}
|
||||
}
|
||||
44
TTT/CS2/Configs/ShopItems/CS2DnaScannerConfig.cs
Normal file
44
TTT/CS2/Configs/ShopItems/CS2DnaScannerConfig.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Cvars;
|
||||
using CounterStrikeSharp.API.Modules.Cvars.Validators;
|
||||
using ShopAPI.Configs.Detective;
|
||||
using TTT.API;
|
||||
using TTT.API.Storage;
|
||||
|
||||
namespace TTT.CS2.Configs.ShopItems;
|
||||
|
||||
public class CS2DnaScannerConfig : IStorage<DnaScannerConfig>, IPluginModule {
|
||||
public static readonly FakeConVar<int> CV_PRICE = new(
|
||||
"css_ttt_shop_dna_price", "Price of the DNA Scanner item (Detective)", 110,
|
||||
ConVarFlags.FCVAR_NONE, new RangeValidator<int>(0, 10000));
|
||||
|
||||
public static readonly FakeConVar<int> CV_MAX_SAMPLES = new(
|
||||
"css_ttt_shop_dna_max_samples",
|
||||
"Maximum number of DNA samples that can be stored at once", 0,
|
||||
ConVarFlags.FCVAR_NONE, new RangeValidator<int>(0, 100));
|
||||
|
||||
public static readonly FakeConVar<int> CV_DECAY_TIME_SECONDS = new(
|
||||
"css_ttt_shop_dna_decay_time",
|
||||
"Time (in seconds) before a DNA sample decays", 120, ConVarFlags.FCVAR_NONE,
|
||||
new RangeValidator<int>(10, 3600));
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
public void Start() { }
|
||||
|
||||
public void Start(BasePlugin? plugin) {
|
||||
ArgumentNullException.ThrowIfNull(plugin, nameof(plugin));
|
||||
plugin.RegisterFakeConVars(this);
|
||||
}
|
||||
|
||||
public Task<DnaScannerConfig?> Load() {
|
||||
var cfg = new DnaScannerConfig {
|
||||
Price = CV_PRICE.Value,
|
||||
MaxSamples = CV_MAX_SAMPLES.Value,
|
||||
DecayTime = TimeSpan.FromSeconds(CV_DECAY_TIME_SECONDS.Value)
|
||||
};
|
||||
|
||||
return Task.FromResult<DnaScannerConfig?>(cfg);
|
||||
}
|
||||
}
|
||||
37
TTT/CS2/Configs/ShopItems/CS2GlovesConfig.cs
Normal file
37
TTT/CS2/Configs/ShopItems/CS2GlovesConfig.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Cvars;
|
||||
using CounterStrikeSharp.API.Modules.Cvars.Validators;
|
||||
using ShopAPI.Configs.Traitor;
|
||||
using TTT.API;
|
||||
using TTT.API.Storage;
|
||||
|
||||
namespace TTT.CS2.Configs.ShopItems;
|
||||
|
||||
public class CS2GlovesConfig : IStorage<GlovesConfig>, IPluginModule {
|
||||
public static readonly FakeConVar<int> CV_PRICE = new(
|
||||
"css_ttt_shop_gloves_price", "Price of the Gloves item (Traitor)", 40,
|
||||
ConVarFlags.FCVAR_NONE, new RangeValidator<int>(0, 10000));
|
||||
|
||||
public static readonly FakeConVar<int> CV_MAX_USES = new(
|
||||
"css_ttt_shop_gloves_max_uses",
|
||||
"Maximum number of times the Gloves can be used before breaking", 5,
|
||||
ConVarFlags.FCVAR_NONE, new RangeValidator<int>(1, 100));
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
public void Start() { }
|
||||
|
||||
public void Start(BasePlugin? plugin) {
|
||||
ArgumentNullException.ThrowIfNull(plugin, nameof(plugin));
|
||||
plugin.RegisterFakeConVars(this);
|
||||
}
|
||||
|
||||
public Task<GlovesConfig?> Load() {
|
||||
var cfg = new GlovesConfig {
|
||||
Price = CV_PRICE.Value, MaxUses = CV_MAX_USES.Value
|
||||
};
|
||||
|
||||
return Task.FromResult<GlovesConfig?>(cfg);
|
||||
}
|
||||
}
|
||||
70
TTT/CS2/Configs/ShopItems/CS2HealthStationConfig.cs
Normal file
70
TTT/CS2/Configs/ShopItems/CS2HealthStationConfig.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Cvars;
|
||||
using CounterStrikeSharp.API.Modules.Cvars.Validators;
|
||||
using ShopAPI.Configs.Detective;
|
||||
using TTT.API;
|
||||
using TTT.API.Storage;
|
||||
|
||||
namespace TTT.CS2.Configs.ShopItems;
|
||||
|
||||
public class CS2HealthStationConfig : IStorage<HealthStationConfig>,
|
||||
IPluginModule {
|
||||
public static readonly FakeConVar<int> CV_PRICE = new(
|
||||
"css_ttt_shop_healthstation_price",
|
||||
"Price of the Health Station item (Detective)", 50, ConVarFlags.FCVAR_NONE,
|
||||
new RangeValidator<int>(0, 10000));
|
||||
|
||||
public static readonly FakeConVar<string> CV_USE_SOUND = new(
|
||||
"css_ttt_shop_healthstation_use_sound",
|
||||
"Sound played when using the Health Station", "sounds/buttons/blip1",
|
||||
ConVarFlags.FCVAR_NONE);
|
||||
|
||||
public static readonly FakeConVar<int> CV_HEALTH_INCREMENTS = new(
|
||||
"css_ttt_shop_healthstation_increments",
|
||||
"Number of health increments applied per use", 10, ConVarFlags.FCVAR_NONE,
|
||||
new RangeValidator<int>(1, 100));
|
||||
|
||||
public static readonly FakeConVar<int> CV_HEALTH_INTERVAL = new(
|
||||
"css_ttt_shop_healthstation_interval",
|
||||
"Interval (in seconds) between health increments", 1,
|
||||
ConVarFlags.FCVAR_NONE, new RangeValidator<int>(1, 60));
|
||||
|
||||
public static readonly FakeConVar<int> CV_STATION_HEALTH = new(
|
||||
"css_ttt_shop_healthstation_station_health",
|
||||
"Maximum health of the station object itself", 200, ConVarFlags.FCVAR_NONE,
|
||||
new RangeValidator<int>(50, 1000));
|
||||
|
||||
public static readonly FakeConVar<int> CV_TOTAL_HEALTH_GIVEN = new(
|
||||
"css_ttt_shop_healthstation_total_health_given",
|
||||
"Total health the station can provide before depleting (0 = infinite)", 0,
|
||||
ConVarFlags.FCVAR_NONE, new RangeValidator<int>(0, 10000));
|
||||
|
||||
public static readonly FakeConVar<float> CV_MAX_RANGE = new(
|
||||
"css_ttt_shop_healthstation_max_range",
|
||||
"Maximum range (in units) from which players can use the station", 256f,
|
||||
ConVarFlags.FCVAR_NONE, new RangeValidator<float>(50f, 2048f));
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
public void Start() { }
|
||||
|
||||
public void Start(BasePlugin? plugin) {
|
||||
ArgumentNullException.ThrowIfNull(plugin, nameof(plugin));
|
||||
plugin.RegisterFakeConVars(this);
|
||||
}
|
||||
|
||||
public Task<HealthStationConfig?> Load() {
|
||||
var cfg = new HealthStationConfig {
|
||||
Price = CV_PRICE.Value,
|
||||
UseSound = CV_USE_SOUND.Value,
|
||||
HealthIncrements = CV_HEALTH_INCREMENTS.Value,
|
||||
HealthInterval = TimeSpan.FromSeconds(CV_HEALTH_INTERVAL.Value),
|
||||
StationHealth = CV_STATION_HEALTH.Value,
|
||||
TotalHealthGiven = CV_TOTAL_HEALTH_GIVEN.Value,
|
||||
MaxRange = CV_MAX_RANGE.Value
|
||||
};
|
||||
|
||||
return Task.FromResult<HealthStationConfig?>(cfg);
|
||||
}
|
||||
}
|
||||
@@ -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(
|
||||
|
||||
38
TTT/CS2/Configs/ShopItems/CS2OneHitKnifeConfig.cs
Normal file
38
TTT/CS2/Configs/ShopItems/CS2OneHitKnifeConfig.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Cvars;
|
||||
using CounterStrikeSharp.API.Modules.Cvars.Validators;
|
||||
using ShopAPI.Configs.Traitor;
|
||||
using TTT.API;
|
||||
using TTT.API.Storage;
|
||||
|
||||
namespace TTT.CS2.Configs.ShopItems;
|
||||
|
||||
public class CS2OneHitKnifeConfig : IStorage<OneHitKnifeConfig>, IPluginModule {
|
||||
public static readonly FakeConVar<int> CV_PRICE = new(
|
||||
"css_ttt_shop_onehitknife_price",
|
||||
"Price of the One-Hit Knife item (Traitor)", 80, ConVarFlags.FCVAR_NONE,
|
||||
new RangeValidator<int>(0, 10000));
|
||||
|
||||
public static readonly FakeConVar<bool> CV_FRIENDLY_FIRE = new(
|
||||
"css_ttt_shop_onehitknife_friendly_fire",
|
||||
"Whether the One-Hit Knife can damage teammates", false,
|
||||
ConVarFlags.FCVAR_NONE);
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
public void Start() { }
|
||||
|
||||
public void Start(BasePlugin? plugin) {
|
||||
ArgumentNullException.ThrowIfNull(plugin, nameof(plugin));
|
||||
plugin.RegisterFakeConVars(this);
|
||||
}
|
||||
|
||||
public Task<OneHitKnifeConfig?> Load() {
|
||||
var cfg = new OneHitKnifeConfig {
|
||||
Price = CV_PRICE.Value, FriendlyFire = CV_FRIENDLY_FIRE.Value
|
||||
};
|
||||
|
||||
return Task.FromResult<OneHitKnifeConfig?>(cfg);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace TTT.CS2.Configs.ShopItems;
|
||||
public class CS2OneShotDeagleConfig : IStorage<OneShotDeagleConfig>,
|
||||
IPluginModule {
|
||||
public static readonly FakeConVar<int> CV_PRICE = new(
|
||||
"css_ttt_shop_onedeagle_price", "Price of the One-Shot Deagle item", 110,
|
||||
"css_ttt_shop_onedeagle_price", "Price of the One-Shot Deagle item", 125,
|
||||
ConVarFlags.FCVAR_NONE, new RangeValidator<int>(0, 10000));
|
||||
|
||||
public static readonly FakeConVar<bool> CV_FRIENDLY_FIRE = new(
|
||||
|
||||
54
TTT/CS2/Configs/ShopItems/CS2SilentAWPConfig.cs
Normal file
54
TTT/CS2/Configs/ShopItems/CS2SilentAWPConfig.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Cvars;
|
||||
using CounterStrikeSharp.API.Modules.Cvars.Validators;
|
||||
using ShopAPI.Configs.Traitor;
|
||||
using TTT.API;
|
||||
using TTT.API.Storage;
|
||||
|
||||
namespace TTT.CS2.Configs.ShopItems;
|
||||
|
||||
public class CS2SilentAWPConfig : IStorage<SilentAWPConfig>, IPluginModule {
|
||||
public static readonly FakeConVar<int> CV_PRICE = new(
|
||||
"css_ttt_shop_silentawp_price", "Price of the Silent AWP item (Traitor)",
|
||||
80, ConVarFlags.FCVAR_NONE, new RangeValidator<int>(0, 10000));
|
||||
|
||||
public static readonly FakeConVar<int> CV_WEAPON_INDEX = new(
|
||||
"css_ttt_shop_silentawp_index", "Weapon slot index for the Silent AWP", 9,
|
||||
ConVarFlags.FCVAR_NONE, new RangeValidator<int>(0, 64));
|
||||
|
||||
public static readonly FakeConVar<string> CV_WEAPON_ID = new(
|
||||
"css_ttt_shop_silentawp_weapon", "Weapon entity ID for the Silent AWP",
|
||||
"weapon_awp", ConVarFlags.FCVAR_NONE);
|
||||
|
||||
public static readonly FakeConVar<int> CV_RESERVE_AMMO = new(
|
||||
"css_ttt_shop_silentawp_reserve_ammo",
|
||||
"Reserve ammo count for the Silent AWP", 0, ConVarFlags.FCVAR_NONE,
|
||||
new RangeValidator<int>(0, 100));
|
||||
|
||||
public static readonly FakeConVar<int> CV_CURRENT_AMMO = new(
|
||||
"css_ttt_shop_silentawp_current_ammo",
|
||||
"Current ammo loaded in the Silent AWP", 1, ConVarFlags.FCVAR_NONE,
|
||||
new RangeValidator<int>(0, 10));
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
public void Start() { }
|
||||
|
||||
public void Start(BasePlugin? plugin) {
|
||||
ArgumentNullException.ThrowIfNull(plugin, nameof(plugin));
|
||||
plugin.RegisterFakeConVars(this);
|
||||
}
|
||||
|
||||
public Task<SilentAWPConfig?> Load() {
|
||||
var cfg = new SilentAWPConfig {
|
||||
Price = CV_PRICE.Value,
|
||||
WeaponIndex = CV_WEAPON_INDEX.Value,
|
||||
WeaponId = CV_WEAPON_ID.Value,
|
||||
ReserveAmmo = CV_RESERVE_AMMO.Value,
|
||||
CurrentAmmo = CV_CURRENT_AMMO.Value
|
||||
};
|
||||
|
||||
return Task.FromResult<SilentAWPConfig?>(cfg);
|
||||
}
|
||||
}
|
||||
30
TTT/CS2/Configs/ShopItems/CS2StickersConfig.cs
Normal file
30
TTT/CS2/Configs/ShopItems/CS2StickersConfig.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Cvars;
|
||||
using CounterStrikeSharp.API.Modules.Cvars.Validators;
|
||||
using ShopAPI.Configs.Detective;
|
||||
using TTT.API;
|
||||
using TTT.API.Storage;
|
||||
|
||||
namespace TTT.CS2.Configs.ShopItems;
|
||||
|
||||
public class CS2StickersConfig : IStorage<StickersConfig>, IPluginModule {
|
||||
public static readonly FakeConVar<int> CV_PRICE = new(
|
||||
"css_ttt_shop_stickers_price", "Price of the Stickers item (Detective)", 25,
|
||||
ConVarFlags.FCVAR_NONE, new RangeValidator<int>(0, 10000));
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
public void Start() { }
|
||||
|
||||
public void Start(BasePlugin? plugin) {
|
||||
ArgumentNullException.ThrowIfNull(plugin, nameof(plugin));
|
||||
plugin.RegisterFakeConVars(this);
|
||||
}
|
||||
|
||||
public Task<StickersConfig?> Load() {
|
||||
var cfg = new StickersConfig { Price = CV_PRICE.Value };
|
||||
|
||||
return Task.FromResult<StickersConfig?>(cfg);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using TTT.API;
|
||||
using TTT.API.Storage;
|
||||
using TTT.CS2.Validators;
|
||||
|
||||
namespace TTT.CS2.Configs;
|
||||
namespace TTT.CS2.Configs.ShopItems;
|
||||
|
||||
public class CS2TaserConfig : IStorage<TaserConfig>, IPluginModule {
|
||||
public static readonly FakeConVar<int> CV_PRICE = new(
|
||||
@@ -1,4 +1,5 @@
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||
using CounterStrikeSharp.API.Modules.Commands;
|
||||
using JetBrains.Annotations;
|
||||
@@ -29,9 +30,9 @@ public class BuyMenuHandler(IServiceProvider provider) : IPluginModule {
|
||||
{ "weapon_usp_silencer", "M4A1" },
|
||||
{ "weapon_sg556", "M4A1" },
|
||||
{ "weapon_mp5sd", "M4A1" },
|
||||
{ "weapon_decoy", "healthshot" },
|
||||
{ "weapon_awp", "AWP" },
|
||||
{ "weapon_hegrenade", "Cluster" }
|
||||
{ "weapon_hegrenade", "Cluster" },
|
||||
{ "weapon_decoy", "Teleport Decoy" },
|
||||
};
|
||||
|
||||
public void Dispose() { }
|
||||
@@ -49,6 +50,14 @@ public class BuyMenuHandler(IServiceProvider provider) : IPluginModule {
|
||||
}
|
||||
|
||||
inventory.RemoveWeapon(player, new BaseWeapon(ev.Weapon));
|
||||
switch (ev.Weapon) {
|
||||
case "weapon_m4a1_silencer":
|
||||
inventory.RemoveWeaponInSlot(player, 0);
|
||||
break;
|
||||
case "weapon_revolver":
|
||||
inventory.RemoveWeaponInSlot(player, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!shopAliases.TryGetValue(ev.Weapon, out var alias))
|
||||
return HookResult.Continue;
|
||||
|
||||
@@ -52,6 +52,17 @@ public class CombatHandler(IServiceProvider provider) : IPluginModule {
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
[GameEventHandler(HookMode.Pre)]
|
||||
public HookResult OnPlayerDamage(EventPlayerHurt ev, GameEventInfo info) {
|
||||
var player = ev.Userid;
|
||||
if (player == null) return HookResult.Continue;
|
||||
|
||||
hideAndTrackStats(ev);
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
private void hideAndTrackStats(EventPlayerDeath ev,
|
||||
CCSPlayerController player) {
|
||||
var victimStats = player.ActionTrackingServices?.MatchStats;
|
||||
@@ -89,6 +100,16 @@ public class CombatHandler(IServiceProvider provider) : IPluginModule {
|
||||
"m_pActionTrackingServices");
|
||||
}
|
||||
|
||||
private void hideAndTrackStats(EventPlayerHurt ev) {
|
||||
var attackerStats = ev.Attacker?.ActionTrackingServices?.MatchStats;
|
||||
|
||||
if (attackerStats == null) return;
|
||||
if (ev.Attacker == null) return;
|
||||
attackerStats.Damage -= ev.DmgHealth;
|
||||
Utilities.SetStateChanged(ev.Attacker, "CCSPlayerController",
|
||||
"m_pActionTrackingServices");
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
[GameEventHandler]
|
||||
public HookResult OnPlayerHurt(EventPlayerHurt ev, GameEventInfo _) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using TTT.API.Events;
|
||||
using JetBrains.Annotations;
|
||||
using TTT.API.Events;
|
||||
using TTT.API.Game;
|
||||
using TTT.CS2.Actions;
|
||||
using TTT.CS2.lang;
|
||||
using TTT.Game.Events.Player;
|
||||
using TTT.Game.Listeners;
|
||||
@@ -8,6 +10,7 @@ namespace TTT.CS2.GameHandlers.DamageCancelers;
|
||||
|
||||
public class TaserListenCanceler(IServiceProvider provider)
|
||||
: BaseListener(provider) {
|
||||
[UsedImplicitly]
|
||||
[EventHandler]
|
||||
public void OnHurt(PlayerDamagedEvent ev) {
|
||||
if (Games.ActiveGame is not { State: State.IN_PROGRESS }) return;
|
||||
@@ -23,5 +26,6 @@ public class TaserListenCanceler(IServiceProvider provider)
|
||||
|
||||
Messenger.Message(attacker,
|
||||
Locale[CS2Msgs.TASER_SCANNED(victim, Roles.GetRoles(victim).First())]);
|
||||
Games.ActiveGame.Logger.LogAction(new TaserAction(Roles, victim, attacker));
|
||||
}
|
||||
}
|
||||
26
TTT/CS2/GameHandlers/MapChangeCausesEndListener.cs
Normal file
26
TTT/CS2/GameHandlers/MapChangeCausesEndListener.cs
Normal 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.");
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public class TraitorChatHandler(IServiceProvider provider) : IPluginModule {
|
||||
|
||||
private HookResult onSay(CCSPlayerController? player,
|
||||
CommandInfo commandInfo) {
|
||||
if (mutedPlayers != null
|
||||
if (mutedPlayers != null && player != null && player.GetHealth() > 0
|
||||
&& mutedPlayers.Contains(player?.SteamID.ToString() ?? ""))
|
||||
return HookResult.Handled;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ using TTT.Game.Roles;
|
||||
namespace TTT.CS2.Items.PoisonShots;
|
||||
|
||||
public static class PoisonShotServiceCollection {
|
||||
public static void AddPoisonShots(this IServiceCollection services) {
|
||||
public static void AddPoisonShotsServices(this IServiceCollection services) {
|
||||
services.AddModBehavior<PoisonShotsItem>();
|
||||
services.AddModBehavior<PoisonShotsListener>();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ using TTT.Game.Roles;
|
||||
namespace TTT.CS2.Items.PoisonSmoke;
|
||||
|
||||
public static class PoisonSmokeServiceCollection {
|
||||
public static void AddPoisonSmoke(this IServiceCollection services) {
|
||||
public static void AddPoisonSmokeServices(this IServiceCollection services) {
|
||||
services.AddModBehavior<PoisonSmokeItem>();
|
||||
services.AddModBehavior<PoisonSmokeListener>();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ using TTT.Game.Roles;
|
||||
namespace TTT.CS2.Items.Station;
|
||||
|
||||
public static class HealthStationCollection {
|
||||
public static void AddHealthStation(this IServiceCollection collection) {
|
||||
public static void AddHealthStationServices(this IServiceCollection collection) {
|
||||
collection.AddModBehavior<HealthStation>();
|
||||
}
|
||||
}
|
||||
|
||||
39
TTT/CS2/Items/TeleportDecoy/TeleportDecoyItem.cs
Normal file
39
TTT/CS2/Items/TeleportDecoy/TeleportDecoyItem.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ShopAPI;
|
||||
using ShopAPI.Configs;
|
||||
using ShopAPI.Configs.Traitor;
|
||||
using TTT.API.Extensions;
|
||||
using TTT.API.Player;
|
||||
using TTT.API.Storage;
|
||||
using TTT.Game.Roles;
|
||||
|
||||
namespace TTT.CS2.Items.TeleportDecoy;
|
||||
|
||||
public static class TeleportDecoyServiceCollection {
|
||||
public static void AddTeleportDecoyServices(
|
||||
this IServiceCollection collection) {
|
||||
collection.AddModBehavior<TeleportDecoyItem>();
|
||||
collection.AddModBehavior<TeleportDecoyListener>();
|
||||
}
|
||||
}
|
||||
|
||||
public class TeleportDecoyItem(IServiceProvider provider)
|
||||
: RoleRestrictedItem<TraitorRole>(provider) {
|
||||
public override string Name
|
||||
=> Locale[TeleportDecoyMsgs.SHOP_ITEM_TELEPORT_DECOY];
|
||||
|
||||
public override string Description
|
||||
=> Locale[TeleportDecoyMsgs.SHOP_ITEM_TELEPORT_DECOY_DESC];
|
||||
|
||||
private TeleportDecoyConfig config
|
||||
=> Provider.GetService<IStorage<TeleportDecoyConfig>>()
|
||||
?.Load()
|
||||
.GetAwaiter()
|
||||
.GetResult() ?? new TeleportDecoyConfig();
|
||||
|
||||
public override ShopItemConfig Config => config;
|
||||
|
||||
public override void OnPurchase(IOnlinePlayer player) {
|
||||
Inventory.GiveWeapon(player, new BaseWeapon("weapon_decoy"));
|
||||
}
|
||||
}
|
||||
37
TTT/CS2/Items/TeleportDecoy/TeleportDecoyListener.cs
Normal file
37
TTT/CS2/Items/TeleportDecoy/TeleportDecoyListener.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ShopAPI;
|
||||
using TTT.API;
|
||||
using TTT.API.Player;
|
||||
|
||||
namespace TTT.CS2.Items.TeleportDecoy;
|
||||
|
||||
public class TeleportDecoyListener(IServiceProvider provider) : IPluginModule {
|
||||
private readonly IPlayerConverter<CCSPlayerController> converter =
|
||||
provider.GetRequiredService<IPlayerConverter<CCSPlayerController>>();
|
||||
|
||||
private readonly IShop shop = provider.GetRequiredService<IShop>();
|
||||
|
||||
public void Dispose() { }
|
||||
public void Start() { }
|
||||
|
||||
[UsedImplicitly]
|
||||
[GameEventHandler]
|
||||
public HookResult OnDecoyDetonate(EventDecoyDetonate ev, GameEventInfo _) {
|
||||
if (ev.Userid == null) return HookResult.Continue;
|
||||
var player = converter.GetPlayer(ev.Userid) as IOnlinePlayer;
|
||||
if (player == null) return HookResult.Continue;
|
||||
|
||||
if (!shop.HasItem<TeleportDecoyItem>(player)) return HookResult.Continue;
|
||||
|
||||
shop.RemoveItem<TeleportDecoyItem>(player);
|
||||
|
||||
var vec = new Vector(ev.X, ev.Y, ev.Z + 16);
|
||||
ev.Userid.Pawn.Value?.Teleport(vec);
|
||||
return HookResult.Continue;
|
||||
}
|
||||
}
|
||||
11
TTT/CS2/Items/TeleportDecoy/TeleportDecoyMsgs.cs
Normal file
11
TTT/CS2/Items/TeleportDecoy/TeleportDecoyMsgs.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using TTT.Locale;
|
||||
|
||||
namespace TTT.CS2.Items.TeleportDecoy;
|
||||
|
||||
public class TeleportDecoyMsgs {
|
||||
public static IMsg SHOP_ITEM_TELEPORT_DECOY
|
||||
=> MsgFactory.Create(nameof(SHOP_ITEM_TELEPORT_DECOY));
|
||||
|
||||
public static IMsg SHOP_ITEM_TELEPORT_DECOY_DESC
|
||||
=> MsgFactory.Create(nameof(SHOP_ITEM_TELEPORT_DECOY_DESC));
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
48
TTT/CS2/Listeners/MapHookListener.cs
Normal file
48
TTT/CS2/Listeners/MapHookListener.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using TTT.API.Events;
|
||||
using TTT.API.Player;
|
||||
using TTT.Game.Events.Game;
|
||||
using TTT.Game.Events.Player;
|
||||
using TTT.Game.Listeners;
|
||||
using TTT.Game.Roles;
|
||||
|
||||
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;
|
||||
|
||||
switch (ev.Role) {
|
||||
case TraitorRole:
|
||||
player.Pawn.Value?.AcceptInput("AddContext", null, null, "TRAITOR:1");
|
||||
break;
|
||||
case DetectiveRole:
|
||||
player.Pawn.Value?.AcceptInput("AddContext", null, null, "DETECTIVE:1");
|
||||
break;
|
||||
case InnocentRole:
|
||||
player.Pawn.Value?.AcceptInput("AddContext", null, null, "INNOCENT:1");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
[EventHandler]
|
||||
public void OnRoundEnd(GameInitEvent ev) {
|
||||
foreach (var player in Utilities.GetPlayers()) {
|
||||
if (player.Pawn.Value == null) continue;
|
||||
player.Pawn.Value.AcceptInput("RemoveContext", null, null, "TRAITOR");
|
||||
player.Pawn.Value.AcceptInput("RemoveContext", null, null, "DETECTIVE");
|
||||
player.Pawn.Value.AcceptInput("RemoveContext", null, null, "INNOCENT");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,14 @@ public class PlayerStatsTracker(IServiceProvider provider) : IListener {
|
||||
|
||||
private readonly ISet<int> revealedDeaths = new HashSet<int>();
|
||||
|
||||
private readonly IDictionary<int, (int, int)> roundKillsAndAssists =
|
||||
new Dictionary<int, (int, int)>();
|
||||
private readonly IDictionary<int, RoundData> roundStats =
|
||||
new Dictionary<int, RoundData>();
|
||||
|
||||
record RoundData {
|
||||
public int Kills;
|
||||
public int Assists;
|
||||
public int Damage;
|
||||
}
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
@@ -50,24 +56,39 @@ public class PlayerStatsTracker(IServiceProvider provider) : IListener {
|
||||
ev.Assister == null ? null : converter.GetPlayer(ev.Assister);
|
||||
|
||||
if (killer != null) {
|
||||
roundKillsAndAssists.TryGetValue(killer.Slot, out var def);
|
||||
def.Item1++;
|
||||
roundKillsAndAssists[killer.Slot] = def;
|
||||
roundStats.TryGetValue(killer.Slot, out var def);
|
||||
def ??= new RoundData();
|
||||
def.Kills++;
|
||||
roundStats[killer.Slot] = def;
|
||||
}
|
||||
|
||||
if (assister != null && assister != killer) {
|
||||
roundKillsAndAssists.TryGetValue(assister.Slot, out var def);
|
||||
def.Item2++;
|
||||
roundKillsAndAssists[assister.Slot] = def;
|
||||
roundStats.TryGetValue(assister.Slot, out var def);
|
||||
def ??= new RoundData();
|
||||
def.Assists++;
|
||||
roundStats[assister.Slot] = def;
|
||||
}
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
[EventHandler(Priority = Priority.HIGH)]
|
||||
public void OnDamage(PlayerDamagedEvent ev) {
|
||||
var attacker =
|
||||
ev.Attacker == null ? null : converter.GetPlayer(ev.Attacker);
|
||||
if (attacker == null) return;
|
||||
|
||||
roundStats.TryGetValue(attacker.Slot, out var def);
|
||||
def ??= new RoundData();
|
||||
def.Damage += ev.DmgDealt;
|
||||
roundStats[attacker.Slot] = def;
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
[EventHandler]
|
||||
public void OnRoundEnd(GameStateUpdateEvent ev) {
|
||||
if (ev.NewState == State.IN_PROGRESS) {
|
||||
revealedDeaths.Clear();
|
||||
roundKillsAndAssists.Clear();
|
||||
roundStats.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -100,15 +121,16 @@ public class PlayerStatsTracker(IServiceProvider provider) : IListener {
|
||||
var online = finder.GetOnline()
|
||||
.Select(p => converter.GetPlayer(p))
|
||||
.OfType<CCSPlayerController>()
|
||||
.Where(p => p.IsValid && roundKillsAndAssists.ContainsKey(p.Slot));
|
||||
.Where(p => p.IsValid && roundStats.ContainsKey(p.Slot));
|
||||
|
||||
foreach (var player in online) {
|
||||
var stats = player.ActionTrackingServices?.MatchStats;
|
||||
if (stats == null) continue;
|
||||
|
||||
var (kills, assists) = roundKillsAndAssists[player.Slot];
|
||||
stats.Kills += kills;
|
||||
stats.Assists += assists;
|
||||
if (!roundStats.TryGetValue(player.Slot, out var data)) continue;
|
||||
|
||||
stats.Kills += data.Kills;
|
||||
stats.Assists += data.Assists;
|
||||
Utilities.SetStateChanged(player, "CCSPlayerController",
|
||||
"m_pActionTrackingServices");
|
||||
}
|
||||
|
||||
@@ -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 _) {
|
||||
|
||||
@@ -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;
|
||||
@@ -118,9 +114,7 @@ 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() {
|
||||
return CreatePaddedName(Id, Name, namePadding + 8);
|
||||
}
|
||||
private string createPaddedName() { return CreatePaddedName(Id, Name, 24); }
|
||||
|
||||
public static string CreatePaddedName(string id, string name, int len) {
|
||||
var suffix = id.Length > 5 ? id[^5..] : id.PadLeft(5, '0');
|
||||
|
||||
21
TTT/CS2/Roles/CS2TraitorRole.cs
Normal file
21
TTT/CS2/Roles/CS2TraitorRole.cs
Normal 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";
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,4 +49,7 @@ SHOP_ITEM_SILENT_AWP: "Silent AWP"
|
||||
SHOP_ITEM_SILENT_AWP_DESC: "Receive a silenced AWP with limited ammo."
|
||||
|
||||
SHOP_ITEM_CLUSTER_GRENADE: "Cluster Grenade"
|
||||
SHOP_ITEM_CLUSTER_GRENADE_DESC: "A grenade that splits into multiple smaller grenades."
|
||||
SHOP_ITEM_CLUSTER_GRENADE_DESC: "A grenade that splits into multiple smaller grenades."
|
||||
|
||||
SHOP_ITEM_TELEPORT_DECOY: "Teleport Decoy"
|
||||
SHOP_ITEM_TELEPORT_DECOY_DESC: "A decoy that teleports you to it upon explosion."
|
||||
@@ -3,6 +3,7 @@ using TTT.API.Game;
|
||||
using TTT.API.Player;
|
||||
using TTT.API.Role;
|
||||
using TTT.Game.Events.Player;
|
||||
using TTT.Game.Roles;
|
||||
|
||||
namespace TTT.Game.Actions;
|
||||
|
||||
@@ -24,6 +25,12 @@ public class DamagedAction(IRoleAssigner roles, IPlayer victim,
|
||||
public string Verb => "damaged";
|
||||
public string Details => $"for {Damage} damage with {Weapon}";
|
||||
|
||||
public string Prefix
|
||||
=> PlayerRole != null && OtherRole != null
|
||||
&& PlayerRole is TraitorRole != OtherRole is TraitorRole ?
|
||||
"" :
|
||||
"[BAD] ";
|
||||
|
||||
#region ConstructorAliases
|
||||
|
||||
public DamagedAction(IServiceProvider provider, IPlayer victim,
|
||||
|
||||
@@ -3,6 +3,7 @@ using TTT.API.Game;
|
||||
using TTT.API.Player;
|
||||
using TTT.API.Role;
|
||||
using TTT.Game.Events.Player;
|
||||
using TTT.Game.Roles;
|
||||
|
||||
namespace TTT.Game.Actions;
|
||||
|
||||
@@ -10,7 +11,7 @@ public class DeathAction(IRoleAssigner roles, IPlayer victim, IPlayer? killer)
|
||||
: IAction {
|
||||
public DeathAction(IRoleAssigner roles, PlayerDeathEvent ev) : this(roles,
|
||||
ev.Player, ev.Killer) {
|
||||
Details = $"using {ev.Weapon}";
|
||||
if (!string.IsNullOrWhiteSpace(ev.Weapon)) Details = $"using {ev.Weapon}";
|
||||
}
|
||||
|
||||
public IPlayer Player { get; } = victim;
|
||||
@@ -34,10 +35,16 @@ public class DeathAction(IRoleAssigner roles, IPlayer victim, IPlayer? killer)
|
||||
$" [{OtherRole.Name.First(char.IsAsciiLetter)}]" :
|
||||
"";
|
||||
return Other is not null ?
|
||||
$"{Other}{oRole} {Verb} {Player}{pRole} {Details}" :
|
||||
$"{Player}{pRole} {Verb} {Details}";
|
||||
$"{Prefix}{Other}{oRole} {Verb} {Player}{pRole} {Details}" :
|
||||
$"{Prefix}{Player}{pRole} {Verb} {Details}";
|
||||
}
|
||||
|
||||
public string Prefix
|
||||
=> PlayerRole != null && OtherRole != null
|
||||
&& PlayerRole is TraitorRole != OtherRole is TraitorRole ?
|
||||
"" :
|
||||
"[BAD] ";
|
||||
|
||||
#region ConstructorAliases
|
||||
|
||||
public DeathAction(IServiceProvider provider, IPlayer victim, IPlayer? killer)
|
||||
|
||||
@@ -11,5 +11,7 @@ public class RoleAssignedAction(IPlayer player, IRole role) : IAction {
|
||||
public IRole? OtherRole { get; } = null;
|
||||
public string Id => "basegame.action.roleassigned";
|
||||
public string Verb => "was assigned";
|
||||
public string Details { get; } = role.Name;
|
||||
|
||||
public string Details { get; } =
|
||||
new(role.Name.Where(char.IsAsciiLetter).ToArray());
|
||||
}
|
||||
@@ -35,14 +35,18 @@ public sealed class KarmaStorage(IServiceProvider provider) : IKarmaService {
|
||||
return karmaElement.GetInt32();
|
||||
}
|
||||
|
||||
public Task Write(IPlayer key, int newData) {
|
||||
var data = new { steam_id = key.Id, karma = newData };
|
||||
public async Task Write(IPlayer key, int newData) {
|
||||
var oldKarma = await Load(key);
|
||||
var karmaUpdateEvent = new KarmaUpdateEvent(key, oldKarma, newData);
|
||||
provider.GetService<IEventBus>()?.Dispatch(karmaUpdateEvent);
|
||||
if (karmaUpdateEvent.IsCanceled) return;
|
||||
|
||||
var data = new { steam_id = key.Id, karma = karmaUpdateEvent.Karma };
|
||||
var payload = new StringContent(
|
||||
System.Text.Json.JsonSerializer.Serialize(data),
|
||||
System.Text.Encoding.UTF8, "application/json");
|
||||
|
||||
return client.PatchAsync("user/" + key.Id, payload);
|
||||
await client.PatchAsync("user/" + key.Id, payload);
|
||||
}
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
16
TTT/RTD/Actions/RolledAction.cs
Normal file
16
TTT/RTD/Actions/RolledAction.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using TTT.API.Game;
|
||||
using TTT.API.Player;
|
||||
using TTT.API.Role;
|
||||
|
||||
namespace TTT.RTD.Actions;
|
||||
|
||||
public class RolledAction(IRoleAssigner roles, IPlayer player, string roll)
|
||||
: IAction {
|
||||
public IPlayer Player { get; } = player;
|
||||
public IPlayer? Other { get; } = null;
|
||||
public IRole? PlayerRole { get; } = roles.GetRoles(player).FirstOrDefault();
|
||||
public IRole? OtherRole { get; } = null;
|
||||
public string Id { get; } = "rtd.action.rolled";
|
||||
public string Verb { get; } = "rolled";
|
||||
public string Details { get; } = roll;
|
||||
}
|
||||
107
TTT/RTD/AutoRTDCommand.cs
Normal file
107
TTT/RTD/AutoRTDCommand.cs
Normal 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";
|
||||
}
|
||||
}
|
||||
@@ -15,4 +15,10 @@
|
||||
<ProjectReference Include="..\Shop\Shop.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="MAULActainShared">
|
||||
<HintPath>..\CS2\ThirdParties\Binaries\MAULActainShared.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -8,10 +8,11 @@ public class ShopItemReward<TItem>(IServiceProvider provider)
|
||||
: RoundStartReward(provider) where TItem : IShopItem {
|
||||
private readonly IShop shop = provider.GetRequiredService<IShop>();
|
||||
|
||||
public override string Name => typeof(TItem).Name;
|
||||
public override string Name
|
||||
=> shop.Items.OfType<TItem>().FirstOrDefault()?.Name ?? typeof(TItem).Name;
|
||||
|
||||
public override string Description
|
||||
=> $"you will receive {("aeiou".Contains(Name.ToLower()[0]) ? "an" : "a")} {typeof(TItem).Name} next round";
|
||||
=> $"you will receive {("aeiou".Contains(Name.ToLower()[0]) ? "an" : "a")} {Name} item next round";
|
||||
|
||||
public override void GiveOnRound(IOnlinePlayer player) {
|
||||
var instance = shop.Items.OfType<TItem>().FirstOrDefault();
|
||||
|
||||
@@ -4,8 +4,10 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using TTT.API.Events;
|
||||
using TTT.API.Game;
|
||||
using TTT.API.Player;
|
||||
using TTT.API.Role;
|
||||
using TTT.Game.Events.Game;
|
||||
using TTT.Locale;
|
||||
using TTT.RTD.Actions;
|
||||
|
||||
namespace TTT.RTD;
|
||||
|
||||
@@ -16,12 +18,15 @@ public abstract class RoundStartReward(IServiceProvider provider)
|
||||
|
||||
private readonly IEventBus bus = provider.GetRequiredService<IEventBus>();
|
||||
|
||||
private readonly IRoleAssigner roles =
|
||||
provider.GetRequiredService<IRoleAssigner>();
|
||||
|
||||
public abstract string Name { get; }
|
||||
public abstract string Description { get; }
|
||||
|
||||
public void GrantReward(IOnlinePlayer player) { givenPlayers.Add(player); }
|
||||
public abstract void GiveOnRound(IOnlinePlayer player);
|
||||
|
||||
|
||||
protected readonly IMsgLocalizer Locale =
|
||||
provider.GetRequiredService<IMsgLocalizer>();
|
||||
|
||||
@@ -30,7 +35,10 @@ public abstract class RoundStartReward(IServiceProvider provider)
|
||||
public virtual void OnRoundStart(GameStateUpdateEvent ev) {
|
||||
if (ev.NewState != State.IN_PROGRESS) return;
|
||||
|
||||
foreach (var player in givenPlayers) GiveOnRound(player);
|
||||
foreach (var player in givenPlayers) {
|
||||
GiveOnRound(player);
|
||||
ev.Game.Logger.LogAction(new RolledAction(roles, player, Name));
|
||||
}
|
||||
|
||||
givenPlayers.Clear();
|
||||
}
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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>();
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
@@ -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}."
|
||||
@@ -13,7 +13,7 @@ using TTT.Game.Roles;
|
||||
namespace TTT.Shop.Items.Healthshot;
|
||||
|
||||
public static class HealthshotServiceCollection {
|
||||
public static void AddHealthshot(this IServiceCollection services) {
|
||||
public static void AddHealthshotServices(this IServiceCollection services) {
|
||||
services.AddModBehavior<HealthshotItem>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ using TTT.Game.Roles;
|
||||
namespace TTT.Shop.Items.Taser;
|
||||
|
||||
public static class TaserServiceCollection {
|
||||
public static void AddTaserItem(this IServiceCollection collection) {
|
||||
public static void AddTaserServices(this IServiceCollection collection) {
|
||||
collection.AddModBehavior<TaserItem>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -12,6 +12,7 @@ using TTT.CS2.Items.PoisonShots;
|
||||
using TTT.CS2.Items.PoisonSmoke;
|
||||
using TTT.CS2.Items.SilentAWP;
|
||||
using TTT.CS2.Items.Station;
|
||||
using TTT.CS2.Items.TeleportDecoy;
|
||||
using TTT.Shop.Commands;
|
||||
using TTT.Shop.Items;
|
||||
using TTT.Shop.Items.Detective.Stickers;
|
||||
@@ -49,15 +50,16 @@ public static class ShopServiceCollection {
|
||||
collection.AddDeagleServices();
|
||||
collection.AddDnaScannerServices();
|
||||
collection.AddGlovesServices();
|
||||
collection.AddHealthStation();
|
||||
collection.AddHealthshot();
|
||||
collection.AddHealthStationServices();
|
||||
collection.AddHealthshotServices();
|
||||
collection.AddInnoCompassServices();
|
||||
collection.AddM4A1Services();
|
||||
collection.AddOneHitKnifeService();
|
||||
collection.AddPoisonShots();
|
||||
collection.AddPoisonSmoke();
|
||||
collection.AddPoisonShotsServices();
|
||||
collection.AddPoisonSmokeServices();
|
||||
collection.AddSilentAWPServices();
|
||||
collection.AddStickerServices();
|
||||
collection.AddTaserItem();
|
||||
collection.AddTaserServices();
|
||||
collection.AddTeleportDecoyServices();
|
||||
}
|
||||
}
|
||||
@@ -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."
|
||||
@@ -34,7 +34,7 @@ SHOP_CANNOT_PURCHASE_WITH_REASON: "%SHOP_PREFIX%You cannot purchase this item: {
|
||||
SHOP_PURCHASED: "%SHOP_PREFIX%You purchased {white}{0}{grey}."
|
||||
SHOP_LIST_FOOTER: "%SHOP_PREFIX%You are %an% {0}{grey}, you have {yellow}{1}{grey} %CREDITS_NAME%%s%."
|
||||
|
||||
CREDITS_NAME: "credit"
|
||||
CREDITS_NAME: "point"
|
||||
CREDITS_GIVEN: "%SHOP_PREFIX%{0}{1} %CREDITS_NAME%%s%"
|
||||
CREDITS_GIVEN_REASON: "%SHOP_PREFIX%{0}{1} %CREDITS_NAME%%s% {grey}({white}{2}{grey})"
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
namespace ShopAPI.Configs.Traitor;
|
||||
|
||||
public record SilentAWPConfig : ShopItemConfig, IWeapon {
|
||||
public override int Price { get; init; } = 90;
|
||||
public int WeaponIndex { get; } = 9;
|
||||
public string WeaponId { get; } = "weapon_awp";
|
||||
public int? ReserveAmmo { get; } = 0;
|
||||
public int? CurrentAmmo { get; } = 2;
|
||||
public override int Price { get; init; } = 80;
|
||||
public int WeaponIndex { get; init; } = 9;
|
||||
public string WeaponId { get; init; } = "weapon_awp";
|
||||
public int? ReserveAmmo { get; init; } = 0;
|
||||
public int? CurrentAmmo { get; init; } = 1;
|
||||
}
|
||||
5
TTT/ShopAPI/Configs/Traitor/TeleportDecoyConfig.cs
Normal file
5
TTT/ShopAPI/Configs/Traitor/TeleportDecoyConfig.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace ShopAPI.Configs.Traitor;
|
||||
|
||||
public record TeleportDecoyConfig : ShopItemConfig {
|
||||
public override int Price { get; init; } = 80;
|
||||
}
|
||||
@@ -11,6 +11,7 @@ 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;
|
||||
|
||||
@@ -21,14 +22,18 @@ public class BhopRound(IServiceProvider provider)
|
||||
.GetResult() ?? new BhopRoundConfig();
|
||||
|
||||
public override void ApplyRoundEffects() {
|
||||
Server.ExecuteCommand("sv_enablebunnyhopping 1");
|
||||
Server.ExecuteCommand("sv_autobunnyhopping 1");
|
||||
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.ExecuteCommand("sv_enablebunnyhopping 0");
|
||||
Server.ExecuteCommand("sv_autobunnyhopping 0");
|
||||
Server.NextWorldUpdate(() => {
|
||||
Server.ExecuteCommand("sv_enablebunnyhopping 0");
|
||||
Server.ExecuteCommand("sv_autobunnyhopping 0");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ public class SpeedRound(IServiceProvider provider)
|
||||
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;
|
||||
@@ -43,7 +44,8 @@ public class SpeedRound(IServiceProvider provider)
|
||||
public override void ApplyRoundEffects() {
|
||||
Provider.GetService<RoundTimerListener>()?.EndTimer?.Dispose();
|
||||
|
||||
setTime(config.InitialSeconds);
|
||||
Server.RunOnTick(Server.TickCount + 2,
|
||||
() => setTime(config.InitialSeconds));
|
||||
}
|
||||
|
||||
private void addTime(TimeSpan span) {
|
||||
@@ -66,7 +68,11 @@ public class SpeedRound(IServiceProvider provider)
|
||||
EndReason.TIMEOUT(new InnocentRole(Provider)))));
|
||||
}
|
||||
|
||||
public override void OnGameState(GameStateUpdateEvent ev) { }
|
||||
public override void OnGameState(GameStateUpdateEvent ev) {
|
||||
if (ev.NewState != State.FINISHED) return;
|
||||
|
||||
endTimer?.Dispose();
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
[EventHandler]
|
||||
|
||||
45
TTT/SpecialRound/Rounds/VanillaRound.cs
Normal file
45
TTT/SpecialRound/Rounds/VanillaRound.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ShopAPI.Events;
|
||||
using SpecialRound.lang;
|
||||
using SpecialRoundAPI;
|
||||
using TTT.API.Events;
|
||||
using TTT.API.Messages;
|
||||
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 readonly IMessenger messenger =
|
||||
provider.GetRequiredService<IMessenger>();
|
||||
|
||||
private readonly IMsgLocalizer locale =
|
||||
provider.GetRequiredService<IMsgLocalizer>();
|
||||
|
||||
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;
|
||||
|
||||
messenger.Message(ev.Player, locale[RoundMsgs.VANILLA_ROUND_REMINDER]);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SpecialRound.Rounds;
|
||||
using SpecialRoundAPI;
|
||||
using TTT.API.Extensions;
|
||||
|
||||
@@ -8,5 +9,9 @@ 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>();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
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;
|
||||
@@ -45,19 +47,32 @@ public class SpecialRoundStarter(IServiceProvider provider)
|
||||
if (Random.Shared.NextSingle() > config.SpecialRoundChance) return;
|
||||
|
||||
var specialRound = getSpecialRound();
|
||||
if (specialRound is null) return;
|
||||
|
||||
TryStartSpecialRound(specialRound);
|
||||
}
|
||||
|
||||
private AbstractSpecialRound? getSpecialRound() {
|
||||
return Provider.GetServices<AbstractSpecialRound>()
|
||||
.OrderBy(_ => Random.Shared.Next())
|
||||
.FirstOrDefault();
|
||||
private AbstractSpecialRound getSpecialRound() {
|
||||
var rounds = Provider.GetServices<ITerrorModule>()
|
||||
.OfType<AbstractSpecialRound>()
|
||||
.Where(r => r.Config.Weight > 0)
|
||||
.ToList();
|
||||
var totalWeight = rounds.Sum(r => r.Config.Weight);
|
||||
var roll = Random.Shared.NextDouble() * totalWeight;
|
||||
foreach (var round in rounds) {
|
||||
roll -= round.Config.Weight;
|
||||
if (roll <= 0) return round;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException(
|
||||
"Failed to select a special round. This should never happen.");
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -1,11 +1,23 @@
|
||||
using SpecialRoundAPI;
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,22 @@
|
||||
using TTT.Locale;
|
||||
using SpecialRoundAPI;
|
||||
using TTT.Locale;
|
||||
|
||||
namespace SpecialRound.lang;
|
||||
|
||||
public class RoundMsgs {
|
||||
public static IMsg SPECIAL_ROUND_STARTED(string name) {
|
||||
return MsgFactory.Create(nameof(SPECIAL_ROUND_STARTED), name);
|
||||
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));
|
||||
|
||||
public static IMsg VANILLA_ROUND_REMINDER
|
||||
=> MsgFactory.Create(nameof(VANILLA_ROUND_REMINDER));
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
SPECIAL_ROUND_STARTED: "%PREFIX%This round is a {purple}Special Round{grey}! This round is a: {yellow}{0}{grey} round!"
|
||||
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_BHOP: " {Yellow}BHOP{grey}: Bunny hopping is enabled! Hold jump to move faster!"
|
||||
SPECIAL_ROUND_VANILLA: " {green}VANILLA{grey}: The shop has been disabled!"
|
||||
VANILLA_ROUND_REMINDER: "%SHOP_PREFIX%This is a {purple}Vanilla{grey} round. The shop is disabled."
|
||||
@@ -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 ?
|
||||
|
||||
@@ -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"
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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}."
|
||||
Reference in New Issue
Block a user