mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-07 02:33:21 +00:00
Add reset to category list
This commit is contained in:
parent
292e445011
commit
95c69b8e64
2 changed files with 43 additions and 15 deletions
|
@ -1,6 +1,7 @@
|
||||||
#define AUTOPUNISH_FLOW_MIN_DISTANCE 5000.0
|
#define AUTOPUNISH_FLOW_MIN_DISTANCE 5000.0
|
||||||
#define AUTOPUNISH_MODE_COUNT 3
|
#define AUTOPUNISH_MODE_COUNT 3
|
||||||
#define TROLL_MODE_COUNT 23
|
#define TROLL_MODE_COUNT 23
|
||||||
|
#define TROLL_NAME_MAX_LENGTH 64
|
||||||
//
|
//
|
||||||
enum trollMode {
|
enum trollMode {
|
||||||
Troll_Reset = 0, //0
|
Troll_Reset = 0, //0
|
||||||
|
@ -117,17 +118,27 @@ int g_iAmmoTable; //Loads the ammo table to get ammo amounts
|
||||||
int gChargerVictim = -1; //For charge player feature
|
int gChargerVictim = -1; //For charge player feature
|
||||||
|
|
||||||
enum struct Troll {
|
enum struct Troll {
|
||||||
char name[64];
|
char name[TROLL_NAME_MAX_LENGTH];
|
||||||
char id[16];
|
char id[16];
|
||||||
char description[128];
|
char description[128];
|
||||||
|
|
||||||
int modifiers;
|
int modifiers;
|
||||||
|
bool players[MAXPLAYERS+1];
|
||||||
|
|
||||||
|
bool IsTrolled(int client) {
|
||||||
|
return this.players[client];
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetTrolled(int client, bool value) {
|
||||||
|
this.players[client] = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList trolls; //<id, Troll>
|
StringMap trolls; //<id, Troll>
|
||||||
|
StringMapSnapshot trollIds;
|
||||||
|
|
||||||
void LoadTrolls() {
|
void LoadTrolls() {
|
||||||
trolls = new ArrayList(sizeof(Troll));
|
trolls = new StringMap();
|
||||||
KeyValues kv = new KeyValues("Trolls");
|
KeyValues kv = new KeyValues("Trolls");
|
||||||
char sPath[PLATFORM_MAX_PATH];
|
char sPath[PLATFORM_MAX_PATH];
|
||||||
BuildPath(Path_SM, sPath, sizeof(sPath), "data/feedthetrolls.cfg");
|
BuildPath(Path_SM, sPath, sizeof(sPath), "data/feedthetrolls.cfg");
|
||||||
|
@ -157,28 +168,31 @@ void LoadTrolls() {
|
||||||
else if(modifiers[i] == 'r') troll.modifiers |= view_as<int>(Type_Repeat);
|
else if(modifiers[i] == 'r') troll.modifiers |= view_as<int>(Type_Repeat);
|
||||||
else if(modifiers[i] == 'c') troll.modifiers |= view_as<int>(Type_Constant);
|
else if(modifiers[i] == 'c') troll.modifiers |= view_as<int>(Type_Constant);
|
||||||
}
|
}
|
||||||
trolls.PushArray(troll);
|
trolls.SetArray(troll.id, troll, sizeof(troll), true);
|
||||||
++loaded;
|
++loaded;
|
||||||
} while (kv.GotoNextKey(false));
|
} while (kv.GotoNextKey(false));
|
||||||
delete kv;
|
delete kv;
|
||||||
|
trollIds = trolls.Snapshot();
|
||||||
PrintToServer("[FTT] Loaded %d trolls successfully", loaded);
|
PrintToServer("[FTT] Loaded %d trolls successfully", loaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyTroll(int trollIndex, int victim, int activator, trollType modifier, bool silent = false) {
|
void GetTrollByIndex(int index, Troll troll) {
|
||||||
|
char key[TROLL_NAME_MAX_LENGTH];
|
||||||
|
trollIds.GetKey(index, key, sizeof(key));
|
||||||
|
trolls.GetArray(key, troll, sizeof(troll));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplyTroll(Troll troll, int victim, int activator, trollType modifier, bool silent = false) {
|
||||||
if(GetClientTeam(victim) == 1) {
|
if(GetClientTeam(victim) == 1) {
|
||||||
//Victim is spectating, find its bot
|
//Victim is spectating, find its bot
|
||||||
victim = FindIdlePlayerBot(victim);
|
victim = FindIdlePlayerBot(victim);
|
||||||
}
|
}
|
||||||
|
|
||||||
Troll troll;
|
bool isActive = troll.IsTrolled(victim);
|
||||||
trolls.GetArray(trollIndex, troll, sizeof(troll));
|
|
||||||
|
|
||||||
bool isActive = HasTroll(trollIndex, victim);
|
|
||||||
|
|
||||||
PrintToChatAll("a=%N v=%N active=%b | %s (%s)", activator, victim, isActive, troll.name, troll.id);
|
|
||||||
if(StrEqual(troll.id, "reset")) {
|
if(StrEqual(troll.id, "reset")) {
|
||||||
ResetClient(victim, true);
|
ResetClient(victim, true);
|
||||||
|
ClearAllTrolls(victim);
|
||||||
ShowActivity(activator, "reset troll effects for %N. ", victim);
|
ShowActivity(activator, "reset troll effects for %N. ", victim);
|
||||||
} else if(StrEqual(troll.id, "slow", true))
|
} else if(StrEqual(troll.id, "slow", true))
|
||||||
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", isActive ? 1.0 : 0.8);
|
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", isActive ? 1.0 : 0.8);
|
||||||
|
@ -262,8 +276,9 @@ void ApplyTroll(int trollIndex, int victim, int activator, trollType modifier, b
|
||||||
}
|
}
|
||||||
|
|
||||||
if(modifier == Type_Constant || modifier == Type_Repeat) {
|
if(modifier == Type_Constant || modifier == Type_Repeat) {
|
||||||
g_iTrollUsers[victim] ^= 1 << view_as<int>(trollIndex) -1;
|
troll.SetTrolled(victim, !isActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!silent) {
|
if(!silent) {
|
||||||
if(isActive) {
|
if(isActive) {
|
||||||
ShowActivity(activator, "deactivated troll \"%s\" on %N. ", troll.name, victim);
|
ShowActivity(activator, "deactivated troll \"%s\" on %N. ", troll.name, victim);
|
||||||
|
@ -276,8 +291,12 @@ void ApplyTroll(int trollIndex, int victim, int activator, trollType modifier, b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasTroll(int trollIndex, int client) {
|
void ClearAllTrolls(int client) {
|
||||||
return ((g_iTrollUsers[client] >> view_as<int>(trollIndex) - 1) & 1) == 1;
|
Troll troll;
|
||||||
|
for(int i = 0; i < trollIds.Length; i++) {
|
||||||
|
GetTrollByIndex(i, troll);
|
||||||
|
troll.players[i] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Applies the selected trollMode to the victim.
|
//Applies the selected trollMode to the victim.
|
||||||
|
|
|
@ -389,6 +389,7 @@ public void Change_ThrowInterval(ConVar convar, const char[] oldValue, const cha
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public Action Command_FeedTheCrescendoTroll(int client, int args) {
|
public Action Command_FeedTheCrescendoTroll(int client, int args) {
|
||||||
|
//TODO: Menu confirm prompt
|
||||||
if(lastCrescendoUser > -1) {
|
if(lastCrescendoUser > -1) {
|
||||||
ActivateAutoPunish(lastCrescendoUser);
|
ActivateAutoPunish(lastCrescendoUser);
|
||||||
ReplyToCommand(client, "Activated auto punish on %N", lastCrescendoUser);
|
ReplyToCommand(client, "Activated auto punish on %N", lastCrescendoUser);
|
||||||
|
@ -704,6 +705,8 @@ public int Menu_ChoosePlayer(Menu menu, MenuAction action, int activator, int it
|
||||||
categoryMenu.AddItem(itemId, "Constant Trolls");
|
categoryMenu.AddItem(itemId, "Constant Trolls");
|
||||||
Format(itemId, sizeof(itemId), "%d|r", targetUserid);
|
Format(itemId, sizeof(itemId), "%d|r", targetUserid);
|
||||||
categoryMenu.AddItem(itemId, "Repeat Trolls");
|
categoryMenu.AddItem(itemId, "Repeat Trolls");
|
||||||
|
Format(itemId, sizeof(itemId), "%d|x", targetUserid);
|
||||||
|
categoryMenu.AddItem(itemId, "Reset All Trolls");
|
||||||
categoryMenu.ExitButton = true;
|
categoryMenu.ExitButton = true;
|
||||||
categoryMenu.Display(activator, 0);
|
categoryMenu.Display(activator, 0);
|
||||||
} else if (action == MenuAction_End)
|
} else if (action == MenuAction_End)
|
||||||
|
@ -736,6 +739,12 @@ public int Menu_ChooseCategory(Menu menu, MenuAction action, int activator, int
|
||||||
selectedType = Type_Repeat;
|
selectedType = Type_Repeat;
|
||||||
}else if(StrEqual(str[1], "c", true)) {
|
}else if(StrEqual(str[1], "c", true)) {
|
||||||
selectedType = Type_Constant;
|
selectedType = Type_Constant;
|
||||||
|
}else if(StrEqual(str[1], "x", true)) {
|
||||||
|
int client = GetClientOfUserId(targetUserid);
|
||||||
|
ClearAllTrolls(client);
|
||||||
|
ResetClient(client, true);
|
||||||
|
ShowActivity(activator, "reset troll effects for %N. ", client);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu trollsMenu = new Menu(Menu_ChooseTroll);
|
Menu trollsMenu = new Menu(Menu_ChooseTroll);
|
||||||
|
@ -771,7 +780,7 @@ public int Menu_ChooseTroll(Menu menu, MenuAction action, int activator, int ite
|
||||||
|
|
||||||
Troll troll;
|
Troll troll;
|
||||||
GetTrollByIndex(trollIndex, troll);
|
GetTrollByIndex(trollIndex, troll);
|
||||||
if(targetUserId < 0) {
|
if(targetUserid == -1) {
|
||||||
for(int i = 1; i <= MaxClients; i++) {
|
for(int i = 1; i <= MaxClients; i++) {
|
||||||
if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2) {
|
if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2) {
|
||||||
ApplyTroll(troll, i, activator, type);
|
ApplyTroll(troll, i, activator, type);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue