From 85cf6d57764910ead568a9b898cc451be245174f Mon Sep 17 00:00:00 2001 From: MSWS Date: Fri, 1 Nov 2024 15:00:38 -0700 Subject: [PATCH] Mark everyone as rebel on last guard --- mod/Jailbreak.LastGuard/LastGuard.cs | 17 ++++++++++------- mod/Jailbreak.LastRequest/LastRequestManager.cs | 9 +++++++-- .../Mod/LastGuard/ILastGuardService.cs | 2 ++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/mod/Jailbreak.LastGuard/LastGuard.cs b/mod/Jailbreak.LastGuard/LastGuard.cs index dead9acd..6b057197 100644 --- a/mod/Jailbreak.LastGuard/LastGuard.cs +++ b/mod/Jailbreak.LastGuard/LastGuard.cs @@ -14,6 +14,7 @@ using Jailbreak.Public.Behaviors; using Jailbreak.Public.Mod.LastGuard; using Jailbreak.Public.Mod.LastRequest; +using Jailbreak.Public.Mod.Rebel; using Jailbreak.Public.Utils; using Jailbreak.Validator; using Microsoft.Extensions.DependencyInjection; @@ -21,8 +22,8 @@ namespace Jailbreak.LastGuard; -public class LastGuard(ILGLocale notifications, ILastRequestManager lrManager) - : ILastGuardService, IPluginBehavior { +public class LastGuard(ILGLocale notifications, ILastRequestManager lrManager, + IRebelService rebel) : ILastGuardService, IPluginBehavior { public static readonly FakeConVar CV_ALWAYS_OVERRIDE_CT = new( "css_jb_lg_apply_lower_hp", "If true, the LG will be forced lower health if calculated"); @@ -66,7 +67,7 @@ public class LastGuard(ILGLocale notifications, ILastRequestManager lrManager) private readonly Random rng = new(); private bool canStart; - private bool isLastGuard; + public bool IsLastGuardActive { get; private set; } private List lastGuardPrisoners = []; public void Start(BasePlugin basePlugin, bool hotreload) { @@ -82,7 +83,7 @@ public void StartLastGuard(CCSPlayerController lastGuard) { if (guardPlayerPawn == null || !guardPlayerPawn.IsValid) return; - isLastGuard = true; + IsLastGuardActive = true; var stats = API.Gangs?.Services.GetService(); if (stats != null) { @@ -134,6 +135,8 @@ public void StartLastGuard(CCSPlayerController lastGuard) { .ToAllCenter() .ToAllChat(); + foreach (var player in lastGuardPrisoners) rebel.MarkRebel(player); + if (string.IsNullOrEmpty(CV_LG_WEAPON.Value)) return; foreach (var player in lastGuardPrisoners) @@ -161,7 +164,7 @@ public HookResult OnPlayerDeathEvent(EventPlayerDeath @event, if (player == null) return HookResult.Continue; checkLastGuard(@event.Userid); - if (!isLastGuard) return HookResult.Continue; + if (!IsLastGuardActive) return HookResult.Continue; if (player.Team != CsTeam.Terrorist) return HookResult.Continue; @@ -204,7 +207,7 @@ private bool playerHasGun(CCSPlayerController player) { private void checkLastGuard(CCSPlayerController? poi) { if (poi == null) return; - if (isLastGuard) return; + if (IsLastGuardActive) return; lastGuardPrisoners.Remove(poi); if (poi.Team != CsTeam.CounterTerrorist) return; var aliveCts = Utilities.GetPlayers() @@ -223,7 +226,7 @@ private void checkLastGuard(CCSPlayerController? poi) { [GameEventHandler] public HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info) { - isLastGuard = false; + IsLastGuardActive = false; return HookResult.Continue; } diff --git a/mod/Jailbreak.LastRequest/LastRequestManager.cs b/mod/Jailbreak.LastRequest/LastRequestManager.cs index c630c6ac..58219c73 100644 --- a/mod/Jailbreak.LastRequest/LastRequestManager.cs +++ b/mod/Jailbreak.LastRequest/LastRequestManager.cs @@ -14,15 +14,18 @@ using Jailbreak.Public; using Jailbreak.Public.Extensions; using Jailbreak.Public.Mod.Damage; +using Jailbreak.Public.Mod.LastGuard; using Jailbreak.Public.Mod.LastRequest; using Jailbreak.Public.Mod.LastRequest.Enums; +using Jailbreak.Public.Mod.Rebel; using Jailbreak.Public.Utils; using Microsoft.Extensions.DependencyInjection; using MStatsShared; namespace Jailbreak.LastRequest; -public class LastRequestManager(ILRLocale messages, IServiceProvider provider) +public class LastRequestManager(ILRLocale messages, IServiceProvider provider, + ILastGuardService lastGuard, IRebelService rebel) : ILastRequestManager, IDamageBlocker { public static readonly FakeConVar CV_LR_BASE_TIME = new("css_jb_lr_time_base", @@ -49,7 +52,7 @@ public class LastRequestManager(ILRLocale messages, IServiceProvider provider) public void Start(BasePlugin basePlugin, bool hotreload) { var stats = API.Gangs?.Services.GetService(); if (stats == null) return; - + stats.Stats.Add(new LRStat()); } @@ -146,6 +149,8 @@ public void EnableLR(CCSPlayerController? died = null) { if (player.Team != CsTeam.Terrorist) continue; if (died != null && player.SteamID == died.SteamID) continue; + + if (lastGuard.IsLastGuardActive) rebel.UnmarkRebel(player); player.ExecuteClientCommandFromServer("css_lr"); } diff --git a/public/Jailbreak.Public/Mod/LastGuard/ILastGuardService.cs b/public/Jailbreak.Public/Mod/LastGuard/ILastGuardService.cs index 38a0a698..5cf202c1 100644 --- a/public/Jailbreak.Public/Mod/LastGuard/ILastGuardService.cs +++ b/public/Jailbreak.Public/Mod/LastGuard/ILastGuardService.cs @@ -6,4 +6,6 @@ public interface ILastGuardService { void StartLastGuard(CCSPlayerController lastGuard); public void DisableLastGuardForRound(); + + bool IsLastGuardActive { get; } } \ No newline at end of file