From e0ffc62da374fb8255dfc4de8f4f3d4d5f7f10da Mon Sep 17 00:00:00 2001 From: Shobhit Pathak Date: Sat, 10 Feb 2024 22:37:50 +0530 Subject: [PATCH] v0.7.0 | feat: Rethrow in prac and much more --- MatchZy.cs | 30 +++++++++++++++++++++++++-- PracticeMode.cs | 32 +++++++++++++++++++++++++---- Utility.cs | 3 ++- cfg/MatchZy/config.cfg | 2 +- documentation/docs/commands.md | 13 ++++++++++++ documentation/docs/configuration.md | 6 ++++++ 6 files changed, 78 insertions(+), 8 deletions(-) diff --git a/MatchZy.cs b/MatchZy.cs index a1242d9..4084007 100644 --- a/MatchZy.cs +++ b/MatchZy.cs @@ -13,7 +13,7 @@ public partial class MatchZy : BasePlugin { public override string ModuleName => "MatchZy"; - public override string ModuleVersion => "0.6.1-alpha"; + public override string ModuleVersion => "0.7.0"; public override string ModuleAuthor => "WD- (https://github.com/shobhit-pathak/)"; @@ -170,7 +170,9 @@ public override void Load(bool hotReload) { { ".rethrowdecoy", OnRethrowDecoyCommand }, { ".throwdecoy", OnRethrowDecoyCommand }, { ".throwmolotov", OnRethrowMolotovCommand }, - { ".rethrowmolotov", OnRethrowMolotovCommand } + { ".rethrowmolotov", OnRethrowMolotovCommand }, + { ".timer", OnTimerCommand }, + { ".lastindex", OnLastIndexCommand } }; RegisterEventHandler(EventPlayerConnectFullHandler); @@ -491,6 +493,30 @@ public override void Load(bool hotReload) { HandeMapPickCommand(player, mapArg); } + if (message.StartsWith(".back")) { + string command = ".back"; + string commandArg = message.Substring(command.Length).Trim(); + + HandleBackCommand(player, commandArg); + } + if (message.StartsWith(".delay")) { + string command = ".delay"; + string commandArg = message.Substring(command.Length).Trim(); + + HandleDelayCommand(player, commandArg); + } + if (message.StartsWith(".throwindex")) { + string command = ".throwindex"; + string commandArg = message.Substring(command.Length).Trim(); + + HandleThrowIndexCommand(player, commandArg); + } + if (message.StartsWith(".throwidx")) { + string command = ".throwindex"; + string commandArg = message.Substring(command.Length).Trim(); + + HandleThrowIndexCommand(player, commandArg); + } return HookResult.Continue; }); diff --git a/PracticeMode.cs b/PracticeMode.cs index 32310a3..87cc70c 100644 --- a/PracticeMode.cs +++ b/PracticeMode.cs @@ -78,6 +78,7 @@ public void StartPracticeMode() Server.PrintToChatAll($"{chatPrefix} \x10.spawn, .ctspawn, .tspawn, .bot, .nobots, .dryrun, .noflash, .break, .exitprac"); Server.PrintToChatAll($"{chatPrefix} \x10.loadnade , .savenade , .importnade , .listnades "); Server.PrintToChatAll($"{chatPrefix} \x10.listnades , .delnade , .globalnades"); + Server.PrintToChatAll($"{chatPrefix} \x10.rethrow, .throwindex , .lastindex, .last, .back , .delay "); } public void GetSpawns() @@ -1171,6 +1172,13 @@ public void HandleThrowIndexCommand(CCSPlayerController player, string argString if (!isPractice || !IsPlayerValid(player)) return; int userId = player!.UserId!.Value; + if (string.IsNullOrEmpty(argString)) + { + int thrownCount = lastGrenadesData.ContainsKey(userId) ? lastGrenadesData[userId].Count : 0; + ReplyToUserCommand(player, $"Usage: !throwindex (You've thrown {thrownCount} grenades till now)"); + return; + } + string[] argsList = argString.Split(); foreach (string arg in argsList) @@ -1332,7 +1340,7 @@ public void OnThrowIndexCommand(CCSPlayerController? player, CommandInfo command } [ConsoleCommand("css_lastindex", "Returns index of the last thrown grenade")] - public void OnLastIndexCommand(CCSPlayerController? player, CommandInfo command) + public void OnLastIndexCommand(CCSPlayerController? player, CommandInfo? command) { if (!isPractice || !IsPlayerValid(player)) return; if (IsValidPositionForLastGrenade(player!, 1)) @@ -1356,7 +1364,7 @@ public void OnDelayCommand(CCSPlayerController? player, CommandInfo command) } [ConsoleCommand("css_timer", "Starts a timer, use .timer again to stop it.")] - public void OnTimerCommand(CCSPlayerController? player, CommandInfo command) + public void OnTimerCommand(CCSPlayerController? player, CommandInfo? command) { if (!isPractice || !IsPlayerValid(player)) return; int userId = player!.UserId!.Value; @@ -1370,7 +1378,7 @@ public void OnTimerCommand(CCSPlayerController? player, CommandInfo command) } else { - playerTimers[userId] = new PlayerPracticeTimer(PracticeTimerType.OnMovement) + playerTimers[userId] = new PlayerPracticeTimer(PracticeTimerType.Immediate) { StartTime = DateTime.Now, Timer = AddTimer(0.1f, () => DisplayPracticeTimerCenter(userId), TimerFlags.REPEAT) @@ -1379,7 +1387,23 @@ public void OnTimerCommand(CCSPlayerController? player, CommandInfo command) } } - // Todo: Implement timer2 when we have OnPlayerRunCmd in CS#. Using OnTick would be its alternative, it would be very expensive and not worth it. + [ConsoleCommand("css_savenade", "Saves current nade position")] + public void OnSaveNadeCommand(CCSPlayerController? player, CommandInfo command) + { + if (!isPractice || !IsPlayerValid(player)) return; + + HandleSaveNadeCommand(player, command.ArgString); + } + + [ConsoleCommand("css_loadnade", "Saves current nade position")] + public void OnLoadNadeCommand(CCSPlayerController? player, CommandInfo command) + { + if (!isPractice || !IsPlayerValid(player)) return; + + HandleLoadNadeCommand(player, command.ArgString); + } + + // Todo: Implement timer2 when we have OnPlayerRunCmd in CS#. Using OnTick would be its alternative, but it would be very expensive and not worth it. // [ConsoleCommand("css_timer2", "Starts a timer, use .timer2 again to stop it.")] // public void OnTimer2Command(CCSPlayerController? player, CommandInfo command) // { diff --git a/Utility.cs b/Utility.cs index a23784e..d2ada35 100644 --- a/Utility.cs +++ b/Utility.cs @@ -1137,9 +1137,10 @@ private void SendAvailableCommandsMessage(CCSPlayerController? player) { if (isPractice) { - ReplyToUserCommand(player, "Available commands: .spawn, .ctspawn, .tspawn, .bot, .nobots, .god, .clear, .fastforward"); + ReplyToUserCommand(player, "Available commands: .spawn, .ctspawn, .tspawn, .bot, .nobots, .god, .clear, .fastforward, .dryrun"); ReplyToUserCommand(player, ".loadnade , .savenade , .importnade .listnades "); ReplyToUserCommand(player, ".ct, .t, .spec, .fas"); + ReplyToUserCommand(player, ".rethrow, .throwindex , .lastindex, .last, .back , .delay "); return; } if (readyAvailable) diff --git a/cfg/MatchZy/config.cfg b/cfg/MatchZy/config.cfg index d23499b..78a5d31 100644 --- a/cfg/MatchZy/config.cfg +++ b/cfg/MatchZy/config.cfg @@ -76,5 +76,5 @@ matchzy_save_nades_as_global_enabled false // Whether force ready using !forceready is enabled or not (Currently works in Match Setup only). Default value: True matchzy_allow_force_ready true -// Maximum number of grenade history that may be saved per-map, per-client. Set to 0 to disable. Default value: 512 +// Maximum number of grenade history that may be saved per-map, per-client. Set to 0 to disable the limit and allow unlimited grenades to be stored. Default value: 512 matchzy_max_saved_last_grenades 512 diff --git a/documentation/docs/commands.md b/documentation/docs/commands.md index 4c628fe..74de8f0 100644 --- a/documentation/docs/commands.md +++ b/documentation/docs/commands.md @@ -3,6 +3,7 @@ Most of the commands can also be used using ! prefix instead of . (like !ready) - `.ready` Marks the player ready - `.unready` Marks the player unready +- `.forceready` Force-readies the player's team (Only works when using Match setup using JSON/Get5) - `.pause` Pauses the match in freezetime (Tactical or normal pause, depends on `matchzy_use_pause_command_for_tactical_pause`). - `.tech` Pauses the match in freezetime. - `.unpause` Request for unpausing the match. Both teams need to type .unpause to unpause the match @@ -35,6 +36,18 @@ Most of the commands can also be used using ! prefix instead of . (like !ready) - `.importnade ` Upon saving a lineup a code will be printed to chat, alternatively those can be retrieved from the savednades.cfg - `.listnades ` Lists either all saved lineups ever or if given a filter only those that match the filter - `.break` Breaks all the breakable entities (glass windows, wooden doors, vents, etc) +- `.rethrow` Rethrows your last thrown grenade +- `.timer` Starts a timer immediately and stops it when you type .timer again, telling you the duration of time +- `.last` Teleports you back to where you threw your last grenade from +- `.back ` Teleports you back to the provided position in your grenade history +- `.delay ` Sets a delay on your last grenade. This is only used when using .rethrow or .throwindex +- `.throwindex ` Throws grenade of provided position(s) from your grenade thrown history. Example: `.throwindex 1 2` will throw your 1st and 2nd grenade. `.throwindex 4 5 8 9` will throw your 4th, 5th, 8th and 9th grenade (If you've added delay in grenades, they'll be thrown with their specific delay). +- `.lastindex` Prints index number of your last thrown grenade. +- `.rethrowsmoke` Throws your last thrown smoke grenade. +- `.rethrownade` Throws your last thrown HE grenade. +- `.rethrowflash` Throws your last thrown flash. +- `.rethrowmolotov` Throws your last thrown molotov. +- `.rethrowdecoy` Throws your last thrown decoy. # Admin Commands diff --git a/documentation/docs/configuration.md b/documentation/docs/configuration.md index 42bf504..29a554c 100644 --- a/documentation/docs/configuration.md +++ b/documentation/docs/configuration.md @@ -105,6 +105,12 @@ Example: `matchzy_demo_upload_url "https://your-website.com/upload-endpoint"` **`Default: false`** +####`matchzy_allow_force_ready` +: Whether force ready using !forceready is enabled or not (Currently works in Match Setup only).
**`Default: true`** + +####`matchzy_max_saved_last_grenades` +: Maximum number of grenade history that may be saved per-map, per-client. Set to 0 to disable the limit and allow unlimited grenades to be stored.
**`Default: 512`** + ### Configuring Warmup/Knife/Live/Prac CFGs Again, inside `csgo/cfg/MatchZy`, files named `warmup.cfg`, `knife.cfg`, `live.cfg` and `prac.cfg` should be present. These configs are executed when Warmup, Knife, Live and Practice Mode is started respectively.