Add slowdrain

This commit is contained in:
Jackzie 2020-12-29 15:38:13 -06:00
parent d5eb2265c7
commit 2eb2db1460
No known key found for this signature in database
GPG key ID: 1E834FE36520537A
2 changed files with 86 additions and 44 deletions

Binary file not shown.

View file

@ -3,13 +3,13 @@
//#define DEBUG //#define DEBUG
#define MAIN_TIMER_INTERVAL_S 5.0
#define PLUGIN_VERSION "1.0" #define PLUGIN_VERSION "1.0"
#include <sourcemod> #include <sourcemod>
#include <sdktools> #include <sdktools>
#include <sdkhooks> #include <sdkhooks>
#include "jutils.inc" #include "jutils.inc"
#include <dhooks>
#undef REQUIRE_PLUGIN #undef REQUIRE_PLUGIN
#include <adminmenu> #include <adminmenu>
@ -28,11 +28,25 @@
11 -> ThrowItAll (Makes player just throw all their items at a nearby player, and periodically) 11 -> ThrowItAll (Makes player just throw all their items at a nearby player, and periodically)
*/ */
#define TROLL_MODE_COUNT 12 #define TROLL_MODE_COUNT 12
enum TROLL_MODE {
ResetUser, //0
SlowSpeed, //1
HigherGravity, //2
HalfPrimaryAmmo, //3
UziRules, //4
PrimaryDisable, //5
SlowDrain, //6
Clumsy, //7
iCantSpellNoMore, //8
CameTooEarly, //9
KillMeSoftly, //10
ThrowItAll //1
}
static const char TROLL_MODES_NAMES[TROLL_MODE_COUNT][32] = { static const char TROLL_MODES_NAMES[TROLL_MODE_COUNT][32] = {
"Disabled", //0 "Reset User", //0
"SlowSpeed", //1 "Slow Speed", //1
"HigherGravity", //2 "Higher Gravity", //2
"HalfPrimary", //3 "Half Primary Ammo", //3
"UziRules", //4 "UziRules", //4
"PrimaryDisable", //5 "PrimaryDisable", //5
"SlowDrain", //6 "SlowDrain", //6
@ -40,7 +54,21 @@ static const char TROLL_MODES_NAMES[TROLL_MODE_COUNT][32] = {
"iCantSpellNoMore", //8 "iCantSpellNoMore", //8
"CameTooEarly", //9 "CameTooEarly", //9
"KillMeSoftly", //10 "KillMeSoftly", //10
"ThrowItall" //11 "ThrowItAll" //11
};
static const char TROLL_MODES_DESCRIPTIONS[TROLL_MODE_COUNT][128] = {
"Resets the user, removes all troll effects", //0
"Sets player speed to 0.8x of normal speed", //1
"Sets player gravity to 1.3x of normal gravity", //2
"Cuts their primary reserve ammo in half", //3
"Picking up a weapon gives them a UZI instead", //4
"Player cannot pickup any weapons, only melee/pistols", //5
"Player slowly loses health", //6
"Player drops axe periodically or on demand", //7
"Chat messages letter will randomly changed with wrong letters ", //8
"When they shoot, random chance they empty whole clip", //9
"Make player eat or waste pills whenever possible", //10
"Player throws all their items at nearby player, periodically" //11
}; };
public Plugin myinfo = public Plugin myinfo =
@ -84,14 +112,20 @@ public void OnPluginStart() {
hThrowItemInterval.AddChangeHook(Change_ThrowInterval); hThrowItemInterval.AddChangeHook(Change_ThrowInterval);
RegAdminCmd("sm_ftl", Command_ListTheTrolls, ADMFLAG_ROOT, "Lists all the trolls currently ingame."); RegAdminCmd("sm_ftl", Command_ListTheTrolls, ADMFLAG_ROOT, "Lists all the trolls currently ingame.");
RegAdminCmd("sm_ftm", Command_ListModes, ADMFLAG_ROOT, "Lists all the troll modes and their description");
RegAdminCmd("sm_ftr", Command_ResetUser, ADMFLAG_ROOT, "Reset user"); RegAdminCmd("sm_ftr", Command_ResetUser, ADMFLAG_ROOT, "Reset user");
RegAdminCmd("sm_fta", Command_ApplyUser, ADMFLAG_ROOT, "apply mode"); RegAdminCmd("sm_fta", Command_ApplyUser, ADMFLAG_ROOT, "apply mode");
if(lateLoaded) UpdateTrollTargets(); if(lateLoaded) {
UpdateTrollTargets();
CreateTimer(MAIN_TIMER_INTERVAL_S, Timer_Main, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
}
} }
//(dis)connection events //(dis)connection events
public void OnMapStart() {
CreateTimer(MAIN_TIMER_INTERVAL_S, Timer_Main, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
}
public void OnClientAuthorized(int client, const char[] auth) { public void OnClientAuthorized(int client, const char[] auth) {
if(StrContains(auth, "BOT", true) == -1) { if(StrContains(auth, "BOT", true) == -1) {
TestForTarget(client, auth); TestForTarget(client, auth);
@ -140,6 +174,7 @@ public Action Command_ResetUser(int client, int args) {
for (int i = 0; i < target_count; i++) for (int i = 0; i < target_count; i++)
{ {
ResetClient(target_list[i]); ResetClient(target_list[i]);
ShowActivity(client, "reset troll effects on \"%N\". ", target_list[i]);
} }
ReplyToCommand(client, "Cleared troll effects for %d players", target_count); ReplyToCommand(client, "Cleared troll effects for %d players", target_count);
} }
@ -166,7 +201,7 @@ public Action Command_ApplyUser(int client, int args) {
int mode = StringToInt(arg2); int mode = StringToInt(arg2);
if(mode == 0) { if(mode == 0) {
ReplyToCommand(client, "Not a valid mode. Must be greater than 0. Usage: sm_fta <user(s)> <mode>"); ReplyToCommand(client, "Not a valid mode. Must be greater than 0. Usage: sm_fta <player> <mode>. Use sm_ftr <player> to reset.");
}else{ }else{
char target_name[MAX_TARGET_LENGTH]; char target_name[MAX_TARGET_LENGTH];
int target_list[MAXPLAYERS], target_count; int target_list[MAXPLAYERS], target_count;
@ -187,14 +222,18 @@ public Action Command_ApplyUser(int client, int args) {
} }
for (int i = 0; i < target_count; i++) for (int i = 0; i < target_count; i++)
{ {
ReplyToCommand(client, "Applied troll mode %d to %N", mode, target_list[i]); ApplyModeToClient(client, target_list[i], mode, false);
ApplyModeToClient(client, target_list[i], mode);
} }
} }
} }
return Plugin_Handled; return Plugin_Handled;
} }
public Action Command_ListModes(int client, int args) {
for(int mode = 0; mode < TROLL_MODE_COUNT; mode++) {
ReplyToCommand(client, "%d. %s - %s", mode, TROLL_MODES_NAMES[mode], TROLL_MODES_DESCRIPTIONS[mode]);
}
return Plugin_Handled;
}
public Action Command_ListTheTrolls(int client, int args) { public Action Command_ListTheTrolls(int client, int args) {
int count = 0; int count = 0;
for(int i = 1; i < MaxClients; i++) { for(int i = 1; i < MaxClients; i++) {
@ -216,11 +255,11 @@ public int ChoosePlayerHandler(Menu menu, MenuAction action, int param1, int par
int userid = StringToInt(info); int userid = StringToInt(info);
int client = GetClientOfUserId(userid); int client = GetClientOfUserId(userid);
PrintToChatAll("You selected player: %N (userid: %d)", client, userid); ReplyToCommand(param1, "You selected player: %N (userid: %d)", client, userid);
Menu trollMenu = new Menu(ChooseModeMenuHandler); Menu trollMenu = new Menu(ChooseModeMenuHandler);
trollMenu.SetTitle("Choose a troll mode"); trollMenu.SetTitle("Choose a troll mode");
for(int i = 1; i < TROLL_MODE_COUNT; i++) { for(int i = 0; i < TROLL_MODE_COUNT; i++) {
char id[8]; char id[8];
Format(id, sizeof(id), "%d|%d", userid, i); Format(id, sizeof(id), "%d|%d", userid, i);
trollMenu.AddItem(id, TROLL_MODES_NAMES[i]); trollMenu.AddItem(id, TROLL_MODES_NAMES[i]);
@ -239,8 +278,7 @@ public int ChooseModeMenuHandler(Menu menu, MenuAction action, int param1, int p
ExplodeString(info, "|", str, 2, 8, false); ExplodeString(info, "|", str, 2, 8, false);
int client = GetClientOfUserId(StringToInt(str[0])); int client = GetClientOfUserId(StringToInt(str[0]));
int mode = StringToInt(str[1]); int mode = StringToInt(str[1]);
PrintToChatAll("You selected item: %d (mode: %d, player: %N)", param2, mode, client); ApplyModeToClient(param1, client, mode, false);
ApplyModeToClient(param1, client, mode);
} else if (action == MenuAction_End) } else if (action == MenuAction_End)
delete menu; delete menu;
} }
@ -283,44 +321,47 @@ public Action Timer_ThrowTimer(Handle timer) {
for(int i = 1; i < MaxClients; i++) { for(int i = 1; i < MaxClients; i++) {
if(IsClientConnected(i) && iTrollUsers[i] == 11) { if(IsClientConnected(i) && iTrollUsers[i] == 11) {
ThrowAllItems(i); ThrowAllItems(i);
count++;
} }
} }
return count > 0 ? Plugin_Continue : Plugin_Stop; return count > 0 ? Plugin_Continue : Plugin_Stop;
} }
public Action Timer_Main(Handle timer) {
// #endregion static int loop;
// #region methods for(int i = 1; i < MaxClients; i++) {
/* if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i)) {
TROLL MODES switch(iTrollUsers[i]) {
1 -> Slow speed (0.8 < 1.0 base) case SlowDrain:
2 -> Higher gravity (1.3 > 1.0) if(loop % 4 == 0) {
3 -> Set primary reserve ammo in half int hp = GetClientHealth(i);
4 -> UziRules (Pickup weapon defaults to uzi) if(hp > 50) {
5 -> PrimaryDisable (Cannot pickup primary weapons at all) SetEntProp(i, Prop_Send, "m_iHealth", hp - 1);
6 -> Slow Drain }
7 -> Clusmy }
8 -> IcantSpellNoMore }
9 -> CameTooEarly }
10 -> KillMeSoftly }
11 -> ThrowItAll if(++loop >= 60) {
12 -> TakeMyPills loop = 0;
*/ }
void ApplyModeToClient(int client, int victim, int mode) { return Plugin_Continue;
}
void ApplyModeToClient(int client, int victim, int mode, bool single) {
ResetClient(victim); ResetClient(victim);
switch(mode) { switch(mode) {
case 1: case SlowDrain:
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", 0.8); SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", 0.8);
case 2: case HigherGravity:
SetEntityGravity(victim, 1.3); SetEntityGravity(victim, 1.3);
case 3: { case HalfPrimaryAmmo: {
int current = GetPrimaryReserveAmmo(victim); int current = GetPrimaryReserveAmmo(victim);
SetPrimaryReserveAmmo(victim, current / 2); SetPrimaryReserveAmmo(victim, current / 2);
} }
case 4: case UziRules:
SDKHook(victim, SDKHook_WeaponEquip, Event_ItemPickup); SDKHook(victim, SDKHook_WeaponEquip, Event_ItemPickup);
case 5: case PrimaryDisable:
SDKHook(victim, SDKHook_WeaponEquip, Event_ItemPickup); SDKHook(victim, SDKHook_WeaponEquip, Event_ItemPickup);
case 7: { case Clumsy: {
int wpn = GetClientSecondaryWeapon(victim); int wpn = GetClientSecondaryWeapon(victim);
bool hasMelee = DoesClientHaveMelee(victim); bool hasMelee = DoesClientHaveMelee(victim);
if(hasMelee) { if(hasMelee) {
@ -341,11 +382,11 @@ void ApplyModeToClient(int client, int victim, int mode) {
SDKHooks_DropWeapon(victim, wpn); SDKHooks_DropWeapon(victim, wpn);
} }
} }
case 8: case CameTooEarly:
ReplyToCommand(client, "This troll mode is not implemented."); ReplyToCommand(client, "This troll mode is not implemented.");
case 11: { case ThrowItAll: {
ThrowAllItems(victim); ThrowAllItems(victim);
if(hThrowTimer == INVALID_HANDLE) { if(hThrowTimer == INVALID_HANDLE && !single) {
PrintToServer("Created new throw item timer"); PrintToServer("Created new throw item timer");
hThrowTimer = CreateTimer(hThrowItemInterval.FloatValue, Timer_ThrowTimer, _, TIMER_REPEAT); hThrowTimer = CreateTimer(hThrowItemInterval.FloatValue, Timer_ThrowTimer, _, TIMER_REPEAT);
} }
@ -355,6 +396,7 @@ void ApplyModeToClient(int client, int victim, int mode) {
PrintToServer("Unknown troll mode to apply: %d", mode); PrintToServer("Unknown troll mode to apply: %d", mode);
} }
} }
ShowActivity(client, "activated troll mode \"%s\" on %N. ", TROLL_MODES_NAMES[mode], victim);
iTrollUsers[victim] = mode; iTrollUsers[victim] = mode;
} }