Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

### Notice 07/13/2025

I decided to discontinue this project due to serveral reason.
1. CounterStrikeSharp's capability lacking a feature that I want to expand the feature.
2. Performanace issues, I take a measure after testing with 64 players comparing with CS2Fixes zombie reborn, ZombieSharp is worse.
3. In real life stuff, I'm hunting for a job right now lol.
4. Incoming of ModSharp (even it could take to 2035).

## Notes:

**The plugin forces a player to become a zombie by calling InfectClient() which drops all weapons except knife, switches them to Terrorist team, and applies zombie class attributes (health, speed calculated as data.Speed / 250f, knockback, etc.) through ClassesApplyToPlayer() with a verification system that retries multiple times to ensure successful application.**

**This is a temporary fix to restore functionality after CS2 updates. While stable for gameplay, some features may require further refinement as the CS2 API evolves. Please report any issues and contribute improvements to help maintain this essential zombie mod for the CS2 community.**

### I TESTED RUNNING THIS PLUGIN WITH CS2FIXES. AS LONG AS YOU DON'T ENABLE ZOMBIE:REBORN, YOU CAN USE CS2FIXES ALONG WITH ZOMBIESHARP PLUGIN.

Zombie-Sharp is a Zombie Mode plugin for CS2 referencing the features and functions from the previous SourcePawn Zombie:Reloaded plugin. You can say this is the Zombie:Reloaded remake but in C#. Here is the list of features.
Expand Down
78 changes: 43 additions & 35 deletions ZombieSharp/Api/Api.cs
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
using CounterStrikeSharp.API.Core;
using ZombieSharp.Plugin;
using ZombieSharpAPI;

namespace ZombieSharp.Api;

public class ZombieSharpInterface : IZombieSharpAPI
{
public event Func<CCSPlayerController, CCSPlayerController?, bool, bool, HookResult?>? OnClientInfect;
public event Func<CCSPlayerController, bool, HookResult?>? OnClientHumanize;

public HookResult? ZS_OnClientInfect(CCSPlayerController client, CCSPlayerController? attacker, bool motherzombie, bool force)
{
return OnClientInfect?.Invoke(client, attacker, motherzombie, force);
}

public HookResult? ZS_OnClientHumanize(CCSPlayerController client, bool force)
{
return OnClientHumanize?.Invoke(client, force);
}

public bool ZS_IsClientHuman(CCSPlayerController client)
{
return Infect.IsClientHuman(client);
}

public bool ZS_IsClientInfect(CCSPlayerController client)
{
return Infect.IsClientInfect(client);
}

public void ZS_RespawnClient(CCSPlayerController client)
{
Respawn.RespawnClient(client);
}
using CounterStrikeSharp.API.Core;
using ZombieSharp.Plugin;
using ZombieSharpAPI;

namespace ZombieSharp.Api;

public class ZombieSharpInterface : IZombieSharpAPI
{
public event Func<CCSPlayerController, CCSPlayerController?, bool, bool, HookResult?>? OnClientInfect;
public event Func<CCSPlayerController, bool, HookResult?>? OnClientHumanize;

public HookResult? ZS_OnClientInfect(CCSPlayerController client, CCSPlayerController? attacker, bool motherzombie, bool force)
{
return OnClientInfect?.Invoke(client, attacker, motherzombie, force);
}

public void Hook_OnInfectClient(Func<CCSPlayerController, CCSPlayerController?, bool, bool, bool, HookResult> handler)
{
OnClientInfect += (client, attacker, motherzombie, force) =>
{
return handler(client, attacker, motherzombie, force, false);
};
}

public HookResult? ZS_OnClientHumanize(CCSPlayerController client, bool force)
{
return OnClientHumanize?.Invoke(client, force);
}

public bool ZS_IsClientHuman(CCSPlayerController client)
{
return Infect.IsClientHuman(client);
}

public bool ZS_IsClientZombie(CCSPlayerController controller)
{
return Infect.IsClientZombie(controller);
}

public void ZS_RespawnClient(CCSPlayerController client)
{
Respawn.RespawnClient(client);
}
}
70 changes: 35 additions & 35 deletions ZombieSharp/Models/CAttackInfo.cs
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
using System.Runtime.InteropServices;
using CounterStrikeSharp.API.Core;

namespace ZombieSharp.Models;

[StructLayout(LayoutKind.Explicit)]
public struct CAttackerInfo
{
public CAttackerInfo(CEntityInstance attacker)
{
NeedInit = false;
IsWorld = true;
Attacker = attacker.EntityHandle.Raw;
if (attacker.DesignerName != "cs_player_controller") return;

var controller = attacker.As<CCSPlayerController>();
IsWorld = false;
IsPawn = true;
AttackerUserId = (ushort)(controller.UserId ?? 0xFFFF);
TeamNum = controller.TeamNum;
TeamChecked = controller.TeamNum;
}

[FieldOffset(0x0)] public bool NeedInit = true;
[FieldOffset(0x1)] public bool IsPawn = false;
[FieldOffset(0x2)] public bool IsWorld = false;

[FieldOffset(0x4)]
public uint Attacker;

[FieldOffset(0x8)]
public ushort AttackerUserId;

[FieldOffset(0x0C)] public int TeamChecked = -1;
[FieldOffset(0x10)] public int TeamNum = -1;
using System.Runtime.InteropServices;
using CounterStrikeSharp.API.Core;
namespace ZombieSharp.Models;
[StructLayout(LayoutKind.Explicit)]
public struct CAttackerInfo
{
public CAttackerInfo(CEntityInstance attacker)
{
NeedInit = false;
IsWorld = true;
Attacker = attacker.EntityHandle.Raw;
if (attacker.DesignerName != "cs_player_controller") return;
var controller = attacker.As<CCSPlayerController>();
IsWorld = false;
IsPawn = true;
AttackerUserId = (ushort)(controller.UserId ?? 0xFFFF);
TeamNum = controller.TeamNum;
TeamChecked = controller.TeamNum;
}
[FieldOffset(0x0)] public bool NeedInit = true;
[FieldOffset(0x1)] public bool IsPawn = false;
[FieldOffset(0x2)] public bool IsWorld = false;
[FieldOffset(0x4)]
public uint Attacker;
[FieldOffset(0x8)]
public ushort AttackerUserId;
[FieldOffset(0x0C)] public int TeamChecked = -1;
[FieldOffset(0x10)] public int TeamNum = -1;
}
44 changes: 22 additions & 22 deletions ZombieSharp/Models/ClassAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
namespace ZombieSharp.Models;

public class ClassAttribute
{
public string? Name { get; set; }
public bool Enable { get; set; } = false;
public int Team { get; set; }
public string? Model { get; set; }
public bool MotherZombie { get; set; } = false;
public float NapalmTime { get; set; } = 0f;
public int Health { get; set; } = 100;
public float Regen_Interval { get; set; } = 0f;
public int Regen_Amount { get; set; } = 0;
public float Knockback { get; set; }
public float Speed { get; set; } = 250f;
}

public class PlayerClasses
{
public ClassAttribute? HumanClass { get; set; } = null;
public ClassAttribute? ZombieClass { get; set; } = null;
public ClassAttribute? ActiveClass { get; set; } = null;
namespace ZombieSharp.Models;
public class ClassAttribute
{
public string? Name { get; set; }
public bool Enable { get; set; } = false;
public int Team { get; set; }
public string? Model { get; set; }
public bool MotherZombie { get; set; } = false;
public float NapalmTime { get; set; } = 0f;
public int Health { get; set; } = 100;
public float Regen_Interval { get; set; } = 0f;
public int Regen_Amount { get; set; } = 0;
public float Knockback { get; set; }
public float Speed { get; set; } = 250f;
}
public class PlayerClasses
{
public ClassAttribute? HumanClass { get; set; } = null;
public ClassAttribute? ZombieClass { get; set; } = null;
public ClassAttribute? ActiveClass { get; set; } = null;
}
72 changes: 36 additions & 36 deletions ZombieSharp/Models/ConVarList.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
using CounterStrikeSharp.API.Modules.Cvars;
using CounterStrikeSharp.API.Modules.Cvars.Validators;

namespace ZombieSharp;

public partial class ZombieSharp
{
public FakeConVar<float> CVAR_FirstInfectionTimer = new("zs_infect_timer", "First Infection Countdown", 15f, default, new RangeValidator<float>(5.0f, 60.0f));
public FakeConVar<float> CVAR_MotherZombieRatio = new("zs_infect_motherzombie_ratio", "Mother zombie ratio", 7f, default, new RangeValidator<float>(1.0f, 64.0f));
public FakeConVar<bool> CVAR_MotherZombieTeleport = new("zs_infect_motherzombie_spawn", "Teleport Motherzombie back to spawn", false, default, new RangeValidator<bool>(false, true));
public FakeConVar<bool> CVAR_CashOnDamage = new("zs_infect_cash_damage_enable", "Enable earning cash from damaging player", false, default, new RangeValidator<bool>(false, true));
public FakeConVar<int> CVAR_TimeoutWinner = new("zs_infect_timeout_winner", "Winner team when timeout (0 = Zombie | 1 = Human)", 1, default, new RangeValidator<int>(0, 1));

public FakeConVar<string> CVAR_DefaultHuman = new("zs_classes_default_human", "Default classes for human", "human_default");
public FakeConVar<string> CVAR_DefaultZombie = new("zs_classes_default_zombie", "Default classes for human", "zombie_default");
public FakeConVar<string> CVAR_MotherZombie = new("zs_classes_motherzombie", "Default classes for motherzombie", "motherzombie");
public FakeConVar<bool> CVAR_RandomClassesOnConnect = new("zs_classes_random_connect", "Assign Random Classes on player connect", true, default, new RangeValidator<bool>(false, true));
public FakeConVar<bool> CVAR_RandomClassesOnSpawn = new("zs_classes_random_spawn", "Assign Random Classes on player spawn", true, default, new RangeValidator<bool>(false, true));
public FakeConVar<bool> CVAR_AllowSavingClass = new("zs_classes_allow_save", "Allowing player to save their classes", true, default, new RangeValidator<bool>(false, true));
public FakeConVar<bool> CVAR_AllowChangeClass = new("zs_classes_allow_change", "Allowing player to change their classes", true, default, new RangeValidator<bool>(false, true));

public FakeConVar<bool> CVAR_WeaponPurchaseEnable = new("zs_weapon_purchase_enable", "Enable Weapon purchase via command", true, default, new RangeValidator<bool>(false, true));
public FakeConVar<bool> CVAR_WeaponRestrictEnable = new("zs_weapon_restrict_enable", "Enable Weapon restriction", true, default, new RangeValidator<bool>(false, true));
public FakeConVar<bool> CVAR_WeaponBuyZoneOnly = new("zs_weapon_purchase_buyzone", "Only allowing weapon purchase in buyzone only", false, default, new RangeValidator<bool>(false, true));

public FakeConVar<bool> CVAR_TeleportAllow = new("zs_ztele_enable", "Allowing player to use !ztele for teleport", true, default, new RangeValidator<bool>(false, true));

public FakeConVar<bool> CVAR_RespawnEnable = new("zs_respawn_enable", "Allowing respawn after die", false, default, new RangeValidator<bool>(false, true));
public FakeConVar<float> CVAR_RespawnDelay = new("zs_respawn_delay", "Respawn Delaying", 5f, default, new RangeValidator<float>(0.1f, 60.0f));
public FakeConVar<bool> CVAR_AllowRespawnJoinLate = new("zs_respawn_allow_join_late", "Allowing player who join game late to spawn during the round", false, default, new RangeValidator<bool>(false, true));
public FakeConVar<int> CVAR_RespawnTeam = new("zs_respawn_team", "Specify team to respawn with after death (0 = Zombie | 1 = Human | 2 = Player Team before death)", 0, default, new RangeValidator<int>(0, 2));

public FakeConVar<string> CVAR_HumanWinOverlayParticle = new("zs_human_overlay_particle", "Human win overlay particle path", string.Empty);
public FakeConVar<string> CVAR_HumanWinOverlayMaterial = new("zs_human_overlay_material", "Human win overlay material path", string.Empty);
public FakeConVar<string> CVAR_ZombieWinOverlayParticle = new("zs_zombie_overlay_particle", "Zombie win overlay particle path", string.Empty);
public FakeConVar<string> CVAR_ZombieWinOverlayMaterial = new("zs_zombie_overlay_material", "Zombie win overlay material path", string.Empty);
using CounterStrikeSharp.API.Modules.Cvars;
using CounterStrikeSharp.API.Modules.Cvars.Validators;
namespace ZombieSharp;
public partial class ZombieSharp
{
public FakeConVar<float> CVAR_FirstInfectionTimer = new("zs_infect_timer", "First Infection Countdown", 15f, default, new RangeValidator<float>(5.0f, 60.0f));
public FakeConVar<float> CVAR_MotherZombieRatio = new("zs_infect_motherzombie_ratio", "Mother zombie ratio", 7f, default, new RangeValidator<float>(1.0f, 64.0f));
public FakeConVar<bool> CVAR_MotherZombieTeleport = new("zs_infect_motherzombie_spawn", "Teleport Motherzombie back to spawn", false, default, new RangeValidator<bool>(false, true));
public FakeConVar<bool> CVAR_CashOnDamage = new("zs_infect_cash_damage_enable", "Enable earning cash from damaging player", false, default, new RangeValidator<bool>(false, true));
public FakeConVar<int> CVAR_TimeoutWinner = new("zs_infect_timeout_winner", "Winner team when timeout (0 = Zombie | 1 = Human)", 1, default, new RangeValidator<int>(0, 1));
public FakeConVar<string> CVAR_DefaultHuman = new("zs_classes_default_human", "Default classes for human", "human_default");
public FakeConVar<string> CVAR_DefaultZombie = new("zs_classes_default_zombie", "Default classes for human", "zombie_default");
public FakeConVar<string> CVAR_MotherZombie = new("zs_classes_motherzombie", "Default classes for motherzombie", "motherzombie");
public FakeConVar<bool> CVAR_RandomClassesOnConnect = new("zs_classes_random_connect", "Assign Random Classes on player connect", true, default, new RangeValidator<bool>(false, true));
public FakeConVar<bool> CVAR_RandomClassesOnSpawn = new("zs_classes_random_spawn", "Assign Random Classes on player spawn", true, default, new RangeValidator<bool>(false, true));
public FakeConVar<bool> CVAR_AllowSavingClass = new("zs_classes_allow_save", "Allowing player to save their classes", true, default, new RangeValidator<bool>(false, true));
public FakeConVar<bool> CVAR_AllowChangeClass = new("zs_classes_allow_change", "Allowing player to change their classes", true, default, new RangeValidator<bool>(false, true));
public FakeConVar<bool> CVAR_WeaponPurchaseEnable = new("zs_weapon_purchase_enable", "Enable Weapon purchase via command", true, default, new RangeValidator<bool>(false, true));
public FakeConVar<bool> CVAR_WeaponRestrictEnable = new("zs_weapon_restrict_enable", "Enable Weapon restriction", true, default, new RangeValidator<bool>(false, true));
public FakeConVar<bool> CVAR_WeaponBuyZoneOnly = new("zs_weapon_purchase_buyzone", "Only allowing weapon purchase in buyzone only", false, default, new RangeValidator<bool>(false, true));
public FakeConVar<bool> CVAR_TeleportAllow = new("zs_ztele_enable", "Allowing player to use !ztele for teleport", true, default, new RangeValidator<bool>(false, true));
public FakeConVar<bool> CVAR_RespawnEnable = new("zs_respawn_enable", "Allowing respawn after die", false, default, new RangeValidator<bool>(false, true));
public FakeConVar<float> CVAR_RespawnDelay = new("zs_respawn_delay", "Respawn Delaying", 5f, default, new RangeValidator<float>(0.1f, 60.0f));
public FakeConVar<bool> CVAR_AllowRespawnJoinLate = new("zs_respawn_allow_join_late", "Allowing player who join game late to spawn during the round", false, default, new RangeValidator<bool>(false, true));
public FakeConVar<int> CVAR_RespawnTeam = new("zs_respawn_team", "Specify team to respawn with after death (0 = Zombie | 1 = Human | 2 = Player Team before death)", 0, default, new RangeValidator<int>(0, 2));
public FakeConVar<string> CVAR_HumanWinOverlayParticle = new("zs_human_overlay_particle", "Human win overlay particle path", string.Empty);
public FakeConVar<string> CVAR_HumanWinOverlayMaterial = new("zs_human_overlay_material", "Human win overlay material path", string.Empty);
public FakeConVar<string> CVAR_ZombieWinOverlayParticle = new("zs_zombie_overlay_particle", "Zombie win overlay particle path", string.Empty);
public FakeConVar<string> CVAR_ZombieWinOverlayMaterial = new("zs_zombie_overlay_material", "Zombie win overlay material path", string.Empty);
}
81 changes: 42 additions & 39 deletions ZombieSharp/Models/GameConfigs.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
namespace ZombieSharp.Models;

public class GameConfigs
{
// Infection stuff.
public float FirstInfectionTimer { get; set; } = 15f;
public float MotherZombieRatio { get; set; } = 7f;
public bool MotherZombieTeleport { get; set; } = false;
public bool CashOnDamage { get; set; } = false;
public int TimeoutWinner { get; set; } = 1;

// human default class stuff.
public string? DefaultHumanBuffer { get; set; }
public string? DefaultZombieBuffer { get; set; }
public string? MotherZombieBuffer { get; set; }
public bool RandomClassesOnConnect { get; set; } = true;
public bool RandomClassesOnSpawn { get; set; } = false;
public bool AllowSavingClass { get; set; } = true;
public bool AllowChangeClass { get; set; } = true;

// weapons section
public bool WeaponPurchaseEnable { get; set; } = false;
public bool WeaponRestrictEnable { get; set; } = true;
public bool WeaponBuyZoneOnly { get; set; } = false;

// teleport section
public bool TeleportAllow { get; set; } = true;

// respawn section
public bool RespawnEnable { get; set; } = false;
public float RespawnDelay { get; set; } = 5.0f;
public bool AllowRespawnJoinLate { get; set; } = false;
public int RespawTeam { get; set; } = 0;

// win overlay stuff
public string HumanWinOverlayParticle { get; set; } = string.Empty;
public string HumanWinOverlayMaterial { get; set; } = string.Empty;
public string ZombieWinOverlayParticle { get; set; } = string.Empty;
public string ZombieWinOverlayMaterial { get; set; } = string.Empty;
namespace ZombieSharp.Models;

public class GameConfigs
{
// Infection stuff.
public float FirstInfectionTimer { get; set; } = 15f;
public float MotherZombieRatio { get; set; } = 7f;
public bool MotherZombieTeleport { get; set; } = false;
public bool CashOnDamage { get; set; } = false;
public int TimeoutWinner { get; set; } = 1;

// human default class stuff.
public string? DefaultHumanBuffer { get; set; }
public string? DefaultZombieBuffer { get; set; }
public string? MotherZombieBuffer { get; set; }
public bool RandomClassesOnConnect { get; set; } = true;
public bool RandomClassesOnSpawn { get; set; } = false;
public bool AllowSavingClass { get; set; } = true;
public bool AllowChangeClass { get; set; } = true;

// weapons section
public bool WeaponPurchaseEnable { get; set; } = false;
public bool WeaponRestrictEnable { get; set; } = true;
public bool WeaponBuyZoneOnly { get; set; } = false;

// teleport section
public bool TeleportAllow { get; set; } = true;

// respawn section
public bool RespawnEnable { get; set; } = false;
public float RespawnDelay { get; set; } = 5.0f;
public bool AllowRespawnJoinLate { get; set; } = false;
public int RespawTeam { get; set; } = 0;

// infection settings
public float MaxKnifeRange { get; set; } = 100.0f;

// win overlay stuff
public string HumanWinOverlayParticle { get; set; } = string.Empty;
public string HumanWinOverlayMaterial { get; set; } = string.Empty;
public string ZombieWinOverlayParticle { get; set; } = string.Empty;
public string ZombieWinOverlayMaterial { get; set; } = string.Empty;
}
12 changes: 6 additions & 6 deletions ZombieSharp/Models/HitGroupData.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace ZombieSharp.Models;

public class HitGroupData
{
public int Index { get; set; }
public float Knockback { get ; set; } = 0f;
namespace ZombieSharp.Models;
public class HitGroupData
{
public int Index { get; set; }
public float Knockback { get ; set; } = 0f;
}
Loading