Compare commits

...

10 Commits

Author SHA1 Message Date
MSWS
acb3be9132 Require on actual team to be alive 2025-10-30 18:09:14 -07:00
MSWS
bbcc998559 Up 1 knife item 2025-10-30 17:57:00 -07:00
MSWS
56781c6ae8 More item balancing, name updating, bug fix 2025-10-30 17:56:09 -07:00
MSWS
0ca983943d Revert "Fetch playername from object if available"
This reverts commit 8cd8e14e18.
2025-10-29 16:28:56 -07:00
MSWS
8cd8e14e18 Fetch playername from object if available 2025-10-29 15:27:13 -07:00
MSWS
57ef5e3e24 Use pretty name for rtd reward description 2025-10-28 20:31:04 -07:00
MSWS
9c99d316aa Revert "Revert "fix: Allow typing if dead even with muted roll""
This reverts commit e679c5193b.
2025-10-28 19:26:57 -07:00
MSWS
e679c5193b Revert "fix: Allow typing if dead even with muted roll"
This reverts commit daa24a0e87.
2025-10-28 19:26:43 -07:00
MSWS
6ece0450bb fix: Reduce volume of health station 2025-10-28 19:26:26 -07:00
MSWS
daa24a0e87 fix: Allow typing if dead even with muted roll 2025-10-28 19:20:42 -07:00
12 changed files with 50 additions and 18 deletions

View File

@@ -7,7 +7,7 @@ public interface IPlayer : IEquatable<IPlayer> {
/// </summary>
string Id { get; }
string Name { get; }
string Name { get; set; }
bool IEquatable<IPlayer>.Equals(IPlayer? other) {
if (other is null) return false;

View File

@@ -82,6 +82,7 @@ public static class CS2ServiceCollection {
collection.AddModBehavior<TraitorChatHandler>();
collection.AddModBehavior<PlayerMuter>();
collection.AddModBehavior<MapChangeCausesEndListener>();
collection.AddModBehavior<NameUpdater>();
// collection.AddModBehavior<EntityTargetHandlers>();
// Damage Cancelers

View File

@@ -12,7 +12,7 @@ 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,
"Price of the Cluster Grenade item (Traitor)", 100, ConVarFlags.FCVAR_NONE,
new RangeValidator<int>(0, 10000));
public static readonly FakeConVar<int> CV_GRENADE_COUNT = new(

View File

@@ -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", 125,
"css_ttt_shop_onedeagle_price", "Price of the One-Shot Deagle item", 130,
ConVarFlags.FCVAR_NONE, new RangeValidator<int>(0, 10000));
public static readonly FakeConVar<bool> CV_FRIENDLY_FIRE = new(

View File

@@ -10,7 +10,7 @@ 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,
"css_ttt_shop_stickers_price", "Price of the Stickers item (Detective)", 35,
ConVarFlags.FCVAR_NONE, new RangeValidator<int>(0, 10000));
public void Dispose() { }

View File

@@ -0,0 +1,24 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
using TTT.API;
using TTT.API.Events;
using TTT.API.Player;
using TTT.Game.Events.Game;
using TTT.Game.Listeners;
namespace TTT.CS2.GameHandlers;
public class NameUpdater(IServiceProvider provider) : BaseListener(provider) {
private readonly IPlayerConverter<CCSPlayerController> converter =
provider.GetRequiredService<IPlayerConverter<CCSPlayerController>>();
[UsedImplicitly]
[EventHandler]
public void OnGameInit(GameInitEvent ev) {
foreach (var player in Utilities.GetPlayers()) {
converter.GetPlayer(player).Name = player.PlayerName;
}
}
}

View File

@@ -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;

View File

@@ -1,5 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using TTT.API.Player;
namespace TTT.CS2.Player;
@@ -53,7 +54,7 @@ public class CS2Player : IOnlinePlayer, IEquatable<CS2Player> {
}
public string Id { get; }
public string Name { get; }
public string Name { get; set; }
public int Health {
get => Player?.Pawn.Value != null ? Player.Pawn.Value.Health : 0;
@@ -96,7 +97,11 @@ public class CS2Player : IOnlinePlayer, IEquatable<CS2Player> {
}
public bool IsAlive {
get => Player != null && Player.Pawn.Value is { Health: > 0 };
get
=> Player != null && Player is {
Team : CsTeam.CounterTerrorist or CsTeam.Terrorist,
Pawn.Value.Health: > 0
};
set
=> throw new NotSupportedException(

View File

@@ -8,28 +8,30 @@ using TTT.Game.Events.Player;
namespace TTT.Game.Roles;
public class RoleAssigner(IServiceProvider provider) : IRoleAssigner {
private readonly IDictionary<IPlayer, ICollection<IRole>> assignedRoles =
new Dictionary<IPlayer, ICollection<IRole>>();
private readonly IDictionary<string, ICollection<IRole>> assignedRoles =
new Dictionary<string, ICollection<IRole>>();
private readonly IEventBus bus = provider.GetRequiredService<IEventBus>();
private readonly IMessenger? onlineMessenger =
provider.GetService<IMessenger>();
private static readonly Random rng = new();
public void AssignRoles(ISet<IOnlinePlayer> players, IList<IRole> roles) {
assignedRoles.Clear();
var shuffled = players.OrderBy(_ => Guid.NewGuid()).ToHashSet();
var shuffled = players.OrderBy(_ => rng.NextDouble()).ToHashSet();
bool roleAssigned;
do { roleAssigned = tryAssignRole(shuffled, roles); } while (roleAssigned);
}
public Task<ICollection<IRole>?> Load(IPlayer key) {
assignedRoles.TryGetValue(key, out var roles);
assignedRoles.TryGetValue(key.Id, out var roles);
return Task.FromResult(roles);
}
public Task Write(IPlayer key, ICollection<IRole> newData) {
assignedRoles[key] = newData;
assignedRoles[key.Id] = newData;
return Task.CompletedTask;
}
@@ -44,9 +46,9 @@ public class RoleAssigner(IServiceProvider provider) : IRoleAssigner {
if (ev.IsCanceled) continue;
if (!assignedRoles.ContainsKey(player))
assignedRoles[player] = new List<IRole>();
assignedRoles[player].Add(ev.Role);
if (!assignedRoles.ContainsKey(player.Id))
assignedRoles[player.Id] = new List<IRole>();
assignedRoles[player.Id].Add(ev.Role);
ev.Role.OnAssign(player);
onlineMessenger?.Debug(

View File

@@ -12,7 +12,7 @@ public class ShopItemReward<TItem>(IServiceProvider provider)
=> 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} item 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();

View File

@@ -1,6 +1,6 @@
namespace ShopAPI.Configs.Traitor;
public record OneHitKnifeConfig : ShopItemConfig {
public override int Price { get; init; } = 70;
public override int Price { get; init; } = 80;
public bool FriendlyFire { get; init; } = true;
}

View File

@@ -10,7 +10,7 @@ public class TestPlayer(string id, string name) : IOnlinePlayer {
// public ICollection<IRole> Roles { get; } = [];
public string Id { get; } = id;
public string Name { get; } = name;
public string Name { get; set; } = name;
public int Health { get; set; } = 100;
public int MaxHealth { get; set; } = 100;