Skip to content

Commit

Permalink
check player is not in sd, give knife in guntoss, add juggernaut
Browse files Browse the repository at this point in the history
  • Loading branch information
destoer committed Nov 25, 2023
1 parent 512ade6 commit 9aff8a7
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 10 additions & 2 deletions src/Jail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info)
{
warden.death(player,killer);
lr.death(player);
sd.death(player,killer);
}

return HookResult.Continue;
Expand All @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/LastRequest/GunToss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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");
}
}
4 changes: 2 additions & 2 deletions src/LastRequest/LastRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
22 changes: 21 additions & 1 deletion src/Lib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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)
Expand Down
51 changes: 51 additions & 0 deletions src/SpecialDay/Juggernaut.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
7 changes: 3 additions & 4 deletions src/SpecialDay/SDBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
17 changes: 17 additions & 0 deletions src/SpecialDay/SpecialDay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -169,6 +184,7 @@ public void sd_cmd(CCSPlayerController? player,CommandInfo command)
public enum SDType
{
FREIENDLY_FIRE,
JUGGERNAUT,
SCOUT_KNIFE,
NONE
};
Expand All @@ -177,6 +193,7 @@ public enum SDType

static String[] SD_NAME = {
"Friendly fire",
"Juggernaut",
"Scout knife",
"None"
};
Expand Down

0 comments on commit 9aff8a7

Please sign in to comment.