Skip to content

Commit

Permalink
impl scout knife
Browse files Browse the repository at this point in the history
  • Loading branch information
destoer committed Nov 22, 2023
1 parent 0590239 commit aad4ce2
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 5 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

1 change: 1 addition & 0 deletions src/Jail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions src/SpecialDay/FriendlyFire.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
28 changes: 27 additions & 1 deletion src/SpecialDay/SDBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public void setup_common()

state = SDState.INACTIVE;
setup();

setup_players();
}

public void start_common()
Expand All @@ -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);
Expand All @@ -73,5 +98,6 @@ public enum SDState
};

public bool restrict_damage = false;
String weapon_restrict = "";
public SDState state = SDState.INACTIVE;
}
51 changes: 51 additions & 0 deletions src/SpecialDay/ScoutKnife.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
26 changes: 26 additions & 0 deletions src/SpecialDay/SpecialDay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -123,13 +147,15 @@ public void sd_cmd(CCSPlayerController? player,CommandInfo command)
public enum SDType
{
FREIENDLY_FIRE,
SCOUT_KNIFE,
NONE
};

public static readonly String SPECIALDAY_PREFIX = $" {ChatColors.Green}[Special day]: {ChatColors.White}";

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

Expand Down
6 changes: 5 additions & 1 deletion src/Warden/Warden.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}


Expand Down

0 comments on commit aad4ce2

Please sign in to comment.