From 84fb944a54be9cdb27b606ef3346058470097e3d Mon Sep 17 00:00:00 2001 From: MSWS Date: Mon, 21 Oct 2024 21:24:53 -0700 Subject: [PATCH 1/8] Fix count command not outputting --- mod/Jailbreak.Warden/Commands/CountCommandsBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/Jailbreak.Warden/Commands/CountCommandsBehavior.cs b/mod/Jailbreak.Warden/Commands/CountCommandsBehavior.cs index 964bb157..238da3fc 100644 --- a/mod/Jailbreak.Warden/Commands/CountCommandsBehavior.cs +++ b/mod/Jailbreak.Warden/Commands/CountCommandsBehavior.cs @@ -40,6 +40,6 @@ public void Command_Count(CCSPlayerController? executor, CommandInfo info) { var prisoners = PlayerUtil.FromTeam(CsTeam.Terrorist) .Count(markers.InMarker); - locale.PrisonersInMarker(prisoners); + locale.PrisonersInMarker(prisoners).ToChat(executor); } } \ No newline at end of file From b4e14f5061a85f9c6078a13d9b55fb4b74f62796 Mon Sep 17 00:00:00 2001 From: MSWS Date: Mon, 21 Oct 2024 21:41:58 -0700 Subject: [PATCH 2/8] Add credit rewards --- mod/Jailbreak.RTD/Jailbreak.RTD.csproj | 3 +++ mod/Jailbreak.RTD/RTDRewarder.cs | 4 ++- mod/Jailbreak.RTD/RewardGenerator.cs | 24 ++++++++++++------ mod/Jailbreak.RTD/Rewards/ColorReward.cs | 2 ++ mod/Jailbreak.RTD/Rewards/CreditReward.cs | 31 +++++++++++++++++------ 5 files changed, 47 insertions(+), 17 deletions(-) diff --git a/mod/Jailbreak.RTD/Jailbreak.RTD.csproj b/mod/Jailbreak.RTD/Jailbreak.RTD.csproj index 9d36a223..929c377d 100644 --- a/mod/Jailbreak.RTD/Jailbreak.RTD.csproj +++ b/mod/Jailbreak.RTD/Jailbreak.RTD.csproj @@ -13,6 +13,9 @@ + + ..\..\public\Jailbreak.Public\Mixin\GangsAPI.dll + ..\..\public\Jailbreak.Public\Mixin\MAULActainShared.dll diff --git a/mod/Jailbreak.RTD/RTDRewarder.cs b/mod/Jailbreak.RTD/RTDRewarder.cs index 65478d56..711f609d 100644 --- a/mod/Jailbreak.RTD/RTDRewarder.cs +++ b/mod/Jailbreak.RTD/RTDRewarder.cs @@ -37,7 +37,9 @@ public HookResult OnSpawn(EventPlayerSpawn @event, GameEventInfo info) { if (!reward.CanGrantReward(player)) return HookResult.Continue; Server.RunOnTick(Server.TickCount + 2, () => { - logs.Append("Granted", reward.Name, "to", logs.Player(player)); + if (!player.IsValid) return; + if (reward.Name != "Nothing") + logs.Append("Granted", reward.Name, "to", logs.Player(player)); reward.GrantReward(id); rewards.Remove(id); }); diff --git a/mod/Jailbreak.RTD/RewardGenerator.cs b/mod/Jailbreak.RTD/RewardGenerator.cs index e9ad3049..31e3eefd 100644 --- a/mod/Jailbreak.RTD/RewardGenerator.cs +++ b/mod/Jailbreak.RTD/RewardGenerator.cs @@ -13,13 +13,13 @@ namespace Jailbreak.RTD; public class RewardGenerator(IZoneManager mgr, IC4Service bomb, IWardenSelectionService warden) : IPluginBehavior, IRewardGenerator { - private static readonly float PROB_LOTTERY = 1 / 5000f; - private static readonly float PROB_EXTREMELY_LOW = 1 / 1000f; - private static readonly float PROB_VERY_LOW = 1 / 100f; - private static readonly float PROB_LOW = 1 / 20f; - private static readonly float PROB_MEDIUM = 1 / 10f; - private static readonly float PROB_OFTEN = 1 / 5f; - private static readonly float PROB_VERY_OFTEN = 1 / 2f; + private const float PROB_LOTTERY = 1 / 3000f; + private const float PROB_EXTREMELY_LOW = 1 / 800f; + private const float PROB_VERY_LOW = 1 / 100f; + private const float PROB_LOW = 1 / 20f; + private const float PROB_MEDIUM = 1 / 10f; + private const float PROB_OFTEN = 1 / 5f; + private const float PROB_VERY_OFTEN = 1 / 2f; private readonly List<(IRTDReward, float)> rewards = []; @@ -32,11 +32,14 @@ public void Start(BasePlugin basePlugin) { rewards.AddRange([ // Very often (new NothingReward(), PROB_VERY_OFTEN), + (new CreditReward(1), PROB_VERY_OFTEN), + (new CreditReward(-1), PROB_VERY_OFTEN), // Often (new WeaponReward("weapon_healthshot"), PROB_OFTEN), (new WeaponReward("weapon_decoy"), PROB_OFTEN), (new HPReward(110), PROB_OFTEN), (new ArmorReward(15), PROB_OFTEN), + (new CreditReward(-10), PROB_VERY_OFTEN), // Medium (new CreditReward(1), PROB_MEDIUM), (new CreditReward(2), PROB_MEDIUM), @@ -50,6 +53,7 @@ public void Start(BasePlugin basePlugin) { (new ArmorReward(150), PROB_MEDIUM), (new GuaranteedWardenReward(warden), PROB_MEDIUM), (new WeaponReward("weapon_g3sg1", CsTeam.CounterTerrorist), PROB_MEDIUM), + (new CreditReward(5), PROB_MEDIUM), // Low (new ChatSpyReward(basePlugin), PROB_LOW), @@ -63,7 +67,7 @@ public void Start(BasePlugin basePlugin) { (new AmmoWeaponReward("weapon_negev", 0, 5), PROB_LOW), (new CannotUseReward(basePlugin, WeaponType.SNIPERS), PROB_LOW), (new CannotUseReward(basePlugin, WeaponType.HEAVY), PROB_LOW), - (new HPReward(1), PROB_LOW / 2), + (new CreditReward(50), PROB_LOW), (new HPReward(1), PROB_LOW / 2), // Very low (new FakeBombReward(), PROB_VERY_LOW * 2), @@ -75,12 +79,16 @@ public void Start(BasePlugin basePlugin) { (new RandomTeleportReward(mgr), PROB_VERY_LOW), (new BombReward(bomb), PROB_VERY_LOW), (new CannotUseReward(basePlugin, WeaponType.UTILITY), PROB_VERY_LOW), + (new CreditReward(-100), PROB_VERY_LOW), + (new CreditReward(500), PROB_VERY_LOW), (new AmmoWeaponReward("weapon_awp", 1, 0), PROB_VERY_LOW / 2), // Extremely low (new AmmoWeaponReward("weapon_awp", 3, 0), PROB_EXTREMELY_LOW), (new WeaponReward("weapon_glock"), PROB_EXTREMELY_LOW), (new CannotUseReward(basePlugin, WeaponType.GUNS), PROB_EXTREMELY_LOW), + (new CreditReward(1000), PROB_EXTREMELY_LOW), + (new CreditReward(-5000), PROB_EXTREMELY_LOW / 2), // Lottery (new CreditReward(10000), PROB_LOTTERY) diff --git a/mod/Jailbreak.RTD/Rewards/ColorReward.cs b/mod/Jailbreak.RTD/Rewards/ColorReward.cs index a727967d..fea84d08 100644 --- a/mod/Jailbreak.RTD/Rewards/ColorReward.cs +++ b/mod/Jailbreak.RTD/Rewards/ColorReward.cs @@ -1,4 +1,5 @@ using System.Drawing; +using CounterStrikeSharp.API; using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Modules.Utils; using Jailbreak.Public.Extensions; @@ -42,6 +43,7 @@ public bool CanGrantReward(CCSPlayerController player) { public bool GrantReward(CCSPlayerController player) { player.SetColor(color); + Server.RunOnTick(Server.TickCount + 2, () => GrantReward(player)); return true; } } \ No newline at end of file diff --git a/mod/Jailbreak.RTD/Rewards/CreditReward.cs b/mod/Jailbreak.RTD/Rewards/CreditReward.cs index 327aaa80..21dddec0 100644 --- a/mod/Jailbreak.RTD/Rewards/CreditReward.cs +++ b/mod/Jailbreak.RTD/Rewards/CreditReward.cs @@ -1,24 +1,39 @@ -using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API; +using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Modules.Utils; +using GangsAPI.Data; +using GangsAPI.Services; +using Jailbreak.Public; using Jailbreak.Public.Mod.RTD; +using Microsoft.Extensions.DependencyInjection; namespace Jailbreak.RTD.Rewards; public class CreditReward(int credits) : IRTDReward { + public static readonly string PREFIX = + $" {ChatColors.Purple}[{ChatColors.LightPurple}RTD{ChatColors.Purple}]"; + public string Name => credits + " Credit"; public string Description => "You won " + credits + " credit" + (credits == 1 ? "" : "s") + (credits > 500 ? "!" : "."); - public bool Enabled => false; // TODO: Implement + public bool Enabled => API.Gangs != null; - public bool PrepareReward(int userid) { - // TODO: When we do implement, set their credits here - return true; - } + public bool PrepareReward(CCSPlayerController player) { + var eco = API.Gangs?.Services.GetService(); + if (eco == null) return false; + var wrapper = new PlayerWrapper(player); + eco.Grant(wrapper, credits, true, "RTD"); + + if (Math.Abs(credits) >= 5000) { + Server.PrintToChatAll( + $"{PREFIX} {ChatColors.Yellow}{wrapper.Name} {ChatColors.Default}won the jackpot of {ChatColors.Green}{credits} {ChatColors.Default}credits!"); + } - public bool GrantReward(CCSPlayerController player) { - // We would have already set their credits in PrepareReward, so do nothing here return true; } + + public bool GrantReward(CCSPlayerController player) { return true; } } \ No newline at end of file From d208da441e1591a2f237e7174a205bdc852e930d Mon Sep 17 00:00:00 2001 From: MSWS Date: Fri, 25 Oct 2024 14:02:40 -0700 Subject: [PATCH 3/8] Improve pluralization --- mod/Jailbreak.RTD/Rewards/CreditReward.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mod/Jailbreak.RTD/Rewards/CreditReward.cs b/mod/Jailbreak.RTD/Rewards/CreditReward.cs index 21dddec0..fb894e39 100644 --- a/mod/Jailbreak.RTD/Rewards/CreditReward.cs +++ b/mod/Jailbreak.RTD/Rewards/CreditReward.cs @@ -13,11 +13,9 @@ public class CreditReward(int credits) : IRTDReward { public static readonly string PREFIX = $" {ChatColors.Purple}[{ChatColors.LightPurple}RTD{ChatColors.Purple}]"; - public string Name => credits + " Credit"; + public string Name => $"{credits} credit{(credits == 1 ? "" : "s")}"; - public string Description - => "You won " + credits + " credit" + (credits == 1 ? "" : "s") - + (credits > 500 ? "!" : "."); + public string Description => $"You won {Name} {(credits > 500 ? "!" : ".")}"; public bool Enabled => API.Gangs != null; From 018df9cb3cc4ab0ddda8f1652fc1ae202700df52 Mon Sep 17 00:00:00 2001 From: MSWS Date: Fri, 25 Oct 2024 14:45:06 -0700 Subject: [PATCH 4/8] Reduce open command cooldown --- mod/Jailbreak.Warden/Commands/WardenOpenCommandsBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/Jailbreak.Warden/Commands/WardenOpenCommandsBehavior.cs b/mod/Jailbreak.Warden/Commands/WardenOpenCommandsBehavior.cs index b7d815f3..44f78076 100644 --- a/mod/Jailbreak.Warden/Commands/WardenOpenCommandsBehavior.cs +++ b/mod/Jailbreak.Warden/Commands/WardenOpenCommandsBehavior.cs @@ -19,7 +19,7 @@ public class WardenOpenCommandsBehavior(IWardenService warden, IZoneManager zoneManager) : IPluginBehavior, IWardenOpenCommand { public static readonly FakeConVar CV_OPEN_COMMAND_COOLDOWN = new( "css_jb_warden_open_cooldown", - "Minimum seconds warden must wait before being able to open the cells.", 30, + "Minimum seconds warden must wait before being able to open the cells.", 20, customValidators: new RangeValidator(0, 300)); public bool OpenedCells { get; set; } From 84c9ec98ba8642b9e4095b01f97fb2b3a7657bf0 Mon Sep 17 00:00:00 2001 From: MSWS Date: Fri, 25 Oct 2024 14:54:11 -0700 Subject: [PATCH 5/8] Fix spacing again --- mod/Jailbreak.RTD/Rewards/CreditReward.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/Jailbreak.RTD/Rewards/CreditReward.cs b/mod/Jailbreak.RTD/Rewards/CreditReward.cs index fb894e39..1e97741d 100644 --- a/mod/Jailbreak.RTD/Rewards/CreditReward.cs +++ b/mod/Jailbreak.RTD/Rewards/CreditReward.cs @@ -15,7 +15,7 @@ public class CreditReward(int credits) : IRTDReward { public string Name => $"{credits} credit{(credits == 1 ? "" : "s")}"; - public string Description => $"You won {Name} {(credits > 500 ? "!" : ".")}"; + public string Description => $"You won {Name}{(credits > 500 ? "!" : ".")}"; public bool Enabled => API.Gangs != null; From 97c2d95665bc67b3e1e2ae22a30a5312238e073b Mon Sep 17 00:00:00 2001 From: MSWS Date: Fri, 25 Oct 2024 14:55:53 -0700 Subject: [PATCH 6/8] Bump up to 25 seconds --- mod/Jailbreak.Warden/Commands/WardenOpenCommandsBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/Jailbreak.Warden/Commands/WardenOpenCommandsBehavior.cs b/mod/Jailbreak.Warden/Commands/WardenOpenCommandsBehavior.cs index 44f78076..6a85e2e2 100644 --- a/mod/Jailbreak.Warden/Commands/WardenOpenCommandsBehavior.cs +++ b/mod/Jailbreak.Warden/Commands/WardenOpenCommandsBehavior.cs @@ -19,7 +19,7 @@ public class WardenOpenCommandsBehavior(IWardenService warden, IZoneManager zoneManager) : IPluginBehavior, IWardenOpenCommand { public static readonly FakeConVar CV_OPEN_COMMAND_COOLDOWN = new( "css_jb_warden_open_cooldown", - "Minimum seconds warden must wait before being able to open the cells.", 20, + "Minimum seconds warden must wait before being able to open the cells.", 25, customValidators: new RangeValidator(0, 300)); public bool OpenedCells { get; set; } From 2830a188c3f60dba98d9a25a583b51ccf4747948 Mon Sep 17 00:00:00 2001 From: MSWS Date: Fri, 25 Oct 2024 15:15:09 -0700 Subject: [PATCH 7/8] Specify seconds left till count can be used --- mod/Jailbreak.Warden/Commands/CountCommandsBehavior.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mod/Jailbreak.Warden/Commands/CountCommandsBehavior.cs b/mod/Jailbreak.Warden/Commands/CountCommandsBehavior.cs index 238da3fc..4be310de 100644 --- a/mod/Jailbreak.Warden/Commands/CountCommandsBehavior.cs +++ b/mod/Jailbreak.Warden/Commands/CountCommandsBehavior.cs @@ -27,8 +27,10 @@ public void Command_Count(CCSPlayerController? executor, CommandInfo info) { return; } - if (RoundUtil.GetTimeElapsed() < CV_COUNT_COMMAND_COOLDOWN.Value) { - locale.CannotCountYet(CV_COUNT_COMMAND_COOLDOWN.Value).ToChat(executor); + var timeTillCount = + CV_COUNT_COMMAND_COOLDOWN.Value - RoundUtil.GetTimeElapsed(); + if (timeTillCount > 0) { + locale.CannotCountYet(timeTillCount).ToChat(executor); return; } From 20ce8b33e989429152bbe6d4d4c112b018dcda66 Mon Sep 17 00:00:00 2001 From: MSWS Date: Fri, 25 Oct 2024 18:50:47 -0700 Subject: [PATCH 8/8] Fix convar ids --- mod/Jailbreak.Warden/Global/WardenBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/Jailbreak.Warden/Global/WardenBehavior.cs b/mod/Jailbreak.Warden/Global/WardenBehavior.cs index 6a778737..6dd15f3c 100644 --- a/mod/Jailbreak.Warden/Global/WardenBehavior.cs +++ b/mod/Jailbreak.Warden/Global/WardenBehavior.cs @@ -40,7 +40,7 @@ public class WardenBehavior(ILogger logger, IMuteService mute, IServiceProvider provider) : IPluginBehavior, IWardenService { public static readonly FakeConVar CV_ARMOR_EQUAL = - new("css_jb_hp_outnumbered", "Health points for CTs have equal balance", 50, + new("css_jb_hp_equal", "Health points for when CTs have equal ratio", 50, ConVarFlags.FCVAR_NONE, new RangeValidator(1, 200)); public static readonly FakeConVar CV_ARMOR_OUTNUMBER =