Skip to content

Commit

Permalink
port over more sds
Browse files Browse the repository at this point in the history
  • Loading branch information
destoer committed Nov 25, 2023
1 parent 9aff8a7 commit 6a66bf9
Show file tree
Hide file tree
Showing 13 changed files with 353 additions and 71 deletions.
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,5 @@ Improve damage blocking
# SD TODO
Waiting on player colour issues fixed for alot of these

Tank, Hide and Seek

Dodgeball, Grenade, Zombie

Gun game, Knife,

Spectre, Headshot, Laser wars

Tank, Hide and Seek, Zombie
Gun game, Spectre, Laser wars
11 changes: 10 additions & 1 deletion src/Jail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public static void end_event()

public override void Load(bool hotReload)
{
if(Lib.is_windows())
{
Console.WriteLine("This plugin only works on linux - (OnTakeDamage and others are broken)");
return;
}

global_ctx = this;

register_commands();
Expand All @@ -83,6 +89,7 @@ void register_listener()
RegisterListener<Listeners.OnEntitySpawned>(entity =>
{
lr.ent_created(entity);
sd.ent_created(entity);
});
}

Expand All @@ -104,7 +111,8 @@ void register_commands()
AddCommand("lr_stats","list lr stats",lr.lr_stats.lr_stats_cmd);

// reg sd commands
AddCommand("sd","start and sd",sd.sd_cmd);
AddCommand("sd","start a sd",sd.sd_cmd);
AddCommand("sd_ff","start a ff sd",sd.sd_ff_cmd);
AddCommand("cancel_sd","cancel an sd",sd.cancel_sd_cmd);

// debug
Expand Down Expand Up @@ -152,6 +160,7 @@ HookResult OnGrenadeThrown(EventGrenadeThrown @event, GameEventInfo info)
if(player != null && player.is_valid())
{
lr.grenade_thrown(player);
sd.grenade_thrown(player);
}

return HookResult.Continue;
Expand Down
36 changes: 3 additions & 33 deletions src/LastRequest/Dodgeball.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,42 +58,12 @@ public override void player_hurt(int damage, int health, int hitgroup)

public override void grenade_thrown()
{
if(JailPlugin.global_ctx == null)
{
return;
}

JailPlugin.global_ctx.AddTimer(1.4f,() =>
{
CCSPlayerController? player = Utilities.GetPlayerFromSlot(player_slot);

if(player != null && player.is_valid_alive())
{
player.GiveNamedItem("weapon_flashbang");
}
});
CCSPlayerController? player = Utilities.GetPlayerFromSlot(player_slot);
Lib.give_weapon_delay(player,1.4f,"weapon_flashbang");
}

public override void ent_created(CEntityInstance entity)
{
if(JailPlugin.global_ctx == null)
{
return;
}

// remove projectile
if(entity.DesignerName == "flashbang_projectile")
{
if(JailPlugin.global_ctx != null)
{
JailPlugin.global_ctx.AddTimer(1.4f,() =>
{
if(entity.IsValid)
{
entity.Remove();
}
});
}
}
Lib.remove_ent_delay(entity,1.4f,"flashbang_projectile");
}
}
16 changes: 2 additions & 14 deletions src/LastRequest/Grenade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,7 @@ public override void init_player(CCSPlayerController player)

public override void grenade_thrown()
{
if(JailPlugin.global_ctx == null)
{
return;
}

JailPlugin.global_ctx.AddTimer(1.4f,() =>
{
CCSPlayerController? player = Utilities.GetPlayerFromSlot(player_slot);

if(player != null && player.is_valid_alive())
{
player.GiveNamedItem("weapon_hegrenade");
}
});
CCSPlayerController? player = Utilities.GetPlayerFromSlot(player_slot);
Lib.give_weapon_delay(player,1.4f,"weapon_hegrenade");
}
}
39 changes: 39 additions & 0 deletions src/Lib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,45 @@ static public int get_health(this CCSPlayerController? player)
return player.PlayerPawn.Value.Health;
}

static public void give_weapon_delay(CCSPlayerController? player,float delay, String name)
{
if(JailPlugin.global_ctx == null)
{
return;
}

JailPlugin.global_ctx.AddTimer(delay,() =>
{
if(player != null && player.is_valid_alive())
{
player.GiveNamedItem(name);
}
});
}

static public void remove_ent_delay(CEntityInstance entity, float delay, String name)
{
if(JailPlugin.global_ctx == null)
{
return;
}

// remove projectile
if(entity.DesignerName == name)
{
if(JailPlugin.global_ctx != null)
{
JailPlugin.global_ctx.AddTimer(delay,() =>
{
if(entity.IsValid)
{
entity.Remove();
}
});
}
}
}

static public void set_movetype(this CCSPlayerController? player, MoveType_t type)
{
if(player == null || !player.is_valid())
Expand Down
59 changes: 59 additions & 0 deletions src/SpecialDay/Dodgeball.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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 SDDodgeball : SDBase
{
public override void setup()
{
announce("Dodgeball started");
announce("Please 15 seconds for damage be enabled");
}

public override void start()
{
announce("Fight!");
}

public override void end()
{
announce("Dodgeball is over");
}

public override void setup_player(CCSPlayerController player)
{
player.strip_weapons(true);
player.GiveNamedItem("weapon_flashbang");
weapon_restrict = "flashbang";
}

public override void grenade_thrown(CCSPlayerController? player)
{
Lib.give_weapon_delay(player,1.4f,"weapon_flashbang");
}

public override void player_hurt(CCSPlayerController? player,int damage, int health, int hitgroup)
{
if(player != null && player.is_valid_alive())
{
player.PlayerPawn.Value.CommitSuicide(true, true);
}
}

public override void ent_created(CEntityInstance entity)
{
Lib.remove_ent_delay(entity,1.4f,"flashbang_projectile");
}

}
1 change: 0 additions & 1 deletion src/SpecialDay/FriendlyFire.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public override void start()
public override void end()
{
announce("Friendly fire day is over");
Lib.disable_friendly_fire();
}

public override void setup_player(CCSPlayerController? player)
Expand Down
46 changes: 46 additions & 0 deletions src/SpecialDay/Grenade.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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 SDGrenade : SDBase
{
public override void setup()
{
announce("Grenade started");
announce("Please 15 seconds for damage be enabled");
}

public override void start()
{
announce("Fight!");
}

public override void end()
{
announce("Grenade is over");
}

public override void setup_player(CCSPlayerController player)
{
player.strip_weapons(true);
player.set_health(175);
player.GiveNamedItem("weapon_hegrenade");
weapon_restrict = "hegrenade";
}

public override void grenade_thrown(CCSPlayerController? player)
{
Lib.give_weapon_delay(player,1.4f,"weapon_hegrenade");
}
}
55 changes: 55 additions & 0 deletions src/SpecialDay/HeadshotOnly.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// 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 SDHeadshotOnly : SDBase
{
public override void setup()
{
announce("Headshot only started");
announce("Please 15 seconds for damage be enabled");
}

public override void start()
{
announce("Fight!");
}

public override void end()
{
announce("Headshot only is over");
}

public override void setup_player(CCSPlayerController player)
{
player.strip_weapons(true);
player.GiveNamedItem("weapon_deagle");
weapon_restrict = "deagle";
}

public override void player_hurt(CCSPlayerController? player,int health,int damage, int hitgroup)
{
if(player == null || !player.is_valid_alive())
{
return;
}

// dont allow damage when its not to head
if(hitgroup != Lib.HITGROUP_HEAD)
{
Lib.restore_hp(player,damage,health);
}
}
}
1 change: 0 additions & 1 deletion src/SpecialDay/Juggernaut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public override void start()
public override void end()
{
announce("Juggernaut is over");
Lib.disable_friendly_fire();
}

public override void death(CCSPlayerController? player, CCSPlayerController? attacker)
Expand Down
39 changes: 39 additions & 0 deletions src/SpecialDay/Knife.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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 SDKnifeWarday : SDBase
{
public override void setup()
{
announce("knife warday started");
announce("Please 15 seconds for damage be enabled");
}

public override void start()
{
announce("Fight!");
}

public override void end()
{
announce("knife warday is over");
}

public override void setup_player(CCSPlayerController player)
{
player.strip_weapons();
weapon_restrict = "knife";
}
}
Loading

0 comments on commit 6a66bf9

Please sign in to comment.