-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add l4d2_block_bot_pills & l4d2_tank_spawn_antirock_protect
Closes #744
- Loading branch information
Showing
17 changed files
with
126 additions
and
10 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
38
addons/sourcemod/scripting/l4d2_tank_spawn_antirock_protect.sp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters