mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-06 09:33:20 +00:00
Add l4d2_swarm plugin
This commit is contained in:
parent
017d97d087
commit
b1782c1c28
3 changed files with 269 additions and 0 deletions
18
README.md
18
README.md
|
@ -14,6 +14,7 @@ All my sourcemod plugins... shitty probably
|
|||
* [l4d2_avoid_minigun](#l4d2_avoid_minigun)
|
||||
* [l4d2_ai_minigun](#l4d2_ai_minigun)
|
||||
* [L4D2Tools](#L4D2Tools)
|
||||
* [l4d2_swarm](#l4d2_swarm)
|
||||
|
||||
## Descriptions
|
||||
### csgo-knifehp
|
||||
|
@ -119,3 +120,20 @@ A collection of small tools: Notification of when someone picks up laser sights
|
|||
* **Convars:**
|
||||
* `sm_laser_use_notice <0/1>` - Enable notification of when a laser box was used first
|
||||
* `sm_time_finale <0/1/2>` - Record the time it takes to complete finale. 0 -> OFF, 1 -> Gauntlets Only, 2 -> All finales
|
||||
|
||||
### l4d2_swarm
|
||||
This plugin is used to counter trolls and otherwise bad players. It simply uses the new script function RushVictim() to make all zombies in X radius attack Y target. It's that simple.
|
||||
|
||||
This really only affects wandering zombies, mobs and panic events, but it may work slightly when bile or pipes are thrown. It does not and can't change the targets of zombies.
|
||||
|
||||
* **Convars:**
|
||||
* `sm_swarm_default_range <20-Infinity>` - The default range for commands & menus. Defaults to 7,500
|
||||
* **Commands:**
|
||||
* `sm_swarm [player] [range]` - Swarm a player, or random if none."
|
||||
* Aliases: `sm_rush`
|
||||
* `sm_rushmenu` - Opens a menu to quickly rush any player. Can be bound to a key to quickly rush as well
|
||||
* Aliases: `sm_rmenu`
|
||||
* `sm_swarmtoggle <player> [range]` - Will continuously run the swarm method on the player at the range. Use the command again or type "disable" for player to disable. Switching players will not disable, just switches target.
|
||||
* Aliases: `sm_rushtoggle`, `sm_rt`
|
||||
* `sm_rushtogglemenu` - Will open a menu to quickly select a player to continuously rush.
|
||||
* Aliases: `sm_rtmenu`
|
BIN
plugins/l4d2_swarm.smx
Normal file
BIN
plugins/l4d2_swarm.smx
Normal file
Binary file not shown.
251
scripting/l4d2_swarm.sp
Normal file
251
scripting/l4d2_swarm.sp
Normal file
|
@ -0,0 +1,251 @@
|
|||
#pragma semicolon 1
|
||||
#pragma newdecls required
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
#define PLUGIN_NAME "L4D2 Swarm"
|
||||
#define PLUGIN_DESCRIPTION "Swarm a player with zombies to counter the trolls"
|
||||
#define PLUGIN_AUTHOR "jackzmc"
|
||||
#define PLUGIN_VERSION "1.0"
|
||||
#define PLUGIN_URL ""
|
||||
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
#include "jutils.inc"
|
||||
|
||||
ConVar hSwarmDefaultRange;
|
||||
//Swarm target is a userid
|
||||
int SwarmTarget, SwarmRadius;
|
||||
|
||||
Handle timer = INVALID_HANDLE;
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = PLUGIN_NAME,
|
||||
author = PLUGIN_AUTHOR,
|
||||
description = PLUGIN_DESCRIPTION,
|
||||
version = PLUGIN_VERSION,
|
||||
url = PLUGIN_URL
|
||||
};
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
EngineVersion g_Game = GetEngineVersion();
|
||||
if(g_Game != Engine_Left4Dead && g_Game != Engine_Left4Dead2)
|
||||
{
|
||||
SetFailState("This plugin is for L4D/L4D2 only.");
|
||||
}
|
||||
|
||||
hSwarmDefaultRange = CreateConVar("sm_swarm_default_range", "7500", "The default range swarms will affect (As a default argument or in use in menus)", FCVAR_NONE, true, 20.0);
|
||||
SwarmRadius = hSwarmDefaultRange.IntValue;
|
||||
|
||||
LoadTranslations("common.phrases");
|
||||
RegAdminCmd("sm_swarm", Cmd_Swarm, ADMFLAG_ROOT, "sm_swarm [player] [range] - Zombies swarm player (or random if not set)");
|
||||
RegAdminCmd("sm_rush", Cmd_Swarm, ADMFLAG_ROOT, "sm_swarm [player] [range] - Zombies swarm player (or random if not set)");
|
||||
RegAdminCmd("sm_rushmenu", Cmd_SwarmMenu, ADMFLAG_ROOT, "sm_swarmmenu - Open swarm menu");
|
||||
RegAdminCmd("sm_rmenu", Cmd_SwarmMenu, ADMFLAG_ROOT, "sm_swarmmenu - Open swarm menu");
|
||||
|
||||
RegAdminCmd("sm_swarmtoggle", Cmd_SwarmToggle, ADMFLAG_ROOT, "sm_swarmtoggle <player> [range]");
|
||||
RegAdminCmd("sm_rushtoggle", Cmd_SwarmToggle, ADMFLAG_ROOT, "sm_swarmtoggle <player> [range]");
|
||||
RegAdminCmd("sm_rt", Cmd_SwarmToggle, ADMFLAG_ROOT, "sm_swarmtoggle <player> [range]");
|
||||
RegAdminCmd("sm_rushtogglemenu", Cmd_SwarmToggleMenu, ADMFLAG_ROOT, "sm_swarmtogglemenu - Open swarm toggle menu");
|
||||
RegAdminCmd("sm_rtmenu", Cmd_SwarmToggleMenu, ADMFLAG_ROOT, "sm_swarmtogglemenu - Open swarm toggle menu");
|
||||
}
|
||||
|
||||
|
||||
public Action Cmd_SwarmToggle(int client, int args) {
|
||||
//SwarmTarget, SwarmRadius
|
||||
if(args == 0) {
|
||||
ReplyToCommand(client, "Usage: sm_rushtoggle <player> [radius]");
|
||||
}else{
|
||||
char arg1[32], arg2[32];
|
||||
GetCmdArg(1, arg1, sizeof(arg1));
|
||||
GetCmdArg(2, arg2, sizeof(arg2));
|
||||
|
||||
if(StrEqual(arg1, "disable", true)) {
|
||||
SwarmTarget = -1;
|
||||
SwarmRadius = hSwarmDefaultRange.IntValue;
|
||||
ReplyToCommand(client, "Deactivated swarm toggle.");
|
||||
CloseHandle(timer);
|
||||
}
|
||||
|
||||
int range = StringToInt(arg2);
|
||||
if(range <= 0) range = hSwarmDefaultRange.IntValue;
|
||||
SwarmRadius = range;
|
||||
|
||||
char target_name[MAX_TARGET_LENGTH];
|
||||
int target_list[1], target_count;
|
||||
bool tn_is_ml;
|
||||
|
||||
if ((target_count = ProcessTargetString(
|
||||
arg1,
|
||||
client,
|
||||
target_list,
|
||||
1,
|
||||
COMMAND_FILTER_ALIVE, /* Only allow alive players */
|
||||
target_name,
|
||||
sizeof(target_name),
|
||||
tn_is_ml)) <= 0)
|
||||
{
|
||||
/* This function replies to the admin with a failure message */
|
||||
ReplyToTargetError(client, target_count);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
if(target_list[0] == SwarmTarget) {
|
||||
SwarmTarget = -1;
|
||||
SwarmRadius = hSwarmDefaultRange.IntValue;
|
||||
ReplyToCommand(client, "Deactivated swarm toggle.");
|
||||
CloseHandle(timer);
|
||||
timer = INVALID_HANDLE;
|
||||
}else{
|
||||
SwarmTarget = target_list[0];
|
||||
SwarmUser(GetClientUserId(target_list[0]), range);
|
||||
ReplyToCommand(client, "Now continously swarming victim %N. Radius: %d", target_list[0], range);
|
||||
if(timer == INVALID_HANDLE)
|
||||
timer = CreateTimer(1.0, Timer_Swarm, _, TIMER_REPEAT);
|
||||
}
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action Cmd_Swarm(int client, int args) {
|
||||
if(args == 0) {
|
||||
SwarmUser(-1, hSwarmDefaultRange.IntValue);
|
||||
ReplyToCommand(client, "Swarming random player at %d radius.", hSwarmDefaultRange.IntValue);
|
||||
}else{
|
||||
char arg1[32], arg2[32];
|
||||
GetCmdArg(1, arg1, sizeof(arg1));
|
||||
GetCmdArg(2, arg2, sizeof(arg2));
|
||||
|
||||
int range = StringToInt(arg2);
|
||||
if(range <= 0) range = hSwarmDefaultRange.IntValue;
|
||||
|
||||
char target_name[MAX_TARGET_LENGTH];
|
||||
int target_list[1], target_count;
|
||||
bool tn_is_ml;
|
||||
|
||||
if ((target_count = ProcessTargetString(
|
||||
arg1,
|
||||
client,
|
||||
target_list,
|
||||
1,
|
||||
COMMAND_FILTER_ALIVE, /* Only allow alive players */
|
||||
target_name,
|
||||
sizeof(target_name),
|
||||
tn_is_ml)) <= 0)
|
||||
{
|
||||
/* This function replies to the admin with a failure message */
|
||||
ReplyToTargetError(client, target_count);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
/*int entity = -1;
|
||||
do {
|
||||
entity = FindEntityByClassname(entity, "zombie");
|
||||
} while(entity != -1)
|
||||
|
||||
for (int target = 1; target <= MaxClients; target++)
|
||||
{
|
||||
if (IsClientInGame(target) && IsPlayerAlive(target) && GetClientTeam(ta))
|
||||
{
|
||||
if (IsPlayerAlive(target) && GetClientTeam(target) == 3)
|
||||
{
|
||||
new Float:targetVector[3];
|
||||
GetClientAbsimpact(target, targetVector);
|
||||
|
||||
new Float:distance = GetVectorDistance(targetVector, impact);
|
||||
if (distance < DISTANCESETTING)
|
||||
{
|
||||
//ACTIONS ON AFFECTED TARGET
|
||||
}
|
||||
}
|
||||
}
|
||||
} */
|
||||
SwarmUser(GetClientUserId(target_list[0]), range);
|
||||
ReplyToCommand(client, "Swarming victim %N. Radius: %d", target_list[0], range);
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
public Action Cmd_SwarmMenu(int client, int args) {
|
||||
Menu menu = new Menu(Handle_SwarmMenu);
|
||||
menu.SetTitle("Swarm a Player");
|
||||
char name[32], idStr[4];
|
||||
for(int id = 1; id < MaxClients; id++) {
|
||||
if(IsClientConnected(id) && IsClientInGame(id) && IsPlayerAlive(id)) {
|
||||
GetClientName(id, name, sizeof(name));
|
||||
Format(idStr, sizeof(idStr), "%d", GetClientUserId(id));
|
||||
menu.AddItem(idStr, name);
|
||||
}
|
||||
}
|
||||
menu.ExitButton = true;
|
||||
menu.Display(client, 0);
|
||||
}
|
||||
public Action Cmd_SwarmToggleMenu(int client, int args) {
|
||||
Menu menu = new Menu(Handle_SwarmMenuToggle);
|
||||
menu.SetTitle("Toggle Swarm On Player");
|
||||
menu.AddItem("disable", "Disable");
|
||||
char name[32], idStr[3];
|
||||
for(int id = 1; id < MaxClients; id++) {
|
||||
if(IsClientConnected(id) && IsClientInGame(id) && IsPlayerAlive(id)) {
|
||||
GetClientName(id, name, sizeof(name));
|
||||
Format(idStr, sizeof(idStr), "%d", GetClientUserId(id));
|
||||
menu.AddItem(idStr, name);
|
||||
}
|
||||
}
|
||||
menu.ExitButton = true;
|
||||
menu.Display(client, 0);
|
||||
}
|
||||
|
||||
public int Handle_SwarmMenu(Menu menu, MenuAction action, int client, int index)
|
||||
{
|
||||
/* If an option was selected, tell the client about the item. */
|
||||
if (action == MenuAction_Select)
|
||||
{
|
||||
char info[4];
|
||||
menu.GetItem(index, info, sizeof(info));
|
||||
int userid = StringToInt(info);
|
||||
SwarmUser(userid, hSwarmDefaultRange.IntValue);
|
||||
PrintToChat(client, "Swarming player %N with radius %d", userid, hSwarmDefaultRange.IntValue);
|
||||
Cmd_SwarmMenu(client, 0);
|
||||
} else if (action == MenuAction_End) {
|
||||
delete menu;
|
||||
}
|
||||
}
|
||||
|
||||
public int Handle_SwarmMenuToggle(Menu menu, MenuAction action, int client, int index)
|
||||
{
|
||||
/* If an option was selected, tell the client about the item. */
|
||||
if (action == MenuAction_Select)
|
||||
{
|
||||
char info[4];
|
||||
menu.GetItem(index, info, sizeof(info));
|
||||
if(StrEqual(info, "disable", true)) {
|
||||
SwarmTarget = -1;
|
||||
SwarmRadius = hSwarmDefaultRange.IntValue;
|
||||
PrintToChat(client, "Disabled swarm toggle.", SwarmTarget, SwarmRadius);
|
||||
CloseHandle(timer);
|
||||
timer = INVALID_HANDLE;
|
||||
}else{
|
||||
SwarmTarget = StringToInt(info);
|
||||
int clientID = GetClientOfUserId(SwarmTarget);
|
||||
PrintToChat(client, "Toggled swarm on for %N. Radius: %d", clientID, SwarmRadius);
|
||||
if(timer == INVALID_HANDLE)
|
||||
timer = CreateTimer(1.0, Timer_Swarm, _, TIMER_REPEAT);
|
||||
}
|
||||
} else if (action == MenuAction_End) {
|
||||
delete menu;
|
||||
}
|
||||
}
|
||||
|
||||
public Action Timer_Swarm(Handle timerH, any data) {
|
||||
if(SwarmTarget >= 0 && IsClientConnected(SwarmTarget) && IsPlayerAlive(SwarmTarget)) {
|
||||
SwarmUser(SwarmTarget, SwarmRadius);
|
||||
return Plugin_Continue;
|
||||
}else {
|
||||
return Plugin_Stop;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SwarmUser(int clientUserId, int range) {
|
||||
L4D2_RunScript("RushVictim(GetPlayerFromUserID(%d), %d)", clientUserId, range);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue