Update plugins

This commit is contained in:
Jackz 2023-08-04 11:42:05 -05:00
parent 2c99586be1
commit daa3b26a4d
No known key found for this signature in database
GPG key ID: E0BBD94CF657F603
19 changed files with 611 additions and 298 deletions

View file

@ -4,7 +4,7 @@
//Allow MAX_TROLLS to be defined elsewhere
#if defined MAX_TROLLS
#else
#define MAX_TROLLS 50
#define MAX_TROLLS 51
#endif
enum trollModifier {
@ -82,6 +82,18 @@ enum struct Troll {
ArrayList flagNames;
ArrayList flagPrompts;
Timer timerFunction;
Handle timerHandles[MAXPLAYERS+1];
float timerInterval;
void SetTimer(float interval, Timer timer) {
this.timerInterval = interval;
this.timerFunction = timer;
for(int i = 0; i <= MAXPLAYERS; i++) {
this.timerHandles[i] = null;
}
}
bool HasMod(trollModifier mod) {
return ((this.mods >> (view_as<int>(mod)) - 1) & 1) == 1;
}
@ -208,15 +220,32 @@ enum struct Troll {
void Toggle(int client, int flags) {
ToggleTroll(client, this.name, flags);
if(this.IsActive(client)) {
this.Disable(client);
} else {
this.Enable(client, flags);
}
}
void Enable(int client, int flags) {
EnableTroll(client, this.name, flags);
this.activeFlagClients[client] = flags;
// If a timer is assigned, start it:
if(this.timerHandles[client] != null) {
delete this.timerHandles[client];
PrintToServer("FTT Debug: Old timer for %N, killing", client);
}
if(this.timerInterval > 0.0) {
this.timerHandles[client] = CreateTimer(this.timerInterval, this.timerFunction, GetClientUserId(client), TIMER_REPEAT);
}
}
void Disable(int client) {
DisableTroll(client, this.name);
this.activeFlagClients[client] = -1;
// Stop any running timer:
if(this.timerHandles[client] != null) {
PrintToServer("FTT Debug: Disabling timer for %N", client);
delete this.timerHandles[client];
}
}
bool IsActive(int client) {
@ -244,7 +273,7 @@ void ResetClient(int victim, bool wipe = true) {
if(victim == 0 || !IsClientConnected(victim)) return;
if(wipe) {
for(int i = 0; i <= MAX_TROLLS; i++) {
Trolls[i].activeFlagClients[victim] = -1;
Trolls[i].Disable(victim);
}
}
noRushingUsSpeed[victim] = 1.0;
@ -311,18 +340,12 @@ void GetTrollByKeyIndex(int index, Troll troll) {
troll = Trolls[index];
}
void ToggleTroll(int client, const char[] name, int flags = 0) {
static Troll troll;
GetTroll(name, troll);
if(troll.IsActive(client))
troll.activeFlagClients[client] = -1;
else
troll.activeFlagClients[client] = flags;
}
void SetTrollFlags(int client, const char[] name, int flags = -1) {
int index = GetTrollID(name);
Trolls[index].activeFlagClients[client] = flags;
if(flags == -1)
Trolls[index].Disable(client);
else
Trolls[index].Enable(client, flags);
}
void ApplyTroll(int victim, const char[] name, int activator, trollModifier modifier, int flags = 0, bool silent = false) {
@ -334,6 +357,10 @@ void ApplyTroll(int victim, const char[] name, int activator, trollModifier modi
return;
}
if(flags > -1 && Trolls[trollIndex].timerInterval > 0.0) {
CreateTimer(Trolls[trollIndex].timerInterval, Trolls[trollIndex].timerFunction, victim, TIMER_REPEAT);
}
if(!silent && SilentMenuSelected[activator]) silent = true;
static int MetaInverseTrollID;

View file

@ -44,7 +44,7 @@ public int Insta_SpecialHandler(Menu menu, MenuAction action, int client, int pa
}
SpecialType special = view_as<SpecialType>(specialInt);
if(inFace) {
if(SpawnSpecialForTarget(special, target, view_as<int>(Special_OnTarget))) {
if(SpawnSpecialForTarget(special, target, view_as<int>(Special_OnTarget | Special_SpawnDirectOnFailure))) {
LogAction(client, target, "\"%L\" spawned Insta-%s™ on \"%L\"", client, SPECIAL_NAMES[specialInt-1], target);
CShowActivityEx(client, "[FTT] ", "spawned {olive}Insta-%s™{default} on {olive}%N", SPECIAL_NAMES[specialInt-1], target);
} else {
@ -396,10 +396,9 @@ void ShowTrollMenu(int client, bool isComboList) {
menu.SetTitle("Choose a player to troll");
static char userid[8], display[64];
for(int i = 1; i <= MaxClients; i++) {
if(IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == 2) {
if(IsClientConnected(i) && IsClientInGame(i) && (hAllowEnemyTeam.BoolValue || GetClientTeam(i) == GetClientTeam(client))) {
IntToString(GetClientUserId(i), userid, sizeof(userid));
int realPlayer = L4D_GetBotOfIdlePlayer(i);
PrintToServer("%d/%d", i, realPlayer);
// Incase player is idle, grab their bot instead of them
if(realPlayer > 0 && IsClientConnected(realPlayer)) {
if(IsPlayerAlive(i))

View file

@ -45,6 +45,7 @@ stock bool SpawnSpecialForTarget(SpecialType specialType, int target, int spawnF
float minDistance = GetIdealMinDistance(specialType);
GetHorizontalPositionFromOrigin(pos, ang, minDistance, testPos);
if(!FindSuitablePosition(pos, testPos, minDistance, 100)) {
PrintToServer("[FTT] Could not find suitable position, falling back");
if(spawnFlags & view_as<int>(Special_SpawnDirectOnFailure))
GetClientAbsOrigin(target, pos);
else

View file

@ -11,6 +11,25 @@ public Action Timer_ThrowTimer(Handle timer) {
}
int instantCommonRef[MAXPLAYERS+1];
Action Timer_RandomVelocity(Handle h, int client) {
if(!IsClientConnected(client)) {
Trolls[t_randomizeVelocityIndex].timerHandles[client] = null;
return Plugin_Stop;
}
float bounds = 50.0;
if(Trolls[t_randomizeAnglesIndex].activeFlagClients[client] & 2) bounds = 100.0;
else if(Trolls[t_randomizeAnglesIndex].activeFlagClients[client] & 4) bounds = 200.0;
else if(Trolls[t_randomizeAnglesIndex].activeFlagClients[client] & 8) bounds = 500.0;
else if(Trolls[t_randomizeAnglesIndex].activeFlagClients[client] & 16) bounds = 1000.0;
float vel[3];
GetEntPropVector(client, Prop_Data, "m_vecVelocity", vel);
vel[0] += GetRandomFloat(-bounds, bounds);
vel[1] += GetRandomFloat(-bounds, bounds);
vel[2] += GetRandomFloat(-100.0, 150.0);
SetAbsVelocity(client, vel);
return Plugin_Continue;
}
public Action Timer_Main(Handle timer) {
static int loopTick;
@ -40,6 +59,19 @@ public Action Timer_Main(Handle timer) {
TeleportEntity(i, NULL_VECTOR, ang, NULL_VECTOR);
}
}
if(Trolls[t_randomizeVelocityIndex].IsActive(i)) {
float bounds = 50.0;
if(Trolls[t_randomizeVelocityIndex].activeFlagClients[i] & 2) bounds = 100.0;
else if(Trolls[t_randomizeVelocityIndex].activeFlagClients[i] & 4) bounds = 200.0;
else if(Trolls[t_randomizeVelocityIndex].activeFlagClients[i] & 8) bounds = 500.0;
else if(Trolls[t_randomizeVelocityIndex].activeFlagClients[i] & 16) bounds = 1000.0;
float vel[3];
GetEntPropVector(i, Prop_Data, "m_vecVelocity", vel);
vel[0] += GetRandomFloat(-bounds, bounds);
vel[1] += GetRandomFloat(-bounds, bounds);
vel[2] += GetRandomFloat(-100.0, 150.0);
SetAbsVelocity(i, vel);
}
if(Trolls[slowDrainIndex].IsActive(i)) {
if(loopTick % 4 == 0) {
int hp = GetClientHealth(i);

View file

@ -4,6 +4,7 @@ int slipperyShoesIndex = 0;
int stickyGooIndex = 0;
int invertedTrollIndex;
int t_randomizeAnglesIndex;
int t_randomizeVelocityIndex;
// int fireSpitMagnetTrollIndex;
void SetupTrolls() {
@ -45,7 +46,7 @@ void SetupTrolls() {
Trolls[index].AddFlag("30% Movement Speed", false);
Trolls[index].AddFlag("0% Movement Speed", false);
stickyGooIndex = index;
index = SetupTroll("Vocalize Specials", "Spawn commons on special vocals", TrollMod_Constant);
index = SetupTroll("Vocalize Specials", "Spawn commons on special vocals", TrollMod_Constant)
Trolls[index].AddFlagPrompt(false);
Trolls[index].AddFlag("Mute Vocalization", true);
Trolls[index].AddFlag("Do not mute", false);
@ -84,6 +85,7 @@ void SetupTrolls() {
// CATEGORY: Items
SetCategory("Items");
SetupTroll("Throw It All", "Player throws their item(s) periodically to a nearby player", TrollMod_Instant);
index = SetupTroll("Spicy Gas", "Gascans player picks up just ignite. Magic.", TrollMod_Constant);
Trolls[index].AddFlagPrompt(false);
Trolls[index].AddFlag("Always (100%)", false);
@ -204,6 +206,15 @@ void SetupTrolls() {
Trolls[index].AddFlag("Painful", false); //8
Trolls[index].AddFlag("Seizure", false); //16
t_randomizeAnglesIndex = index;
index = SetupTroll("Randomize Velocity", "Randomly change their velocity", TrollMod_Constant);
Trolls[index].SetTimer(0.1, Timer_RandomVelocity);
Trolls[index].AddCustomFlagPrompt("Frequency:", false);
Trolls[index].AddFlag("Loose", true); //1
Trolls[index].AddFlag("Slippery", false); //2
Trolls[index].AddFlag("Earthquake", false); //4
Trolls[index].AddFlag("Severe Earthquake", false); //8
Trolls[index].AddFlag("Bouncy Castle", false); //16
t_randomizeVelocityIndex = index;
/// CATEGORY: MISC
@ -230,6 +241,7 @@ void SetupTrolls() {
// Initialize the default flag values to -1
for(int i = 0; i <= MAX_TROLLS; i++) {
for(int j = 1; j <= MAXPLAYERS; j++) {
Trolls[i].timerHandles[j] = null;
Trolls[i].activeFlagClients[j] = -1;
}
}