mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-06 21:43:22 +00:00
ftt: good luck, changed a lot. added multiple prompt support
This commit is contained in:
parent
48e5432705
commit
ef6de290f1
7 changed files with 239 additions and 106 deletions
Binary file not shown.
|
@ -13,6 +13,7 @@ enum trollModifier {
|
|||
TrollMod_Constant = 2
|
||||
}
|
||||
|
||||
//up to 30 flags technically possiible
|
||||
enum trollFlag {
|
||||
Flag_1 = 1 << 0,
|
||||
Flag_2 = 1 << 1,
|
||||
|
@ -26,6 +27,28 @@ enum trollFlag {
|
|||
|
||||
StringMap trollKV;
|
||||
char trollIds[MAX_TROLLS+1][MAX_TROLL_NAME_LENGTH];
|
||||
char DEFAULT_FLAG_PROMPT_MULTIPLE[] = "Choose flags (Multiple)";
|
||||
char DEFAULT_FLAG_PROMPT[] = "Choose flags";
|
||||
|
||||
static int g_trollAddPromptIndex;
|
||||
|
||||
enum struct TrollFlagPrompt {
|
||||
char promptText[MAX_TROLL_FLAG_LENGTH];
|
||||
int flags;
|
||||
int defaults;
|
||||
bool multiselect;
|
||||
int requireFlags;
|
||||
|
||||
void GetPromptText(char[] prompt, int maxlength) {
|
||||
if(this.promptText[0] != '\0') {
|
||||
strcopy(prompt, maxlength, this.promptText);
|
||||
} else if(this.multiselect) {
|
||||
strcopy(prompt, maxlength, DEFAULT_FLAG_PROMPT_MULTIPLE);
|
||||
} else {
|
||||
strcopy(prompt, maxlength, DEFAULT_FLAG_PROMPT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum struct Troll {
|
||||
int id;
|
||||
|
@ -38,8 +61,9 @@ enum struct Troll {
|
|||
|
||||
int activeFlagClients[MAXPLAYERS+1];
|
||||
ArrayList flagNames;
|
||||
int defaultFlags;
|
||||
bool flagsMultiselectable;
|
||||
char flagPrompt[MAX_TROLL_FLAG_LENGTH];
|
||||
ArrayList flagPrompts;
|
||||
|
||||
bool HasMod(trollModifier mod) {
|
||||
return ((this.mods >> (view_as<int>(mod)) - 1) & 1) == 1;
|
||||
|
@ -61,21 +85,66 @@ enum struct Troll {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
int AddFlag(const char[] name, bool defaultOn) {
|
||||
if(defaultOn && !this.flagsMultiselectable && this.defaultFlags > 0) {
|
||||
ThrowError("Flag \"%s\" cannot be set as default flag in single select mode, as one has already been set (%d)", name, this.defaultFlags);
|
||||
return -1;
|
||||
}
|
||||
if(this.flagNames == null) this.flagNames = new ArrayList(MAX_TROLL_FLAG_LENGTH);
|
||||
int index = this.flagNames.PushString(name);
|
||||
if(defaultOn)
|
||||
this.defaultFlags |= (1 << index);
|
||||
int AddCustomFlagPrompt(const char[] promptText, bool multiselect = false, int requireFlags = 0) {
|
||||
TrollFlagPrompt prompt;
|
||||
prompt.multiselect = multiselect;
|
||||
prompt.requireFlags = requireFlags;
|
||||
strcopy(prompt.promptText, MAX_TROLL_FLAG_LENGTH, promptText);
|
||||
int index = this.flagPrompts.PushArray(prompt);
|
||||
g_trollAddPromptIndex = index;
|
||||
return index;
|
||||
}
|
||||
|
||||
int AddFlagPrompt(bool multiselect = false, int requireFlags = 0) {
|
||||
//g_trollAddPromptIndex
|
||||
TrollFlagPrompt prompt;
|
||||
prompt.multiselect = multiselect;
|
||||
prompt.requireFlags = requireFlags;
|
||||
int index = this.flagPrompts.PushArray(prompt);
|
||||
g_trollAddPromptIndex = index;
|
||||
return index;
|
||||
}
|
||||
|
||||
int AddFlag(const char[] name, bool defaultOn) {
|
||||
if(this.flagNames == null) this.flagNames = new ArrayList(MAX_TROLL_FLAG_LENGTH);
|
||||
|
||||
int flagIndex = this.GetFlagIndex(name);
|
||||
if(flagIndex == -1) flagIndex = this.flagNames.PushString(name);
|
||||
|
||||
static TrollFlagPrompt prompt;
|
||||
this.flagPrompts.GetArray(g_trollAddPromptIndex, prompt);
|
||||
|
||||
prompt.flags |= (1 << flagIndex);
|
||||
|
||||
if(defaultOn) {
|
||||
// If out of bounds, set to default -1 -> pick global prompt
|
||||
if(this.flagPrompts.Length == 0) {
|
||||
ThrowError("Troll \"%s\" does not have any flag prompts, thus a default value cannot be set. (flag=\"%s\")", this.name, name);
|
||||
return -1;
|
||||
}
|
||||
if(!prompt.multiselect && prompt.defaults > 0) {
|
||||
ThrowError("Flag \"%s\" cannot be set as default flag in single select mode, as one has already been set for prompt %d", name, g_trollAddPromptIndex);
|
||||
return -1;
|
||||
}
|
||||
prompt.defaults |= flagIndex;
|
||||
}
|
||||
this.flagPrompts.SetArray(g_trollAddPromptIndex, prompt); //May not be required
|
||||
return flagIndex;
|
||||
}
|
||||
|
||||
int GetFlagIndex(const char[] flagName) {
|
||||
static char comprFlag[MAX_TROLL_FLAG_LENGTH];
|
||||
for(int i = 0; i < this.flagNames.Length; i++) {
|
||||
this.flagNames.GetString(i, comprFlag, sizeof(comprFlag));
|
||||
if(StrEqual(comprFlag, flagName)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool HasFlags() {
|
||||
return this.flagNames != null && this.flagNames.Length > 0;
|
||||
return this.flagNames != null && this.flagNames.Length > 0 && this.flagPrompts.Length > 0;
|
||||
}
|
||||
|
||||
bool IsFlagActive(int client, trollFlag flag) {
|
||||
|
@ -95,6 +164,14 @@ enum struct Troll {
|
|||
return this.activeFlagClients[client];
|
||||
}
|
||||
|
||||
void SetFlagPrompt(const char[] prompt) {
|
||||
strcopy(this.flagPrompt, MAX_TROLL_FLAG_LENGTH, prompt);
|
||||
}
|
||||
|
||||
void GetFlagPrompt(int index, TrollFlagPrompt prompt) {
|
||||
this.flagPrompts.GetArray(index, prompt);
|
||||
}
|
||||
|
||||
/////// TROLL ACTIVATION
|
||||
|
||||
void Activate(int client, int activator, trollModifier modifier = TrollMod_Invalid, int flags = 0) {
|
||||
|
@ -125,24 +202,26 @@ ArrayList categories;
|
|||
static int categoryID = -1;
|
||||
|
||||
void ResetClient(int victim, bool wipe = true) {
|
||||
if(wipe) {
|
||||
for(int i = 0; i < MAX_TROLLS; i++) {
|
||||
if(victim == 0) return;
|
||||
if(wipe) {
|
||||
for(int i = 0; i <= MAX_TROLLS; i++) {
|
||||
Trolls[i].activeFlagClients[victim] = -1;
|
||||
}
|
||||
}
|
||||
SetEntityGravity(victim, 1.0);
|
||||
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", 1.0);
|
||||
SDKUnhook(victim, SDKHook_WeaponCanUse, Event_ItemPickup);
|
||||
int wpn = GetClientWeaponEntIndex(victim, 0);
|
||||
if(wpn > -1)
|
||||
SDKUnhook(wpn, SDKHook_Reload, Event_WeaponReload);
|
||||
SetEntityGravity(victim, 1.0);
|
||||
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", 1.0);
|
||||
SDKUnhook(victim, SDKHook_WeaponCanUse, Event_ItemPickup);
|
||||
int wpn = GetClientWeaponEntIndex(victim, 0);
|
||||
if(wpn > -1)
|
||||
SDKUnhook(wpn, SDKHook_Reload, Event_WeaponReload);
|
||||
}
|
||||
|
||||
int SetupTroll(const char[] name, const char description[128], int mods, bool flagsMultiselectable = false, int defaultFlags = 0) {
|
||||
int SetupTroll(const char[] name, const char description[128], int mods, bool flagsMultiselectable = false) {
|
||||
if(mods == 0) {
|
||||
ThrowError("Troll \"%s\" has no flags defined.", name);
|
||||
return -1;
|
||||
}
|
||||
g_trollAddPromptIndex = 0;
|
||||
static int i = 0;
|
||||
Trolls[i].id = i;
|
||||
strcopy(Trolls[i].name, MAX_TROLL_NAME_LENGTH, name);
|
||||
|
@ -150,6 +229,7 @@ int SetupTroll(const char[] name, const char description[128], int mods, bool fl
|
|||
Trolls[i].categoryID = categoryID;
|
||||
Trolls[i].mods = mods;
|
||||
Trolls[i].flagsMultiselectable = flagsMultiselectable;
|
||||
Trolls[i].flagPrompts = new ArrayList(sizeof(TrollFlagPrompt));
|
||||
|
||||
strcopy(trollIds[i], MAX_TROLL_NAME_LENGTH, name);
|
||||
trollKV.SetValue(name, i);
|
||||
|
@ -175,7 +255,7 @@ int GetTrollID(const char[] name) {
|
|||
}
|
||||
|
||||
bool IsAnyTrollActive(int victim) {
|
||||
for(int i = 0; i < MAX_TROLLS; i++) {
|
||||
for(int i = 0; i <= MAX_TROLLS; i++) {
|
||||
if(Trolls[i].activeFlagClients[victim] >= 0) return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -197,6 +277,7 @@ void ToggleTroll(int client, const char[] name, int flags = 0) {
|
|||
else
|
||||
troll.activeFlagClients[client] = flags;
|
||||
}
|
||||
|
||||
void ApplyTroll(int victim, const char[] name, int activator, trollModifier modifier, bool silent = false, int flags = 0) {
|
||||
static Troll troll;
|
||||
int trollIndex = GetTroll(name, troll);
|
||||
|
@ -213,8 +294,9 @@ void ApplyTroll(int victim, const char[] name, int activator, trollModifier modi
|
|||
if(!ApplyAffect(victim, troll, activator, modifier, flags)) {
|
||||
return;
|
||||
}
|
||||
bool isActive = IsTrollActive(victim, troll.name);
|
||||
if(!silent) {
|
||||
if(IsTrollActive(victim, troll.name)) {
|
||||
if(isActive) {
|
||||
ShowActivityEx(activator, "[FTT] ", "deactivated troll \"%s\" on %N. ", troll.name, victim);
|
||||
LogAction(activator, victim, "\"%L\" deactivated troll \"%s\" on \"%L\"", activator, troll.name, victim);
|
||||
} else {
|
||||
|
@ -232,7 +314,7 @@ void ApplyTroll(int victim, const char[] name, int activator, trollModifier modi
|
|||
}
|
||||
}
|
||||
if(modifier == TrollMod_Constant) {
|
||||
Trolls[troll.id].activeFlagClients[victim] = flags;
|
||||
Trolls[troll.id].activeFlagClients[victim] = isActive ? -1 : flags;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,7 +323,9 @@ bool ApplyAffect(int victim, const Troll troll, int activator, trollModifier mod
|
|||
if(StrEqual(troll.name, "Reset User")) {
|
||||
LogAction(activator, victim, "\"%L\" reset all troll effects for \"%L\"", activator, victim);
|
||||
ShowActivityEx(activator, "[FTT] ", "reset troll effects for %N. ", victim);
|
||||
troll.activeFlagClients[victim] = -1;
|
||||
for(int i = 0; i <= MAX_TROLLS; i++) {
|
||||
Trolls[i].activeFlagClients[victim] = -1;
|
||||
}
|
||||
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", 1.0);
|
||||
SetEntityGravity(victim, 1.0);
|
||||
return false;
|
||||
|
|
|
@ -147,7 +147,10 @@ public Action L4D2_OnEntityShoved(int client, int entity, int weapon, float vecD
|
|||
public Action OnClientSayCommand(int client, const char[] command, const char[] sArgs) {
|
||||
if(sArgs[0] == '@') return Plugin_Continue;
|
||||
static int honkID;
|
||||
static int profanityID;
|
||||
if(honkID == 0) honkID = GetTrollID("Honk / Meow");
|
||||
if(profanityID == 0) profanityID = GetTrollID("No Profanity");
|
||||
|
||||
if(Trolls[honkID].IsActive(client) && Trolls[honkID].activeFlagClients[client] & 1) {
|
||||
static char strings[32][7];
|
||||
int words = ExplodeString(sArgs, " ", strings, sizeof(strings), 5);
|
||||
|
@ -250,7 +253,7 @@ public Action OnClientSayCommand(int client, const char[] command, const char[]
|
|||
PrintToServer("%N: %s", client, sArgs);
|
||||
CPrintToChatAll("{blue}%N {default}: %s", client, newMessage);
|
||||
return Plugin_Handled;
|
||||
}else if(IsTrollActive(client, "No Profanity")) {
|
||||
}else if(Trolls[profanityID].IsActive(client)) {
|
||||
static char strings[32][MAX_PHRASE_LENGTH];
|
||||
ArrayList phrases;
|
||||
bool foundWord = false;
|
||||
|
@ -274,7 +277,16 @@ public Action OnClientSayCommand(int client, const char[] command, const char[]
|
|||
}
|
||||
fullMessagePhraseList.GetString(GetRandomInt(0, fullMessagePhraseList.Length - 1), message, MAX_PHRASE_LENGTH);
|
||||
}
|
||||
CPrintToChatAll("{blue}%N {default}: %s", client, message);
|
||||
if(Trolls[profanityID].activeFlagClients[client] % 2) {
|
||||
CPrintToChat(client, "{blue}%N {default}: %s", client, sArgs);
|
||||
for(int i = 1; i <= MaxClients; i++) {
|
||||
if(IsClientConnected(i) && IsClientInGame(i) && i != client) {
|
||||
CPrintToChat(i, "{blue}%N {default}: %s", client, message);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
CPrintToChatAll("{blue}%N {default}: %s", client, message);
|
||||
}
|
||||
PrintToServer("%N: %s", client, sArgs);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
@ -361,14 +373,26 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
|
|||
|
||||
public Action Event_TakeDamage(int victim, int& attacker, int& inflictor, float& damage, int& damagetype) {
|
||||
//Stop FF from marked:
|
||||
static int reverseFF;
|
||||
if(reverseFF == 0) reverseFF = GetTrollID("Reverse FF");
|
||||
if(attacker > 0 && attacker <= MaxClients && IsClientInGame(attacker) && IsPlayerAlive(attacker)) {
|
||||
if(g_PendingBanTroll[attacker] > 0 && GetClientTeam(attacker) == 2 && GetClientTeam(victim) == 2) {
|
||||
|
||||
return Plugin_Stop;
|
||||
}
|
||||
if(IsTrollActive(attacker, "Damage Boost")) {
|
||||
if(IsTrollActive(victim, "Damage Boost")) {
|
||||
damage * 2;
|
||||
return Plugin_Changed;
|
||||
} else if(Trolls[reverseFF].IsActive(attacker) && attacker != victim && GetClientTeam(attacker) != GetClientTeam(victim)) {
|
||||
float returnDmg = damage; //default is 1:1
|
||||
if(Trolls[reverseFF].activeFlagClients[attacker] & 4) {
|
||||
returnDmg /= 2.0;
|
||||
} else if(Trolls[reverseFF].activeFlagClients[attacker] & 2) {
|
||||
returnDmg *= 2.0;
|
||||
}
|
||||
SDKHooks_TakeDamage(attacker, attacker, attacker, returnDmg, damagetype, -1);
|
||||
damage = 0.0;
|
||||
return Plugin_Changed;
|
||||
}
|
||||
}
|
||||
return Plugin_Continue;
|
||||
|
|
|
@ -181,7 +181,7 @@ public int ChooseClumsySlotHandler(Menu menu, MenuAction action, int param1, int
|
|||
} else {
|
||||
ThrowItemToClosestPlayer(client, slot);
|
||||
}
|
||||
LogAction(param1, client, "\"%L\" activated troll \"Throw It all\" for \"%L\"", param1, client);
|
||||
LogAction(param1, client, "\"%L\" activated troll \"Throw It all\" slot=%d for \"%L\"", param1, slot, client);
|
||||
ShowActivityEx(param1, "[FTT] ", "activated troll \"Throw It All\" for %N. ", client);
|
||||
|
||||
ShowThrowItAllMenu(param1, userid);
|
||||
|
@ -233,7 +233,7 @@ public int ChooseTrollFlagHandler(Menu menu, MenuAction action, int param1, int
|
|||
int keyIndex = StringToInt(str[1]);
|
||||
int modifiers = StringToInt(str[2]);
|
||||
int flags = StringToInt(str[3]);
|
||||
bool done = StringToInt(str[4]) == 1;
|
||||
int nextIndex = StringToInt(str[4]);
|
||||
|
||||
if(client == 0) {
|
||||
ReplyToCommand(param1, "FTT: Could not acquire player");
|
||||
|
@ -243,20 +243,25 @@ public int ChooseTrollFlagHandler(Menu menu, MenuAction action, int param1, int
|
|||
static Troll troll;
|
||||
GetTrollByKeyIndex(keyIndex, troll);
|
||||
|
||||
if(done || !troll.flagsMultiselectable) {
|
||||
if(modifiers > 0) {
|
||||
if(modifiers == 1 || modifiers == 3)
|
||||
troll.Activate(client, param1, TrollMod_Instant, flags);
|
||||
if(modifiers == 2 || modifiers == 3)
|
||||
troll.Activate(client, param1, TrollMod_Constant, flags);
|
||||
} else {
|
||||
troll.Activate(client, param1, TrollMod_Invalid, flags);
|
||||
static TrollFlagPrompt prompt;
|
||||
if(nextIndex != -1) {
|
||||
nextIndex = GetNextPrompt(troll, flags, nextIndex);
|
||||
if(nextIndex != -1) {
|
||||
ShowSelectFlagMenu(param1, userid, modifiers, troll, flags, nextIndex);
|
||||
return;
|
||||
}
|
||||
ShowTrollsForCategory(param1, userid, troll.categoryID);
|
||||
} else {
|
||||
ShowSelectFlagMenu(param1, userid, modifiers, troll, flags);
|
||||
}
|
||||
|
||||
if(modifiers > 0) {
|
||||
if(modifiers & view_as<int>(TrollMod_Instant))
|
||||
troll.Activate(client, param1, TrollMod_Instant, flags);
|
||||
if(modifiers & view_as<int>(TrollMod_Constant))
|
||||
troll.Activate(client, param1, TrollMod_Constant, flags);
|
||||
} else {
|
||||
troll.Activate(client, param1, TrollMod_Invalid, flags);
|
||||
}
|
||||
ShowTrollsForCategory(param1, userid, troll.categoryID);
|
||||
|
||||
} else if (action == MenuAction_End)
|
||||
delete menu;
|
||||
}
|
||||
|
@ -332,37 +337,52 @@ void ShowTrollsForCategory(int client, int userid, int category) {
|
|||
trollMenu.Display(client, 0);
|
||||
}
|
||||
|
||||
void ShowSelectFlagMenu(int activator, int victimUserID, int modifiers, Troll troll, int prevFlags = 0) {
|
||||
static char info[MAX_TROLL_NAME_LENGTH+16];
|
||||
void ShowSelectFlagMenu(int activator, int victimUserID, int modifiers, Troll troll, int prevFlags = -1, int promptIndex = 0) {
|
||||
static char info[MAX_TROLL_NAME_LENGTH+16]; //victimUSERID|trollID|modifiers|flags||flagIndex
|
||||
static char name[32];
|
||||
|
||||
|
||||
Menu flagMenu = new Menu(ChooseTrollFlagHandler);
|
||||
if(troll.flagsMultiselectable) {
|
||||
if(prevFlags == 0) prevFlags = troll.defaultFlags;
|
||||
Format(info, sizeof(info), "%s: Choose flags (Multiple)", troll.name);
|
||||
flagMenu.SetTitle(info);
|
||||
|
||||
Format(info, sizeof(info), "%d|%d|%d|%d|1", victimUserID, troll.id, modifiers, prevFlags);
|
||||
flagMenu.AddItem(info, "Apply Troll / Finish");
|
||||
TrollFlagPrompt prompt;
|
||||
troll.GetFlagPrompt(promptIndex, prompt);
|
||||
prompt.GetPromptText(info, sizeof(info));
|
||||
|
||||
Format(info, sizeof(info), "%s: %s", troll.name, info);
|
||||
flagMenu.SetTitle(info);
|
||||
|
||||
// If there is another prompt, go to this index, or be done (-1)
|
||||
int nextIndex = (promptIndex < troll.flagPrompts.Length - 1) ? promptIndex + 1 : -1;
|
||||
|
||||
if(prompt.multiselect) {
|
||||
if(prevFlags == -1) prevFlags = prompt.defaults;
|
||||
|
||||
Format(info, sizeof(info), "%d|%d|%d|%d|%d", victimUserID, troll.id, modifiers, prevFlags, nextIndex);
|
||||
if(nextIndex == -1)
|
||||
flagMenu.AddItem(info, "Apply Troll / Finish");
|
||||
else
|
||||
flagMenu.AddItem(info, "Next Prompt");
|
||||
|
||||
for(int i = 0; i < troll.flagNames.Length; i++) {
|
||||
troll.flagNames.GetString(i, name, sizeof(name));
|
||||
int a = 1 << i;
|
||||
if(prevFlags > 0 && prevFlags & a == a)
|
||||
Format(name, sizeof(name), "%s (On)", name);
|
||||
int newFlags = prevFlags ^ a;
|
||||
Format(info, sizeof(info), "%d|%d|%d|%d|0", victimUserID, troll.id, modifiers, newFlags);
|
||||
flagMenu.AddItem(info, name);
|
||||
if(prompt.flags & a) {
|
||||
troll.flagNames.GetString(i, name, sizeof(name));
|
||||
if(prevFlags > 0 && prevFlags & a)
|
||||
Format(name, sizeof(name), "%s (On)", name);
|
||||
int newFlags = prevFlags ^ a;
|
||||
Format(info, sizeof(info), "%d|%d|%d|%d|%d", victimUserID, troll.id, modifiers, newFlags, promptIndex);
|
||||
flagMenu.AddItem(info, name);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Format(info, sizeof(info), "%s: Choose flags", troll.name);
|
||||
flagMenu.SetTitle(info);
|
||||
|
||||
if(prevFlags == -1) prevFlags = 0;
|
||||
// Single choice only
|
||||
for(int i = 0; i < troll.flagNames.Length; i++) {
|
||||
troll.flagNames.GetString(i, name, sizeof(name));
|
||||
Format(info, sizeof(info), "%d|%d|%d|%d|0", victimUserID, troll.id, modifiers, 1 << i);
|
||||
flagMenu.AddItem(info, name);
|
||||
if(prompt.flags & 1 << i) {
|
||||
troll.flagNames.GetString(i, name, sizeof(name));
|
||||
int newFlags = prevFlags | 1 << i;
|
||||
Format(info, sizeof(info), "%d|%d|%d|%d|%d", victimUserID, troll.id, modifiers, newFlags, nextIndex);
|
||||
flagMenu.AddItem(info, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
flagMenu.ExitButton = true;
|
||||
|
@ -377,8 +397,15 @@ void ShowThrowItAllMenu(int client, int userid) {
|
|||
static char itmName[32];
|
||||
Format(info, sizeof(info), "%d|-1", userid);
|
||||
itmMenu.AddItem(info, "All Items");
|
||||
|
||||
int victim = GetClientOfUserId(userid);
|
||||
if(victim == 0) {
|
||||
ReplyToCommand(client, "FTT: Could not acquire player");
|
||||
return;
|
||||
}
|
||||
|
||||
for(int slot = 0; slot <= 4; slot++) {
|
||||
int item = GetPlayerWeaponSlot(client, slot);
|
||||
int item = GetPlayerWeaponSlot(victim, slot);
|
||||
if(item > -1) {
|
||||
GetEdictClassname(item, itmName, sizeof(itmName));
|
||||
Format(info, sizeof(info), "%d|%d", userid, slot);
|
||||
|
@ -387,4 +414,17 @@ void ShowThrowItAllMenu(int client, int userid) {
|
|||
}
|
||||
itmMenu.ExitButton = true;
|
||||
itmMenu.Display(client, 0);
|
||||
}
|
||||
|
||||
int GetNextPrompt(Troll troll, int flags, int currentPrompt = 0) {
|
||||
static TrollFlagPrompt prompt;
|
||||
//If this prompt requires flags but they don't exist, skip to next that is valid or be done:
|
||||
for(int i = currentPrompt; i < troll.flagPrompts.Length; i++) {
|
||||
troll.GetFlagPrompt(i, prompt);
|
||||
if(prompt.requireFlags & flags) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
// No suitable prompts found, mark it as done:
|
||||
return -1;
|
||||
}
|
|
@ -71,7 +71,7 @@ bool SpawnSpecialNear(int target, int specialType) {
|
|||
|
||||
// doesnt seem to work with l4dhooks methods
|
||||
void BypassLimit() {
|
||||
int bot = CreateFakeClient("InfectedBot");
|
||||
int bot = CreateFakeClient("Infected Bot");
|
||||
if (bot != 0) {
|
||||
ChangeClientTeam(bot, 3);
|
||||
CreateTimer(0.1, Timer_KickBot, bot);
|
||||
|
|
|
@ -12,7 +12,6 @@ void SetupTrolls() {
|
|||
index = SetupTroll("Tank Magnet", "Attracts ALL tanks to any alive target with this troll enabled", TrollMod_Constant, false);
|
||||
AddMagnetFlags(index);
|
||||
index = SetupTroll("Witch Magnet", "All witches when startled will target any player with this troll", TrollMod_Constant, false);
|
||||
AddMagnetFlags(index);
|
||||
|
||||
SetCategory("Infected");
|
||||
SetupTroll("Swarm", "Swarms a player with zombies. Requires swarm plugin", TrollMod_Instant | TrollMod_Constant);
|
||||
|
@ -22,8 +21,13 @@ void SetupTrolls() {
|
|||
SetupTroll("Goo", "Spawns a spitter puddle underneath them", TrollMod_Instant);
|
||||
|
||||
SetCategory("Items");
|
||||
SetupTroll("Throw It All", "Player throws their item(s) periodically to a nearby player", TrollMod_Instant);
|
||||
index = SetupTroll("Throw It All", "Player throws their item(s) periodically to a nearby player", TrollMod_Instant, false);
|
||||
//Can't add directly, is custom troll:
|
||||
// Trolls[index].AddFlag("Throw to Admin", true);
|
||||
// Trolls[index].AddFlag("Drop At Feet", false);
|
||||
// Trolls[index].AddFlag("Drop At Admin", false);
|
||||
index = SetupTroll("Bad Throw", "Player drops throwables on throw, and biles/molotovs themselves", TrollMod_Constant, true);
|
||||
Trolls[index].AddFlagPrompt(true);
|
||||
Trolls[index].AddFlag("Biles", true);
|
||||
Trolls[index].AddFlag("Molotovs", true);
|
||||
Trolls[index].AddFlag("Pipebombs", true);
|
||||
|
@ -34,11 +38,18 @@ void SetupTrolls() {
|
|||
|
||||
SetCategory("Chat");
|
||||
SetupTroll("iCantSpellNoMore", "Chat messages letter will randomly changed with wrong letters", TrollMod_Constant);
|
||||
SetupTroll("No Profanity", "Replaces some words with random phrases", TrollMod_Constant);
|
||||
index = SetupTroll("No Profanity", "Replaces some words with random phrases", TrollMod_Constant);
|
||||
Trolls[index].AddFlagPrompt(false);
|
||||
Trolls[index].AddFlag("Show Modified to Them", true);
|
||||
Trolls[index].AddFlag("Show Original to Them", false);
|
||||
SetupTroll("Vocalize Gag", "Prevents player from sending any vocalizations (even automatic)", TrollMod_Constant);
|
||||
index = SetupTroll("Honk / Meow", "Honk or Meow", TrollMod_Constant, false);
|
||||
Trolls[index].AddCustomFlagPrompt("Choose Sound Type:");
|
||||
Trolls[index].AddFlag("Honk", true);
|
||||
Trolls[index].AddFlag("Meow", false);
|
||||
Trolls[index].AddCustomFlagPrompt("Choose Chat modifier:", false, 1);
|
||||
Trolls[index].AddFlag("Show Modified to Them", true);
|
||||
Trolls[index].AddFlag("Show Original to Them", false);
|
||||
SetupTroll("Reversed", "Reserves their message", TrollMod_Constant);
|
||||
|
||||
SetCategory("Health");
|
||||
|
@ -46,6 +57,11 @@ void SetupTrolls() {
|
|||
SetupTroll("Temp Health Quick Drain", "Makes a player's temporarily health drain very quickly", TrollMod_Constant);
|
||||
SetupTroll("Slow Drain", "Will make the player slowly lose health over time", TrollMod_Constant);
|
||||
SetupTroll("KillMeSoftly", "Make player eat or waste pills whenever possible", TrollMod_Instant | TrollMod_Constant);
|
||||
index = SetupTroll("Reverse FF", "All damage dealt to a player is reversed", TrollMod_Constant, false);
|
||||
Trolls[index].AddCustomFlagPrompt("Choose Reverse FF", false);
|
||||
Trolls[index].AddFlag("1:1 Ratio", true);
|
||||
Trolls[index].AddFlag("2x Ratio", false);
|
||||
Trolls[index].AddFlag("0.5x Ratio", false);
|
||||
|
||||
SetCategory("Misc");
|
||||
SetupTroll("Gun Jam", "On reload, small chance their gun gets jammed - Can't reload.", TrollMod_Constant);
|
||||
|
@ -59,7 +75,7 @@ void SetupTrolls() {
|
|||
|
||||
|
||||
// Initialize the default flag values to -1
|
||||
for(int i = 0; i < MAX_TROLLS; i++) {
|
||||
for(int i = 0; i <= MAX_TROLLS; i++) {
|
||||
for(int j = 1; j <= MAXPLAYERS; j++) {
|
||||
Trolls[i].activeFlagClients[j] = -1;
|
||||
}
|
||||
|
@ -67,6 +83,7 @@ void SetupTrolls() {
|
|||
}
|
||||
|
||||
void AddMagnetFlags(int index) {
|
||||
Trolls[index].AddCustomFlagPrompt("Choose Magnet Chance:", false);
|
||||
Trolls[index].AddFlag("Always (100%)", true);
|
||||
Trolls[index].AddFlag("Half Time (50%)", false);
|
||||
Trolls[index].AddFlag("Rare (10%)", false);
|
||||
|
|
|
@ -161,23 +161,13 @@ bool IsPlayerFarDistance(int client, float distance) {
|
|||
return client == farthestClient && difference > distance;
|
||||
}
|
||||
|
||||
int GetAutoPunishMode() {
|
||||
int number = 2 ^ GetRandomInt(0, AUTOPUNISH_MODE_COUNT - 1);
|
||||
if(hAutoPunish.IntValue & number == 0) {
|
||||
return GetAutoPunishMode();
|
||||
}else{
|
||||
return number;
|
||||
}
|
||||
}
|
||||
|
||||
stock int GetPrimaryReserveAmmo(int client) {
|
||||
int weapon = GetPlayerWeaponSlot(client, 0);
|
||||
if(weapon > -1) {
|
||||
int primaryAmmoType = GetEntProp(weapon, Prop_Send, "m_iPrimaryAmmoType");
|
||||
return GetEntData(client, g_iAmmoTable + (primaryAmmoType * 4));
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
stock bool SetPrimaryReserveAmmo(int client, int amount) {
|
||||
int weapon = GetPlayerWeaponSlot(client, 0);
|
||||
|
@ -185,9 +175,8 @@ stock bool SetPrimaryReserveAmmo(int client, int amount) {
|
|||
int primaryAmmoType = GetEntProp(weapon, Prop_Send, "m_iPrimaryAmmoType");
|
||||
SetEntData(client, g_iAmmoTable + (primaryAmmoType * 4), amount);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
stock void SendChatToAll(int client, const char[] message) {
|
||||
|
@ -202,33 +191,12 @@ stock void SendChatToAll(int client, const char[] message) {
|
|||
}
|
||||
|
||||
stock float GetTempHealth(int client) {
|
||||
//First filter -> Must be a valid client, successfully in-game and not an spectator (The dont have health).
|
||||
if(client <= 0 || !IsValidEntity(client) || !IsClientInGame(client)|| !IsPlayerAlive(client) || IsClientObserver(client)) {
|
||||
return -1.0;
|
||||
}
|
||||
if(client <= 0 || !IsValidEntity(client) || !IsClientInGame(client)|| !IsPlayerAlive(client) || IsClientObserver(client)) return -1.0;
|
||||
if(GetClientTeam(client) != 2) return 0.0;
|
||||
|
||||
//If the client is not on the survivors team, then just return the normal client health.
|
||||
if(GetClientTeam(client) != 2) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
//First, we get the amount of temporal health the client has
|
||||
float buffer = GetEntPropFloat(client, Prop_Send, "m_healthBuffer");
|
||||
|
||||
//In case the buffer is 0 or less, we set the temporal health as 0, because the client has not used any pills or adrenaline yet
|
||||
if(buffer <= 0.0) return 0.0;
|
||||
|
||||
|
||||
//This is the difference between the time we used the temporal item, and the current time
|
||||
float difference = GetGameTime() - GetEntPropFloat(client, Prop_Send, "m_healthBufferTime");
|
||||
|
||||
//We get the decay rate from this convar (Note: Adrenaline uses this value)
|
||||
float decay = GetConVarFloat(FindConVar("pain_pills_decay_rate"));
|
||||
|
||||
//This is a constant we create to determine the amount of health. This is the amount of time it has to pass
|
||||
//before 1 Temporal HP is consumed.
|
||||
float constant = 1.0 / decay;
|
||||
|
||||
//Then we do the calcs
|
||||
return buffer - (difference / constant);
|
||||
float decay = FindConVar("pain_pills_decay_rate").FloatValue;
|
||||
return buffer - (difference / (1.0 / decay));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue