diff --git a/scripting/include/feedthetrolls/combos.inc b/scripting/include/feedthetrolls/combos.inc new file mode 100644 index 0000000..ddb4443 --- /dev/null +++ b/scripting/include/feedthetrolls/combos.inc @@ -0,0 +1,60 @@ + +ArrayList combos; + +enum struct SpecifiedTroll { + int id; + trollModifier mod; + int flags; +} +enum struct TrollCombo { + char name[32]; + ArrayList trolls; + + void AddTroll(const char[] name, int flags = 0, trollModifier mod = TrollMod_Invalid) { + int id = GetTrollID(name); + if(mod == TrollMod_Invalid) mod = Trolls[id].GetDefaultMod(); + SpecifiedTroll troll; + troll.id = id; + troll.mod = mod; + troll.flags = flags; + this.trolls.PushArray(troll, sizeof(troll)); + } + + void Activate(int client, int target) { + for(int i = 0; i < this.trolls.Length; i++) { + SpecifiedTroll troll; + this.trolls.GetArray(i, troll, sizeof(troll)); + Trolls[troll.id].Activate(target, client, troll.mod, troll.flags); + } + } +} + +void SetupCombo(TrollCombo combo, const char[] name) { + strcopy(combo.name, sizeof(combo.name), name); + combo.trolls = new ArrayList(sizeof(SpecifiedTroll)); + combos.PushArray(combo, sizeof(combo)); +} + +void SetupsTrollCombos() { + combos = new ArrayList(sizeof(TrollCombo)); + + TrollCombo combo; + SetupCombo(combo, "Magnet Galore"); + combo.AddTroll("Special Magnet"); + combo.AddTroll("Tank Magnet"); + combo.AddTroll("Witch Magnet"); + + SetupCombo(combo, "Tank Run Noob"); + combo.AddTroll("Slow Speed"); + combo.AddTroll("Tank Magnet"); + + SetupCombo(combo, "Nuclear"); + combo.AddTroll("Slow Speed"); + combo.AddTroll("Special Magnet"); + combo.AddTroll("Tank Magnet"); + combo.AddTroll("Witch Magnet"); + combo.AddTroll("Reverse FF", .flags=2); + combo.AddTroll("Vomit Player"); + + PrintToServer("[FTT] Loaded %d troll combos", combos.Length); +} \ No newline at end of file diff --git a/scripting/include/feedthetrolls/commands.inc b/scripting/include/feedthetrolls/commands.inc index 7e93d35..a1cb430 100644 --- a/scripting/include/feedthetrolls/commands.inc +++ b/scripting/include/feedthetrolls/commands.inc @@ -224,7 +224,7 @@ public Action Command_ResetUser(int client, int args) { public Action Command_ApplyUser(int client, int args) { if(args < 1) { SilentMenuSelected[client] = false; - ShowTrollMenu(client); + ShowTrollMenu(client, false); }else{ char arg1[32], arg2[16]; GetCmdArg(1, arg1, sizeof(arg1)); @@ -266,10 +266,39 @@ public Action Command_ApplyUser(int client, int args) { return Plugin_Handled; } +public Action Command_ApplyComboTrolls(int client, int args) { + if(args < 1) { + ShowTrollMenu(client, true); + }else{ + char arg1[32]; + GetCmdArg(1, arg1, sizeof(arg1)); + + static 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_NO_MULTI, + target_name, + sizeof(target_name), + tn_is_ml)) <= 0 + && target_list[0] > 0) { + /* This function replies to the admin with a failure message */ + ReplyToTargetError(client, target_count); + return Plugin_Handled; + } + ShowTrollCombosMenu(client, target_list[0]); + } + return Plugin_Handled; +} + public Action Command_ApplyUserSilent(int client, int args) { if(args < 1) { SilentMenuSelected[client] = true; - ShowTrollMenu(client); + ShowTrollMenu(client, false); }else{ char arg1[32], arg2[16]; GetCmdArg(1, arg1, sizeof(arg1)); @@ -506,4 +535,4 @@ public Action Command_FeedTheTrollMenu(int client, int args) { ReplyToCommand(client, "sm_ftc - Will apply a punishment to the last crescendo/event activator"); ReplyToCommand(client, "sm_mark - Marks the user to be banned on disconnect, prevents their FF."); return Plugin_Handled; -} \ No newline at end of file +} diff --git a/scripting/include/feedthetrolls/menus.inc b/scripting/include/feedthetrolls/menus.inc index 235f242..d010e77 100644 --- a/scripting/include/feedthetrolls/menus.inc +++ b/scripting/include/feedthetrolls/menus.inc @@ -80,10 +80,49 @@ public int ChoosePlayerHandler(Menu menu, MenuAction action, int param1, int par delete menu; } +public int ChoosePlayerHandlerForCombos(Menu menu, MenuAction action, int client, int param2) { + if (action == MenuAction_Select) { + static char info[8]; + menu.GetItem(param2, info, sizeof(info)); + int userid = StringToInt(info); + int victim = GetClientOfUserId(userid); + + if(victim == 0) { + ReplyToCommand(victim, "FTT: Could not acquire player"); + return; + } + + ShowTrollCombosMenu(client, userid); + } else if (action == MenuAction_End) + delete menu; +} + +public int ChooseComboHandler(Menu menu, MenuAction action, int client, int param2) { + if (action == MenuAction_Select) { + static char info[16]; + menu.GetItem(param2, info, sizeof(info)); + static char str[2][8]; + ExplodeString(info, "|", str, 2, 8, false); + int userid = StringToInt(str[0]); + int victim = GetClientOfUserId(userid); + int comboID = StringToInt(str[1]); + + if(victim == 0) { + ReplyToCommand(client, "FTT: Could not acquire player"); + return; + } + + static TrollCombo combo; + combos.GetArray(comboID, combo, sizeof(combo)); + combo.Activate(client, victim); + } else if (action == MenuAction_End) + delete menu; +} + static int iMenuVictimID[MAXPLAYERS+1]; public int ChooseCategoryHandler(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_Cancel && param2 == MenuCancel_ExitBack) - ShowTrollMenu(param1); + ShowTrollMenu(param1, false); else if (action == MenuAction_Select) { static char info[32]; menu.GetItem(param2, info, sizeof(info)); @@ -299,8 +338,32 @@ void SetupCategoryMenu(int client, int victimUserID) { categoryMenu.Display(client, 0); } -void ShowTrollMenu(int client) { - Menu menu = new Menu(ChoosePlayerHandler); +void ShowTrollCombosMenu(int client, int victimUserID) { + Menu comboMenu = new Menu(ChooseComboHandler); + static char id[32]; + Format(id, sizeof(id), "%N: Choose troll combo", GetClientOfUserId(victimUserID)); + comboMenu.SetTitle(id); + + static TrollCombo combo; + + if(combos.Length == 0) { + ReplyToCommand(client, "FTT: No troll combos available"); + return; + } + + for(int i = 0; i < combos.Length; i++) { + combos.GetArray(i, combo, sizeof(combo)); + Format(id, sizeof(id), "%d|%d", victimUserID, i); + comboMenu.AddItem(id, combo.name); + } + + comboMenu.ExitButton = true; + comboMenu.ExitBackButton = true; + comboMenu.Display(client, 0); +} + +void ShowTrollMenu(int client, bool isComboList) { + Menu menu = isComboList ? new Menu(ChoosePlayerHandlerForCombos) : new Menu(ChoosePlayerHandler); menu.SetTitle("Choose a player to troll"); static char userid[8], display[32]; for(int i = 1; i <= MaxClients; i++) { diff --git a/scripting/include/feedthetrolls/misc.inc b/scripting/include/feedthetrolls/misc.inc index 4bbd84d..8afc743 100644 --- a/scripting/include/feedthetrolls/misc.inc +++ b/scripting/include/feedthetrolls/misc.inc @@ -34,9 +34,9 @@ bool ToggleMarkPlayer(int client, int target) { ShowActivityEx(client, "[FTT] ", "unmarked %N as troll", target); return true; }else{ - AdminId admin_client = GetUserAdmin(client); - AdminId admin_target = GetUserAdmin(target); - if(admin_client != INVALID_ADMIN_ID && admin_target == INVALID_ADMIN_ID ) { + bool isClientAdmin = GetUserAdmin(client) != INVALID_ADMIN_ID; + bool isTargetAdmin = GetUserAdmin(target) != INVALID_ADMIN_ID; + if(isClientAdmin && !isTargetAdmin) { Call_StartForward(g_PlayerMarkedForward); Call_PushCell(client); Call_PushCell(target); diff --git a/scripting/include/feedthetrolls/trolls.inc b/scripting/include/feedthetrolls/trolls.inc index fd20316..4a37f3a 100644 --- a/scripting/include/feedthetrolls/trolls.inc +++ b/scripting/include/feedthetrolls/trolls.inc @@ -95,6 +95,7 @@ void SetupTrolls() { Trolls[i].activeFlagClients[j] = -1; } } + } void AddMagnetFlags(int index) { diff --git a/scripting/include/ftt.inc b/scripting/include/ftt.inc index 1eae4e6..7c80c7a 100644 --- a/scripting/include/ftt.inc +++ b/scripting/include/ftt.inc @@ -45,6 +45,7 @@ char steamids[MAXPLAYERS+1][64]; #include #include +#include #include #include #include diff --git a/scripting/l4d2_feedthetrolls.sp b/scripting/l4d2_feedthetrolls.sp index 7f043b6..c6aa207 100644 --- a/scripting/l4d2_feedthetrolls.sp +++ b/scripting/l4d2_feedthetrolls.sp @@ -45,6 +45,7 @@ public void OnPluginStart() { REPLACEMENT_PHRASES = new StringMap(); LoadPhrases(); SetupTrolls(); + SetupsTrollCombos(); // Witch target overwrite stuff: @@ -73,7 +74,8 @@ public void OnPluginStart() { RegAdminCmd("sm_ftas", Command_ApplyUserSilent, ADMFLAG_CHEATS, "Apply a troll mod to a player, or shows menu if no parameters."); RegAdminCmd("sm_ftt", Command_FeedTheTrollMenu, ADMFLAG_KICK, "Opens a list that shows all the commands"); RegAdminCmd("sm_mark", Command_MarkPendingTroll, ADMFLAG_KICK, "Marks a player as to be banned on disconnect"); - RegAdminCmd("sm_ftc", Command_FeedTheCrescendoTroll, ADMFLAG_KICK, "Applies a manual punish on the last crescendo activator"); + RegAdminCmd("sm_ftp", Command_FeedTheCrescendoTroll, ADMFLAG_KICK, "Applies a manual punish on the last crescendo activator"); + RegAdminCmd("sm_ftc", Command_ApplyComboTrolls, ADMFLAG_KICK, "Applies predefined combinations of trolls"); RegAdminCmd("sm_witch_attack", Command_WitchAttack, ADMFLAG_CHEATS, "Makes all witches target a player"); RegAdminCmd("sm_insta", Command_InstaSpecial, ADMFLAG_KICK, "Spawns a special that targets them, close to them."); RegAdminCmd("sm_instaface", Command_InstaSpecialFace, ADMFLAG_KICK, "Spawns a special that targets them, right in their face.");