From 9aff8a74746e04ac771e1dc9eb26902ba4badc4a Mon Sep 17 00:00:00 2001 From: destoer Date: Sat, 25 Nov 2023 17:15:02 +0000 Subject: [PATCH] check player is not in sd, give knife in guntoss, add juggernaut --- README.md | 2 +- src/Jail.cs | 12 ++++++-- src/LastRequest/GunToss.cs | 6 ++++ src/LastRequest/LastRequest.cs | 4 +-- src/Lib.cs | 22 ++++++++++++++- src/SpecialDay/Juggernaut.cs | 51 ++++++++++++++++++++++++++++++++++ src/SpecialDay/SDBase.cs | 7 ++--- src/SpecialDay/SpecialDay.cs | 17 ++++++++++++ 8 files changed, 111 insertions(+), 10 deletions(-) create mode 100644 src/SpecialDay/Juggernaut.cs diff --git a/README.md b/README.md index a03dc1f..2f4823f 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Improve damage blocking # SD TODO Waiting on player colour issues fixed for alot of these -Tank, Juggernaut, Hide and Seek +Tank, Hide and Seek Dodgeball, Grenade, Zombie diff --git a/src/Jail.cs b/src/Jail.cs index a7f7eab..2857a04 100644 --- a/src/Jail.cs +++ b/src/Jail.cs @@ -232,6 +232,7 @@ HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info) { warden.death(player,killer); lr.death(player); + sd.death(player,killer); } return HookResult.Continue; @@ -243,8 +244,15 @@ HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info) if(player != null && player.is_valid()) { - AddTimer(0.5f,() => warden.spawn(player)); - //warden.spawn(player); + if(Lib.is_windows()) + { + warden.spawn(player); + } + + else + { + AddTimer(0.5f,() => warden.spawn(player)); + } } return HookResult.Continue; diff --git a/src/LastRequest/GunToss.cs b/src/LastRequest/GunToss.cs index 173690c..94ade7e 100644 --- a/src/LastRequest/GunToss.cs +++ b/src/LastRequest/GunToss.cs @@ -21,6 +21,7 @@ public LRGunToss(LastRequest manager,LastRequest.LRType type,int lr_slot, int pl public override void init_player(CCSPlayerController player) { weapon_restrict = "deagle"; + player.GiveNamedItem("weapon_knife"); player.GiveNamedItem("weapon_deagle"); // empty ammo so players dont shoot eachother @@ -31,4 +32,9 @@ public override void init_player(CCSPlayerController player) deagle.set_ammo(0,0); } } + + public override bool weapon_equip(String name) + { + return name.Contains("knife") || name.Contains("deagle"); + } } \ No newline at end of file diff --git a/src/LastRequest/LastRequest.cs b/src/LastRequest/LastRequest.cs index 88aa6c3..2b23ade 100644 --- a/src/LastRequest/LastRequest.cs +++ b/src/LastRequest/LastRequest.cs @@ -684,7 +684,7 @@ void pick_partner_internal(CCSPlayerController? player, String name) foreach(var t in alive_t) { - if(!t.is_valid()) + if(!t.is_valid() || in_lr(t)) { continue; } @@ -705,7 +705,7 @@ void pick_partner_internal(CCSPlayerController? player, String name) foreach(var ct in alive_ct) { - if(!ct.is_valid()) + if(!ct.is_valid() || in_lr(ct)) { continue; } diff --git a/src/Lib.cs b/src/Lib.cs index ed8ba45..1a71790 100644 --- a/src/Lib.cs +++ b/src/Lib.cs @@ -9,6 +9,7 @@ using CounterStrikeSharp.API.Modules.Memory; using CounterStrikeSharp.API.Modules.Menu; using CounterStrikeSharp.API.Modules.Utils; +using System.Runtime.InteropServices; using CounterStrikeSharp.API.Modules.Entities.Constants; using CSTimer = CounterStrikeSharp.API.Modules.Timers; using CounterStrikeSharp.API.Modules.Admin; @@ -75,6 +76,21 @@ static public void set_health(this CCSPlayerController? player, int hp) player.PlayerPawn.Value.Health = hp; } + static public bool is_windows() + { + return RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + } + + static public int get_health(this CCSPlayerController? player) + { + if(player == null || !player.is_valid_alive()) + { + return 100; + } + + return player.PlayerPawn.Value.Health; + } + static public void set_movetype(this CCSPlayerController? player, MoveType_t type) { if(player == null || !player.is_valid()) @@ -124,7 +140,11 @@ static public void strip_weapons(this CCSPlayerController? player, bool remove_k return; } - player.RemoveWeapons(); + // TODO: why is this call messed up on windows? + if(!is_windows()) + { + player.RemoveWeapons(); + } // dont remove knife its buggy if(!remove_knife) diff --git a/src/SpecialDay/Juggernaut.cs b/src/SpecialDay/Juggernaut.cs new file mode 100644 index 0000000..6185d20 --- /dev/null +++ b/src/SpecialDay/Juggernaut.cs @@ -0,0 +1,51 @@ +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 SDJuggernaut : SDBase +{ + public override void setup() + { + announce("Juggernaut started"); + announce("Please 15 seconds for friendly fire to be enabled"); + } + + public override void start() + { + announce("Friendly fire enabled"); + Lib.enable_friendly_fire(); + } + + public override void end() + { + announce("Juggernaut is over"); + Lib.disable_friendly_fire(); + } + + public override void death(CCSPlayerController? player, CCSPlayerController? attacker) + { + if(player == null || !player.is_valid() || attacker == null || !attacker.is_valid_alive()) + { + return; + } + + // Give attacker 100 hp + attacker.set_health(attacker.get_health() + 100); + } + + public override void setup_player(CCSPlayerController? player) + { + player.event_gun_menu(); + } +} \ No newline at end of file diff --git a/src/SpecialDay/SDBase.cs b/src/SpecialDay/SDBase.cs index f07bf64..e0f15a3 100644 --- a/src/SpecialDay/SDBase.cs +++ b/src/SpecialDay/SDBase.cs @@ -56,12 +56,11 @@ public virtual bool weapon_equip(String name) return weapon_restrict == "" || name.Contains(weapon_restrict); } - public abstract void setup_player(CCSPlayerController player); + public virtual void death(CCSPlayerController? player, CCSPlayerController? attacker) {} - public virtual void cleanup_player(CCSPlayerController player) - { + public abstract void setup_player(CCSPlayerController player); - } + public virtual void cleanup_player(CCSPlayerController player) {} public void setup_players() { diff --git a/src/SpecialDay/SpecialDay.cs b/src/SpecialDay/SpecialDay.cs index 987fc33..873fbc6 100644 --- a/src/SpecialDay/SpecialDay.cs +++ b/src/SpecialDay/SpecialDay.cs @@ -70,6 +70,13 @@ public void setup_sd(CCSPlayerController? player, ChatMenuOption option) break; } + case "Juggernaut": + { + active_sd = new SDJuggernaut(); + type = SDType.JUGGERNAUT; + break; + } + case "Scout knife": { active_sd = new SDScoutKnife(); @@ -109,6 +116,14 @@ public void weapon_equip(CCSPlayerController? player,String name) } } + public void death(CCSPlayerController? player, CCSPlayerController? attacker) + { + if(active_sd != null) + { + active_sd.death(player,attacker); + } + } + public void start_sd() { if(active_sd != null) @@ -169,6 +184,7 @@ public void sd_cmd(CCSPlayerController? player,CommandInfo command) public enum SDType { FREIENDLY_FIRE, + JUGGERNAUT, SCOUT_KNIFE, NONE }; @@ -177,6 +193,7 @@ public enum SDType static String[] SD_NAME = { "Friendly fire", + "Juggernaut", "Scout knife", "None" };