From aad4ce2896b43e7c2b8b473df95d5db060140e74 Mon Sep 17 00:00:00 2001 From: destoer Date: Wed, 22 Nov 2023 12:36:57 +0000 Subject: [PATCH] impl scout knife --- README.md | 11 +++++++- src/Jail.cs | 1 + src/SpecialDay/FriendlyFire.cs | 2 -- src/SpecialDay/SDBase.cs | 28 ++++++++++++++++++- src/SpecialDay/ScoutKnife.cs | 51 ++++++++++++++++++++++++++++++++++ src/SpecialDay/SpecialDay.cs | 26 +++++++++++++++++ src/Warden/Warden.cs | 6 +++- 7 files changed, 120 insertions(+), 5 deletions(-) create mode 100644 src/SpecialDay/ScoutKnife.cs diff --git a/README.md b/README.md index f4cd120..a03dc1f 100644 --- a/README.md +++ b/README.md @@ -38,4 +38,13 @@ Add stats leaderboard Improve damage blocking # SD TODO -start SD after lr and warden is is nearly finished +Waiting on player colour issues fixed for alot of these + +Tank, Juggernaut, Hide and Seek + +Dodgeball, Grenade, Zombie + +Gun game, Knife, + +Spectre, Headshot, Laser wars + diff --git a/src/Jail.cs b/src/Jail.cs index 4eecac5..c085750 100644 --- a/src/Jail.cs +++ b/src/Jail.cs @@ -154,6 +154,7 @@ HookResult OnItemEquip(EventItemEquip @event, GameEventInfo info) if(player != null && player.is_valid()) { lr.weapon_equip(player,@event.Item); + sd.weapon_equip(player,@event.Item); } return HookResult.Continue; diff --git a/src/SpecialDay/FriendlyFire.cs b/src/SpecialDay/FriendlyFire.cs index ef9965a..219efd8 100644 --- a/src/SpecialDay/FriendlyFire.cs +++ b/src/SpecialDay/FriendlyFire.cs @@ -20,8 +20,6 @@ public override void setup() { announce("Friendly fire day started"); announce("Please 15 seconds for friendly fire to be enabled"); - - setup_players(); } public override void start() diff --git a/src/SpecialDay/SDBase.cs b/src/SpecialDay/SDBase.cs index b6e89e7..f07bf64 100644 --- a/src/SpecialDay/SDBase.cs +++ b/src/SpecialDay/SDBase.cs @@ -31,6 +31,8 @@ public void setup_common() state = SDState.INACTIVE; setup(); + + setup_players(); } public void start_common() @@ -45,21 +47,44 @@ public void end_common() { state = SDState.INACTIVE; end(); + + cleanup_players(); + } + + public virtual bool weapon_equip(String name) + { + return weapon_restrict == "" || name.Contains(weapon_restrict); } public abstract void setup_player(CCSPlayerController player); + public virtual void cleanup_player(CCSPlayerController player) + { + + } + public void setup_players() { foreach(CCSPlayerController player in Utilities.GetPlayers()) { - if(player.is_valid()) + if(player.is_valid_alive()) { setup_player(player); } } } + public void cleanup_players() + { + foreach(CCSPlayerController player in Utilities.GetPlayers()) + { + if(player.is_valid_alive()) + { + cleanup_player(player); + } + } + } + public void announce(String str) { Lib.announce(SpecialDay.SPECIALDAY_PREFIX,str); @@ -73,5 +98,6 @@ public enum SDState }; public bool restrict_damage = false; + String weapon_restrict = ""; public SDState state = SDState.INACTIVE; } \ No newline at end of file diff --git a/src/SpecialDay/ScoutKnife.cs b/src/SpecialDay/ScoutKnife.cs new file mode 100644 index 0000000..f0e09a8 --- /dev/null +++ b/src/SpecialDay/ScoutKnife.cs @@ -0,0 +1,51 @@ +// base lr class +using CounterStrikeSharp.API; +using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Core.Attributes; +using CounterStrikeSharp.API.Core.Attributes.Registration; +using CounterStrikeSharp.API.Modules.Commands; +using CounterStrikeSharp.API.Modules.Cvars; +using CounterStrikeSharp.API.Modules.Entities; +using CounterStrikeSharp.API.Modules.Events; +using CounterStrikeSharp.API.Modules.Memory; +using CounterStrikeSharp.API.Modules.Menu; +using CounterStrikeSharp.API.Modules.Utils; +using CounterStrikeSharp.API.Modules.Entities.Constants; +using CSTimer = CounterStrikeSharp.API.Modules.Timers; + + +public class SDScoutKnife : SDBase +{ + public override void setup() + { + announce("Scout knife started"); + announce("Please 15 seconds for damage be enabled"); + } + + public override void start() + { + announce("Fight!"); + } + + public override void end() + { + announce("Scout knife is over"); + } + + public override void setup_player(CCSPlayerController player) + { + player.strip_weapons(); + player.GiveNamedItem("weapon_ssg08"); + player.set_gravity(0.1f); + } + + public override bool weapon_equip(String name) + { + return name.Contains("knife") || name.Contains("ssg08"); + } + + public override void cleanup_player(CCSPlayerController player) + { + player.set_gravity(1.0f); + } +} \ No newline at end of file diff --git a/src/SpecialDay/SpecialDay.cs b/src/SpecialDay/SpecialDay.cs index a62e9be..e74138d 100644 --- a/src/SpecialDay/SpecialDay.cs +++ b/src/SpecialDay/SpecialDay.cs @@ -63,6 +63,13 @@ public void setup_sd(CCSPlayerController? player, ChatMenuOption option) type = SDType.FREIENDLY_FIRE; break; } + + case "Scout knife": + { + active_sd = new SDScoutKnife(); + type = SDType.SCOUT_KNIFE; + break; + } } // call the intiail sd setup @@ -79,6 +86,23 @@ public void setup_sd(CCSPlayerController? player, ChatMenuOption option) } } + public void weapon_equip(CCSPlayerController? player,String name) + { + if(player == null || !player.is_valid_alive()) + { + return; + } + + if(active_sd != null) + { + // weapon equip not valid reset the player state + if(!active_sd.weapon_equip(name)) + { + active_sd.setup_player(player); + } + } + } + public void start_sd() { if(active_sd != null) @@ -123,6 +147,7 @@ public void sd_cmd(CCSPlayerController? player,CommandInfo command) public enum SDType { FREIENDLY_FIRE, + SCOUT_KNIFE, NONE }; @@ -130,6 +155,7 @@ public enum SDType static String[] SD_NAME = { "Friendly fire", + "Scout knife", "None" }; diff --git a/src/Warden/Warden.cs b/src/Warden/Warden.cs index 2bff962..14a8da2 100644 --- a/src/Warden/Warden.cs +++ b/src/Warden/Warden.cs @@ -373,7 +373,11 @@ public void death(CCSPlayerController? player, CCSPlayerController? killer) jail_player.rebel_death(player,killer); } - set_warden_if_last(); + // if a t dies we dont need to regive the warden + if(player.is_ct()) + { + set_warden_if_last(); + } }