Skip to content

Commit

Permalink
Add Spitter Spec Acid Blocker to prevent acid damage on spec switch
Browse files Browse the repository at this point in the history
  • Loading branch information
altair-sossai committed Nov 8, 2024
1 parent f832b72 commit c5befcd
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
Binary file not shown.
87 changes: 87 additions & 0 deletions addons/sourcemod/scripting/l4d2_spitter_spec_acid_blocker.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <left4dhooks>

#define L4D2_TEAM_INFECTED 3

bool g_bBlocked[MAXPLAYERS + 1];

public Plugin myinfo =
{
name = "L4D2 - Spitter Spec Acid Blocker",
author = "Altair Sossai",
description = "Prevents Spitter acid from causing damage if the player switches to spectator mode before dying",
version = "1.0.0",
url = "https://github.com/SirPlease/L4D2-Competitive-Rework"
};

public void OnPluginStart()
{
AddCommandListener(Spectate_Callback, "sm_spectate");
AddCommandListener(Spectate_Callback, "sm_spec");
AddCommandListener(Spectate_Callback, "sm_s");
AddCommandListener(JoinTeam_Callback, "jointeam");

HookEvent("player_team", PlayerTeam_Event, EventHookMode_Post);
}

public void L4D_OnEnterGhostState(int client)
{
g_bBlocked[client] = false;
}

Action Spectate_Callback(int client, char[] command, int args)
{
g_bBlocked[client] = true;

return Plugin_Continue;
}

Action JoinTeam_Callback(int client, char[] command, int args)
{
if (args == 0)
return Plugin_Continue;

int team = GetClientTeam(client);
if (team != L4D2_TEAM_INFECTED)
return Plugin_Continue;

char buffer[128];
GetCmdArg(1, buffer, sizeof(buffer));

int newTeam = StringToInt(buffer);
if (newTeam == L4D2_TEAM_INFECTED)
return Plugin_Continue;

g_bBlocked[client] = true;

return Plugin_Continue;
}

public void OnEntityCreated(int entity, const char[] classname)
{
if (StrEqual(classname, "insect_swarm"))
SDKHook(entity, SDKHook_SpawnPost, SDK_OnSpawnPost);
}

void SDK_OnSpawnPost(int entity)
{
int owner = GetEntPropEnt(entity, Prop_Data, "m_hOwnerEntity");
if (owner < 1 || owner > MaxClients)
return;

if (g_bBlocked[owner])
AcceptEntityInput(entity, "Kill");
}

void PlayerTeam_Event(Event event, const char[] name, bool dontBroadcast)
{
if (GetEventInt(event, "team") != L4D2_TEAM_INFECTED)
return;

int client = GetClientOfUserId(GetEventInt(event, "userid"));

g_bBlocked[client] = false;
}
1 change: 1 addition & 0 deletions cfg/generalfixes.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ sm plugins load fixes/l4d_fix_rotated_physblocker.smx
sm plugins load fixes/firebulletsfix.smx
sm plugins load fixes/l4d_fix_stagger_dir.smx
sm plugins load fixes/l4d2_fix_rocket_pull.smx
sm plugins load fixes/l4d2_spitter_spec_acid_blocker.smx

// Anti-Cheat.
sm plugins load anticheat/l4d2_noghostcheat.smx

0 comments on commit c5befcd

Please sign in to comment.