From ed1115e7dab2b7d3d45cf4aea87b0ef2002c3070 Mon Sep 17 00:00:00 2001 From: destoer Date: Thu, 8 Feb 2024 12:25:13 +0000 Subject: [PATCH 1/6] renable riot, switch to v163, add lr failsafe --- Cs2Jailbreak.csproj | 2 +- gamedata/Cs2Jailbreak.json | 8 +------- src/Jail.cs | 4 ++-- src/LastRequest/Dodgeball.cs | 17 ++++++++++++++++- src/LastRequest/Grenade.cs | 18 ++++++++++++++++++ src/LastRequest/LRBase.cs | 22 ++++++++++++++++++++++ src/LastRequest/LastRequest.cs | 7 +++---- src/LastRequest/LastRequestMenu.cs | 10 +++++----- src/Lib/Lib.cs | 6 +++--- src/Lib/Weapon.cs | 2 +- src/SpecialDay/SpecialDay.cs | 4 ++-- 11 files changed, 74 insertions(+), 26 deletions(-) diff --git a/Cs2Jailbreak.csproj b/Cs2Jailbreak.csproj index 9d18261..1156460 100644 --- a/Cs2Jailbreak.csproj +++ b/Cs2Jailbreak.csproj @@ -7,7 +7,7 @@ - + diff --git a/gamedata/Cs2Jailbreak.json b/gamedata/Cs2Jailbreak.json index 23f33a3..0e0dcd2 100644 --- a/gamedata/Cs2Jailbreak.json +++ b/gamedata/Cs2Jailbreak.json @@ -1,9 +1,3 @@ { - "CBasePlayerController_SetPawn": { - "signatures": { - "library": "server", - "windows": "\\x44\\x88\\x4C\\x24\\x2A\\x55\\x57", - "linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x41\\x55\\x41\\x54\\x49\\x89\\xFC\\x53\\x48\\x89\\xF3\\x48\\x81\\xEC\\xC8\\x00\\x00\\x00" - } - } + } \ No newline at end of file diff --git a/src/Jail.cs b/src/Jail.cs index b8197b5..215eb96 100644 --- a/src/Jail.cs +++ b/src/Jail.cs @@ -138,7 +138,7 @@ public class JailConfig : BasePluginConfig // main plugin file, controls central hooking // defers to warden, lr and sd -[MinimumApiVersion(141)] +[MinimumApiVersion(163)] public class JailPlugin : BasePlugin, IPluginConfig { // Global event settings, used to filter plugin activits @@ -184,7 +184,7 @@ public static void PurgePlayerStats(CCSPlayerController? player) public override string ModuleName => "CS2 Jailbreak - destoer"; - public override string ModuleVersion => "v0.3.5"; + public override string ModuleVersion => "v0.3.6"; public override void Load(bool hotReload) { diff --git a/src/LastRequest/Dodgeball.cs b/src/LastRequest/Dodgeball.cs index 1c44feb..d3d7a52 100644 --- a/src/LastRequest/Dodgeball.cs +++ b/src/LastRequest/Dodgeball.cs @@ -46,6 +46,11 @@ public override void InitPlayer(CCSPlayerController player) } } + public override void PairActivate() + { + DelayFailSafe(35.0f); + } + public override void PlayerHurt(int damage, int health, int hitgroup) { CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot); @@ -59,7 +64,17 @@ public override void PlayerHurt(int damage, int health, int hitgroup) public override void GrenadeThrown() { CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot); - GiveLRNadeDelay(1.4f,"weapon_flashbang"); + + if(!failSafe) + { + GiveLRNadeDelay(1.4f,"weapon_flashbang"); + } + + // failsafe timer is up give a he grenade + else + { + GiveLRNadeDelay(1.4f,"weapon_hegrenade"); + } } public override void EntCreated(CEntityInstance entity) diff --git a/src/LastRequest/Grenade.cs b/src/LastRequest/Grenade.cs index 23896db..4b9bfcf 100644 --- a/src/LastRequest/Grenade.cs +++ b/src/LastRequest/Grenade.cs @@ -45,7 +45,25 @@ public override void InitPlayer(CCSPlayerController player) } } } + + public override void PairActivate() + { + DelayFailSafe(35.0f); + } + + + public override void PlayerHurt(int damage, int health, int hitgroup) + { + CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot); + // instantly drop the player if the failsafe is active + if(player.IsLegalAlive() && failSafe) + { + player.Announce(LastRequest.LR_PREFIX,"Boom!"); + player.Slay(); + } + } + public override void GrenadeThrown() { CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot); diff --git a/src/LastRequest/LRBase.cs b/src/LastRequest/LRBase.cs index 5cf2261..eaa16f8 100644 --- a/src/LastRequest/LRBase.cs +++ b/src/LastRequest/LRBase.cs @@ -64,6 +64,9 @@ public void Cleanup() // clean up laser Lib.KillTimer(ref laserTimer); + // killthe fail safe timer + Lib.KillTimer(ref failsafeTimer); + laser.Destroy(); countdown.Kill(); @@ -278,6 +281,21 @@ public void CountdownStart() countdown.Start(lrName,5,this,PrintCountdown,manager.ActivateLR); } + public void FailSafeActivate() + { + // clean up timer + failsafeTimer = null; + + failSafe = true; + Chat.Announce(LastRequest.LR_PREFIX,$"{lrName} fail-safe active"); + } + + public void DelayFailSafe(float delay) + { + Chat.Announce(LastRequest.LR_PREFIX,$"fail-safe active in {delay} seconds"); + JailPlugin.globalCtx.AddTimer(delay,FailSafeActivate,CSTimer.TimerFlags.STOP_ON_MAPCHANGE); + } + public void LaserTick() { // get both players and check they are valid @@ -350,6 +368,10 @@ public virtual void WeaponZoom() {} Line laser = new Line(); + CSTimer.Timer? failsafeTimer = null; + public bool failSafe = false; + + CSTimer.Timer? laserTimer = null; // managed timer diff --git a/src/LastRequest/LastRequest.cs b/src/LastRequest/LastRequest.cs index 8babb3b..0f1e46a 100644 --- a/src/LastRequest/LastRequest.cs +++ b/src/LastRequest/LastRequest.cs @@ -402,15 +402,14 @@ public void LRCmdInternal(CCSPlayerController? player,bool bypass, CommandInfo c { lrMenu.AddMenuOption("Knife rebel",StartKnifeRebel); lrMenu.AddMenuOption("Rebel",StartRebel); - /* + if(Config.riotEnable) { - lrMenu.AddMenuOption("Riot",start_riot); + lrMenu.AddMenuOption("Riot",StartRiot); } - */ } - ChatMenus.OpenMenu(player, lrMenu); + MenuManager.OpenChatMenu(player, lrMenu); } public void LRCmd(CCSPlayerController? player, CommandInfo command) diff --git a/src/LastRequest/LastRequestMenu.cs b/src/LastRequest/LastRequestMenu.cs index dc6cbb8..218d930 100644 --- a/src/LastRequest/LastRequestMenu.cs +++ b/src/LastRequest/LastRequestMenu.cs @@ -101,7 +101,7 @@ public void PickOption(CCSPlayerController? player, ChatMenuOption option) lrMenu.AddMenuOption("High speed", PickedOption); lrMenu.AddMenuOption("One hit", PickedOption); - ChatMenus.OpenMenu(player, lrMenu); + MenuManager.OpenChatMenu(player, lrMenu); break; } @@ -112,7 +112,7 @@ public void PickOption(CCSPlayerController? player, ChatMenuOption option) lrMenu.AddMenuOption("Vanilla", PickedOption); lrMenu.AddMenuOption("Low gravity", PickedOption); - ChatMenus.OpenMenu(player, lrMenu); + MenuManager.OpenChatMenu(player, lrMenu); break; } @@ -123,7 +123,7 @@ public void PickOption(CCSPlayerController? player, ChatMenuOption option) lrMenu.AddMenuOption("Awp", PickedOption); lrMenu.AddMenuOption("Scout", PickedOption); - ChatMenus.OpenMenu(player, lrMenu); + MenuManager.OpenChatMenu(player, lrMenu); break; } @@ -134,7 +134,7 @@ public void PickOption(CCSPlayerController? player, ChatMenuOption option) lrMenu.AddMenuOption("Vanilla", PickedOption); lrMenu.AddMenuOption("Low gravity", PickedOption); - ChatMenus.OpenMenu(player, lrMenu); + MenuManager.OpenChatMenu(player, lrMenu); break; } @@ -149,7 +149,7 @@ public void PickOption(CCSPlayerController? player, ChatMenuOption option) lrMenu.AddMenuOption("Five seven",PickedOption); lrMenu.AddMenuOption("Dual Elite",PickedOption); - ChatMenus.OpenMenu(player, lrMenu); + MenuManager.OpenChatMenu(player, lrMenu); break; } diff --git a/src/Lib/Lib.cs b/src/Lib/Lib.cs index 91023a5..832a898 100644 --- a/src/Lib/Lib.cs +++ b/src/Lib/Lib.cs @@ -99,7 +99,7 @@ static public void InvokePlayerMenu(CCSPlayerController? invoke, String name, return; } - ChatMenu menu = new ChatMenu(name); + var menu = new ChatMenu(name); foreach(var player in Utilities.GetPlayers()) { @@ -109,7 +109,7 @@ static public void InvokePlayerMenu(CCSPlayerController? invoke, String name, } } - ChatMenus.OpenMenu(invoke, menu); + MenuManager.OpenChatMenu(invoke, menu); } public static void ColourMenu(CCSPlayerController? player,Action callback, String name) @@ -126,7 +126,7 @@ public static void ColourMenu(CCSPlayerController? player,Action Date: Thu, 8 Feb 2024 14:55:15 +0000 Subject: [PATCH 2/6] fix restrict on dodgeball failsafe --- src/Jail.cs | 6 ++---- src/LastRequest/Dodgeball.cs | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Jail.cs b/src/Jail.cs index 215eb96..3f36e28 100644 --- a/src/Jail.cs +++ b/src/Jail.cs @@ -524,7 +524,7 @@ HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info) CCSPlayerController? killer = @event.Attacker; // NOTE: have to check IsConnected incase this is tripped by a dc - + /* // hide t killing ct if(Config.hideKills && victim.IsConnected() && killer.IsConnected() && killer.IsT() && victim.IsCt()) { @@ -557,15 +557,13 @@ HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info) info.DontBroadcast = true; } - - + */ if(victim.IsLegal() && victim.IsConnected()) { warden.Death(victim,killer); lr.Death(victim); sd.Death(victim,killer); } - return HookResult.Continue; } diff --git a/src/LastRequest/Dodgeball.cs b/src/LastRequest/Dodgeball.cs index d3d7a52..f9826f4 100644 --- a/src/LastRequest/Dodgeball.cs +++ b/src/LastRequest/Dodgeball.cs @@ -73,6 +73,7 @@ public override void GrenadeThrown() // failsafe timer is up give a he grenade else { + weaponRestrict = "hegrenade"; GiveLRNadeDelay(1.4f,"weapon_hegrenade"); } } From b07813658b61cd0ea6d92b21ecc54f04f8192596 Mon Sep 17 00:00:00 2001 From: destoer Date: Thu, 8 Feb 2024 15:08:58 +0000 Subject: [PATCH 3/6] change kill feed handling --- src/Jail.cs | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/src/Jail.cs b/src/Jail.cs index 3f36e28..5c347ac 100644 --- a/src/Jail.cs +++ b/src/Jail.cs @@ -524,40 +524,14 @@ HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info) CCSPlayerController? killer = @event.Attacker; // NOTE: have to check IsConnected incase this is tripped by a dc - /* + // hide t killing ct if(Config.hideKills && victim.IsConnected() && killer.IsConnected() && killer.IsT() && victim.IsCt()) { - //@event.Attacker = player; - // fire event as is to T - foreach(CCSPlayerController? player in Utilities.GetPlayers()) - { - if(player.IsLegal()) - { - if(player.IsT()) - { - // T gets full event - @event.Userid = victim; - @event.Attacker = killer; - - @event.FireEventToClient(player); - } - - else - { - // ct gets a suicide - @event.Userid = victim; - @event.Attacker = victim; - @event.Assister = victim; - - @event.FireEventToClient(player); - } - } - } - + killer.Announce(Warden.WARDEN_PREFIX,$"You killed: {victim.PlayerName}"); info.DontBroadcast = true; } - */ + if(victim.IsLegal() && victim.IsConnected()) { warden.Death(victim,killer); From 4d4bbecc622453918af8ffa931872b8ccda46ad1 Mon Sep 17 00:00:00 2001 From: destoer Date: Thu, 8 Feb 2024 15:13:38 +0000 Subject: [PATCH 4/6] update readme --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d50b8d7..7183769 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,11 @@ Download the latest release from the releases tab and copy it into the counterst NOTE: this plugin only operates correctly on linux -windows has a couple of places where a !is_windows() check wraps buggy code +windows has a couple of places where a !IsWindows() check wraps buggy code +namely OnTakeDamage # Warden TODO -Warden Laser and T laser +T laser Auto unstuck @@ -29,8 +30,6 @@ Handicap Warden Ring -Refactor stat API - # LR TODO Port crash, sumo @@ -40,7 +39,7 @@ Add beacons # SD TODO -Waiting on player colour and respawn issues fixed for these +Waiting on no block issues being fixed, and trace for laser wars Zombie, Gun game, Laser wars From a2875972669f0b9407d87ddb13adda10e1660071 Mon Sep 17 00:00:00 2001 From: destoer Date: Thu, 8 Feb 2024 15:17:37 +0000 Subject: [PATCH 5/6] remove debug text --- src/LastRequest/Rebel.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/LastRequest/Rebel.cs b/src/LastRequest/Rebel.cs index b16cba8..e8c7f67 100644 --- a/src/LastRequest/Rebel.cs +++ b/src/LastRequest/Rebel.cs @@ -99,7 +99,6 @@ public void RiotRespawn() { if(player.IsLegal() && !player.IsLegalAlive()) { - Server.PrintToChatAll($"Respawn {player.PlayerName}"); player.Respawn(); } } From 57db5be24dbca39e6dde16d1857300a82cbf384e Mon Sep 17 00:00:00 2001 From: destoer Date: Thu, 8 Feb 2024 15:35:54 +0000 Subject: [PATCH 6/6] impl prefix translations --- lang/en.json | 10 +++++++++- src/Jail.cs | 17 +++++++++++++++++ src/LastRequest/LastRequest.cs | 2 +- src/Lib/Entity.cs | 2 +- src/SpecialDay/SpecialDay.cs | 2 +- src/Warden/JailPlayer.cs | 2 +- src/Warden/Mute.cs | 2 +- src/Warden/Team.cs | 2 +- src/Warden/Warday.cs | 2 +- src/Warden/Warden.cs | 2 +- 10 files changed, 34 insertions(+), 9 deletions(-) diff --git a/lang/en.json b/lang/en.json index 4511c15..632d174 100644 --- a/lang/en.json +++ b/lang/en.json @@ -53,6 +53,9 @@ "warden.give_freeday_cmd": "give_freeday", "warden.give_pardon_cmd": "give_pardon", "warden.colour_cmd": "colour", + "warden.warden_prefix": "{green}[Warden]: {white}", + "warden.door_prefix": "{green}[Door]: {white}", + "warden.team_prefix": "{green}[Team]: {white}", "warden.give_pardon": "{0} has been pardoned", "warden.give_freeday": "{0} has been given a freeday", @@ -78,11 +81,14 @@ "mute.thirty": "All t's are muted for the first 30 seconds", "mute.speak_quietly": "T's may now speak quietly", "mute.end_round": "You are muted until the end of the round", + "mute.mute_prefix": "{green}[Mute]: {white}", "warday.live": "Weapons live!", "warday.location": "warday at {0}", + "warday.warday_prefix": "{green}[Warday]: {white}", "rebel.kill": "{0} killed the rebel {1}", + "rebel.rebel_prefix": "{green}[Rebel]: {white}", "block.enable": "Block enabled", "block.disable": "Block disabled", @@ -118,6 +124,7 @@ "sd.start_cmd": "sd", "sd.start_ff_cmd": "sd_ff", "sd.cancel_cmd": "sd_cancel", + "sd.sd_prefix": "{green}[Special Day]: {white}", "lr.rebel_last": "You must be the last player alive to rebel", @@ -137,5 +144,6 @@ "lr.cancel_lr_cmd": "cancel_lr", "lr.start_lr_cmd": "lr", - "lr.stats_cmd": "lr_stats" + "lr.stats_cmd": "lr_stats", + "lr.lr_prefix": "{green}[LR]: {white}" } diff --git a/src/Jail.cs b/src/Jail.cs index 5c347ac..d670804 100644 --- a/src/Jail.cs +++ b/src/Jail.cs @@ -197,6 +197,8 @@ public override void Load(bool hotReload) RegisterListeners(); + LocalizePrefix(); + JailPlayer.SetupDB(); Console.WriteLine("Sucessfully started JB"); @@ -205,6 +207,21 @@ public override void Load(bool hotReload) } + void LocalizePrefix() + { + LastRequest.LR_PREFIX = Chat.Localize("lr.lr_prefix"); + Entity.DOOR_PREFIX = Chat.Localize("warden.door_prefix"); + + SpecialDay.SPECIALDAY_PREFIX = Chat.Localize("sd.sd_prefix"); + JailPlayer.REBEL_PREFIX = Chat.Localize("rebel.rebel_prefix"); + + Mute.MUTE_PREFIX = Chat.Localize("mute.mute_prefix"); + Warden.TEAM_PREFIX = Chat.Localize("warden.team_prefix"); + + Warday.WARDAY_PREFIX = Chat.Localize("warday.warday_prefix"); + Warden.WARDEN_PREFIX = Chat.Localize("warden.warden_prefix"); + } + void StatDBReload() { Task.Run(async () => diff --git a/src/LastRequest/LastRequest.cs b/src/LastRequest/LastRequest.cs index 0f1e46a..0482b86 100644 --- a/src/LastRequest/LastRequest.cs +++ b/src/LastRequest/LastRequest.cs @@ -525,5 +525,5 @@ internal class LRChoice long startTimestamp = 0; - public static readonly String LR_PREFIX = $" {ChatColors.Green}[LR]: {ChatColors.White}"; + public static String LR_PREFIX = $" {ChatColors.Green}[LR]: {ChatColors.White}"; } \ No newline at end of file diff --git a/src/Lib/Entity.cs b/src/Lib/Entity.cs index 134e7f6..ae0de3a 100644 --- a/src/Lib/Entity.cs +++ b/src/Lib/Entity.cs @@ -119,7 +119,7 @@ static public int DrawLaser(Vector start, Vector end, float width, Color colour) return (int)laser.Index; } - static String DOOR_PREFIX = $" {ChatColors.Green}[Door control]: {ChatColors.White}"; + public static String DOOR_PREFIX = $" {ChatColors.Green}[Door control]: {ChatColors.White}"; public static void ForceClose() { diff --git a/src/SpecialDay/SpecialDay.cs b/src/SpecialDay/SpecialDay.cs index c29d0fd..7e036ae 100644 --- a/src/SpecialDay/SpecialDay.cs +++ b/src/SpecialDay/SpecialDay.cs @@ -299,7 +299,7 @@ public enum SDType NONE }; - public static readonly String SPECIALDAY_PREFIX = $" {ChatColors.Green}[Special day]: {ChatColors.White}"; + public static String SPECIALDAY_PREFIX = $" {ChatColors.Green}[Special day]: {ChatColors.White}"; static String[] SD_NAME = { "Friendly fire", diff --git a/src/Warden/JailPlayer.cs b/src/Warden/JailPlayer.cs index 7485bce..1312be7 100644 --- a/src/Warden/JailPlayer.cs +++ b/src/Warden/JailPlayer.cs @@ -371,7 +371,7 @@ public void PlayerHurt(CCSPlayerController? player, CCSPlayerController? attacke } - public static readonly String REBEL_PREFIX = $" {ChatColors.Green}[REBEL]: {ChatColors.White}"; + public static String REBEL_PREFIX = $" {ChatColors.Green}[REBEL]: {ChatColors.White}"; public static JailConfig Config = new JailConfig(); diff --git a/src/Warden/Mute.cs b/src/Warden/Mute.cs index 9b405e0..78dbf73 100644 --- a/src/Warden/Mute.cs +++ b/src/Warden/Mute.cs @@ -170,7 +170,7 @@ public void SwitchTeam(CCSPlayerController? player,int new_team) CSTimer.Timer? muteTimer = null; - static readonly String MUTE_PREFIX = $" {ChatColors.Green}[MUTE]: {ChatColors.White}"; + public static String MUTE_PREFIX = $" {ChatColors.Green}[MUTE]: {ChatColors.White}"; // has the mute timer finished? bool muteActive = false; diff --git a/src/Warden/Team.cs b/src/Warden/Team.cs index 30b732c..f51273b 100644 --- a/src/Warden/Team.cs +++ b/src/Warden/Team.cs @@ -20,7 +20,7 @@ public partial class Warden { - static readonly String TEAM_PREFIX = $" {ChatColors.Green}[TEAM]: {ChatColors.White}"; + public static String TEAM_PREFIX = $" {ChatColors.Green}[TEAM]: {ChatColors.White}"; public bool JoinTeam(CCSPlayerController? invoke, CommandInfo command) { diff --git a/src/Warden/Warday.cs b/src/Warden/Warday.cs index 64ed9e6..eb01972 100644 --- a/src/Warden/Warday.cs +++ b/src/Warden/Warday.cs @@ -94,7 +94,7 @@ public void MapStart() public JailConfig Config = new JailConfig(); - String WARDAY_PREFIX = $" {ChatColors.Green} [Warday]: {ChatColors.White}"; + public static String WARDAY_PREFIX = $" {ChatColors.Green} [Warday]: {ChatColors.White}"; bool wardayActive = false; diff --git a/src/Warden/Warden.cs b/src/Warden/Warden.cs index 37358f0..f6ad19e 100644 --- a/src/Warden/Warden.cs +++ b/src/Warden/Warden.cs @@ -186,7 +186,7 @@ public void SetupPlayerGuns(CCSPlayerController? player) int wardenSlot = INAVLID_SLOT; - public static readonly String WARDEN_PREFIX = $" {ChatColors.Green}[WARDEN]: {ChatColors.White}"; + public static String WARDEN_PREFIX = $" {ChatColors.Green}[WARDEN]: {ChatColors.White}"; long wardenTimestamp = -1;