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..1e97741d 100644 --- a/mod/Jailbreak.RTD/Rewards/CreditReward.cs +++ b/mod/Jailbreak.RTD/Rewards/CreditReward.cs @@ -1,24 +1,37 @@ -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 string Name => credits + " Credit"; + public static readonly string PREFIX = + $" {ChatColors.Purple}[{ChatColors.LightPurple}RTD{ChatColors.Purple}]"; - public string Description - => "You won " + credits + " credit" + (credits == 1 ? "" : "s") - + (credits > 500 ? "!" : "."); + public string Name => $"{credits} credit{(credits == 1 ? "" : "s")}"; - public bool Enabled => false; // TODO: Implement + public string Description => $"You won {Name}{(credits > 500 ? "!" : ".")}"; - public bool PrepareReward(int userid) { - // TODO: When we do implement, set their credits here - return true; - } + public bool Enabled => API.Gangs != null; + + 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 diff --git a/mod/Jailbreak.Warden/Commands/CountCommandsBehavior.cs b/mod/Jailbreak.Warden/Commands/CountCommandsBehavior.cs index 964bb157..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; } @@ -40,6 +42,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 diff --git a/mod/Jailbreak.Warden/Commands/WardenOpenCommandsBehavior.cs b/mod/Jailbreak.Warden/Commands/WardenOpenCommandsBehavior.cs index b7d815f3..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.", 30, + "Minimum seconds warden must wait before being able to open the cells.", 25, customValidators: new RangeValidator(0, 300)); public bool OpenedCells { get; set; } 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 =