Skip to content

Commit

Permalink
Add l4d2_block_bot_pills & l4d2_tank_spawn_antirock_protect
Browse files Browse the repository at this point in the history
Closes #744
  • Loading branch information
SirPlease committed Apr 2, 2024
1 parent 0a5ebcc commit 295cb8a
Show file tree
Hide file tree
Showing 17 changed files with 126 additions and 10 deletions.
Binary file not shown.
Binary file removed addons/sourcemod/plugins/optional/botpopstop.smx
Binary file not shown.
Binary file not shown.
File renamed without changes.
77 changes: 77 additions & 0 deletions addons/sourcemod/scripting/l4d2_block_bot_pills.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <left4dhooks>
#include <actions>
#include <colors>

bool g_bExtensionActions;

ConVar g_cvDebugModeEnabled;

public Plugin myinfo =
{
name = "[L4D2] Block Bot Pills",
author = "B[R]UTUS",
description = "Prohibits the use of pills to bots",
version = "1.0.1",
url = "https://github.com/SirPlease/L4D2-Competitive-Rework"
}

public void OnPluginStart()
{
// ====================
// Validate extensions
// ====================
g_bExtensionActions = LibraryExists("actionslib");

if (!g_bExtensionActions)
SetFailState("\n==========\nMissing required extensions: \"Actions\".\nRead installation instructions again.\n==========");

g_cvDebugModeEnabled = CreateConVar("l4d2_bbp_debug_enabled", "0", "Is debug mode enabled?");

HookEvent("player_bot_replace", playerBotReplace_Event);
}

public void playerBotReplace_Event(Event hEvent, char[] sEventName, bool dontBroadcast)
{
int bot = GetClientOfUserId(hEvent.GetInt("bot"));

if (bot < 1 || bot > MaxClients)
return;

char sWeapon[64];
GetClientWeapon(bot, sWeapon, sizeof(sWeapon));

if (strcmp(sWeapon[7], "pain_pills") == 0)
{
AcceptEntityInput(GetPlayerWeaponSlot(bot, 4), "Kill");

int newPills = CreateEntityByName("weapon_pain_pills");
DispatchSpawn(newPills);
EquipPlayerWeapon(bot, newPills);

if (g_cvDebugModeEnabled.BoolValue)
CPrintToChatAll("{green}[{default}Bot Block Pills{green}]{default}: Prevented accidental pills take by %N", bot);
}
}

// ====================================================================================================
// ACTIONS EXTENSION
// ====================================================================================================
public void OnActionCreated(BehaviorAction action, int actor, const char[] name)
{
/* Hooking take pills action (when bot wants to take pills) */
if (strcmp(name, "SurvivorTakePills") == 0)
action.OnStart = OnSelfActionPills;
}

public Action OnSelfActionPills(BehaviorAction action, int actor, BehaviorAction priorAction, ActionResult result)
{
if (g_cvDebugModeEnabled.BoolValue)
CPrintToChatAll("{green}[{default}Bot Block Pills{green}]{default}: Bot {blue}%N{default} wants to use pain pills. Blocking this action...", actor);

result.type = DONE;
return Plugin_Changed;
}
38 changes: 38 additions & 0 deletions addons/sourcemod/scripting/l4d2_tank_spawn_antirock_protect.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <sourcemod>
#include <left4dhooks>
#include <colors>

float g_fSpawnTime[MAXPLAYERS + 1];

ConVar g_cvAntiRockProtectTime;

public Plugin myinfo =
{
name = "[L4D2] Tank Spawn Anti-Rock Protect",
author = "B[R]UTUS",
description = "Protects a Tank player from randomly rock attack at his spawn",
version = "1.0.1",
url = "https://github.com/SirPlease/L4D2-Competitive-Rework"
}

public void OnPluginStart()
{
HookEvent("tank_spawn", Event_TankSpawn, EventHookMode_Post);
g_cvAntiRockProtectTime = CreateConVar("l4d2_antirock_protect_time", "1.5", "Protection time to avoid Tank throwing a rock by accident");
}

public void Event_TankSpawn(Event event, const char[] name, bool dontBroadcast)
{
int tank = GetClientOfUserId(event.GetInt("userid"));
g_fSpawnTime[tank] = GetGameTime();
}

public Action L4D_OnCThrowActivate(int ability)
{
int abilityOwner = GetEntPropEnt(ability, Prop_Send, "m_owner");

if (abilityOwner != -1 && GetGameTime() - g_fSpawnTime[abilityOwner] < g_cvAntiRockProtectTime.FloatValue)
return Plugin_Handled;

return Plugin_Continue;
}
2 changes: 1 addition & 1 deletion cfg/cfgogl/acemodrv/shared_plugins.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ sm plugins load optional/l4d2_pickup.smx
sm plugins load optional/blockheatseekingchargers.smx
sm plugins load optional/blocktrolls.smx
sm plugins load optional/bossspawningfix.smx
sm plugins load optional/botpopstop.smx
sm plugins load optional/l4d2_block_bot_pills.smx
sm plugins load optional/coinflip.smx
sm plugins load optional/current.smx
sm plugins load optional/finalefix.smx
Expand Down
2 changes: 1 addition & 1 deletion cfg/cfgogl/apex/shared_plugins.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ sm plugins load optional/l4d2_pickup.smx
sm plugins load optional/blockheatseekingchargers.smx
sm plugins load optional/blocktrolls.smx
sm plugins load optional/bossspawningfix.smx
sm plugins load optional/botpopstop.smx
sm plugins load optional/l4d2_block_bot_pills.smx
sm plugins load optional/coinflip.smx
sm plugins load optional/current.smx
sm plugins load optional/finalefix.smx
Expand Down
2 changes: 1 addition & 1 deletion cfg/cfgogl/deadman/confogl_plugins.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sm plugins load optional/1v1.smx
sm plugins load optional/aitankgank.smx
sm plugins load optional/blocktrolls.smx
sm plugins load optional/bossspawningfix.smx
sm plugins load optional/botpopstop.smx
sm plugins load optional/l4d2_block_bot_pills.smx
sm plugins load optional/checkpoint-rage-control.smx
sm plugins load optional/coinflip.smx
sm plugins load optional/current.smx
Expand Down
2 changes: 1 addition & 1 deletion cfg/cfgogl/eq/shared_plugins.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sm plugins load playercommands.smx
sm plugins load optional/blockheatseekingchargers.smx
sm plugins load optional/blocktrolls.smx
sm plugins load optional/bossspawningfix.smx
sm plugins load optional/botpopstop.smx
sm plugins load optional/l4d2_block_bot_pills.smx
sm plugins load optional/coinflip.smx
sm plugins load optional/current.smx
sm plugins load optional/finalefix.smx
Expand Down
2 changes: 1 addition & 1 deletion cfg/cfgogl/neomod/shared_plugins.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ sm plugins load optional/l4d2_pickup.smx
sm plugins load optional/blockheatseekingchargers.smx
sm plugins load optional/blocktrolls.smx
sm plugins load optional/bossspawningfix.smx
sm plugins load optional/botpopstop.smx
sm plugins load optional/l4d2_block_bot_pills.smx
sm plugins load optional/coinflip.smx
sm plugins load optional/current.smx
sm plugins load optional/finalefix.smx
Expand Down
2 changes: 1 addition & 1 deletion cfg/cfgogl/nextmod/shared_plugins.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sm plugins load optional/l4d2_pickup.smx
sm plugins load optional/blockheatseekingchargers.smx
sm plugins load optional/blocktrolls.smx
sm plugins load optional/bossspawningfix.smx
sm plugins load optional/botpopstop.smx
sm plugins load optional/l4d2_block_bot_pills.smx
sm plugins load optional/coinflip.smx
sm plugins load optional/8ball.smx
sm plugins load optional/changelog.smx
Expand Down
2 changes: 1 addition & 1 deletion cfg/cfgogl/pmelite/confogl_plugins.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ sm plugins load optional/autopause.smx
sm plugins load optional/blockheatseekingchargers.smx
sm plugins load optional/blocktrolls.smx
sm plugins load optional/boomer_horde_equalizer.smx
sm plugins load optional/botpopstop.smx
sm plugins load optional/l4d2_block_bot_pills.smx
sm plugins load optional/bossspawningfix.smx
sm plugins load optional/checkpoint-rage-control.smx
sm plugins load optional/coinflip.smx
Expand Down
2 changes: 1 addition & 1 deletion cfg/cfgogl/zonehunters/shared_plugins.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sm plugins load playercommands.smx
sm plugins load optional/l4d2_pickup.smx
sm plugins load optional/blocktrolls.smx
sm plugins load optional/bossspawningfix.smx
sm plugins load optional/botpopstop.smx
sm plugins load optional/l4d2_block_bot_pills.smx
sm plugins load optional/coinflip.smx
sm plugins load optional/current.smx
sm plugins load optional/finalefix.smx
Expand Down
2 changes: 1 addition & 1 deletion cfg/cfgogl/zonemod/shared_plugins.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ sm plugins load optional/l4d2_pickup.smx
sm plugins load optional/blockheatseekingchargers.smx
sm plugins load optional/blocktrolls.smx
sm plugins load optional/bossspawningfix.smx
sm plugins load optional/botpopstop.smx
sm plugins load optional/l4d2_block_bot_pills.smx
sm plugins load optional/coinflip.smx
sm plugins load optional/current.smx
sm plugins load optional/finalefix.smx
Expand Down
2 changes: 1 addition & 1 deletion cfg/cfgogl/zoneretro/shared_plugins.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ sm plugins load playercommands.smx
sm plugins load optional/l4d2_pickup.smx
sm plugins load optional/blocktrolls.smx
sm plugins load optional/bossspawningfix.smx
sm plugins load optional/botpopstop.smx
sm plugins load optional/l4d2_block_bot_pills.smx
sm plugins load optional/coinflip.smx
sm plugins load optional/current.smx
sm plugins load optional/finalefix.smx
Expand Down
1 change: 1 addition & 0 deletions cfg/generalfixes.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ sm plugins load fixes/weapon_spawn_duplicate_fix.smx
sm plugins load fixes/l4d_fix_common_shove.smx
sm plugins load fixes/l4d2_null_cusercmd_fix.smx
sm plugins load fixes/l4d2_tank_flying_incap.smx
sm plugins load fixes/l4d2_tank_spawn_antirock_protect.smx

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

0 comments on commit 295cb8a

Please sign in to comment.