Updated plugins

- Fixed server spam for 200IQBots_FlyYouFools
- Fixed timer response in L4D2Tools
- Added redirect damage to l4d2_ff_test
This commit is contained in:
Jackzie 2020-06-14 19:51:16 -05:00
parent fa0f5b65e7
commit 95404d458d
No known key found for this signature in database
GPG key ID: 1E834FE36520537A
7 changed files with 60 additions and 47 deletions

View file

@ -84,5 +84,5 @@ Another joke plugin, with it configured, a victim will have a % chance their sho
* **Convars:** * **Convars:**
* `troll_enable <0/1>` - Enable troll. 0 -> OFF, 1 -> Shots * `troll_enable <0/1>` - Enable troll. 0 -> OFF, 1 -> Shots
* `troll_shot_fail_percentage <0.0-1.0>` - percentage float (0.0 to 1.0) chance that victims' shots fail * `troll_shot_fail_percentage <0.0-1.0>` - percentage float (0.0 to 1.0) chance that victims' shots fail
* `troll_targets <ids>` - comma separate list of steamid64 targets (ex: STEAM_0:0:75141700) * `troll_targets <ids>` - comma separated list of steamid64 targets (ex: STEAM_0:0:75141700)
* `troll_shot_mode <0/1>` - 0 -> ALL Weapons, 1 -> AWP * `troll_shot_mode <0/1>` - 0 -> ALL Weapons, 1 -> AWP

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -38,7 +38,6 @@ public void OnPluginStart()
AutoExecConfig(true, "200IQBots_FlyYouFools"); AutoExecConfig(true, "200IQBots_FlyYouFools");
} }
public void OnMapStart() { public void OnMapStart() {
@ -64,9 +63,6 @@ public Action BotControlTimer(Handle timer)
{ {
//remove timer once tank no longer exists, is dead, or finale escape vehicle arrived //remove timer once tank no longer exists, is dead, or finale escape vehicle arrived
if(bEscapeReady || TankClient == -1 || !IsClientInGame(TankClient) || !IsPlayerAlive(TankClient)) { if(bEscapeReady || TankClient == -1 || !IsClientInGame(TankClient) || !IsPlayerAlive(TankClient)) {
#if debug
PrintToServer("Tank processing now ended. Escape ready or tank has been killed.");
#endif
//incase any other tanks are available //incase any other tanks are available
FindExistingTank(); FindExistingTank();
return Plugin_Stop; return Plugin_Stop;
@ -74,15 +70,7 @@ public Action BotControlTimer(Handle timer)
//Once an AI tank is awakened, m_lookatPlayer is set to a player ID //Once an AI tank is awakened, m_lookatPlayer is set to a player ID
//Possible props: m_lookatPlayer, m_zombieState (if 1), m_hasVisibleThreats //Possible props: m_lookatPlayer, m_zombieState (if 1), m_hasVisibleThreats
int tank_target = GetEntPropEnt(TankClient, Prop_Send, "m_lookatPlayer", 0); int tank_target = GetEntPropEnt(TankClient, Prop_Send, "m_lookatPlayer", 0);
#if debug
bool hasVisibleThreats = GetEntProp(TankClient, Prop_Send, "m_hasVisibleThreats", 1) == 1;
char targetted_name[64];
#endif
if(tank_target > -1) { if(tank_target > -1) {
#if debug
GetClientName(tank_target, targetted_name, sizeof(targetted_name));
ShowHintToAll("tank_target: %d (%s) | visible threats: %b", tank_target, targetted_name, hasVisibleThreats);
#endif
//grab tank position outside loop, only calculate bot //grab tank position outside loop, only calculate bot
float TankPosition[3]; float TankPosition[3];
GetClientAbsOrigin(TankClient, TankPosition); GetClientAbsOrigin(TankClient, TankPosition);
@ -122,7 +110,6 @@ public void FindExistingTank() {
char name[16]; char name[16];
GetClientName(i, name, sizeof(name)); GetClientName(i, name, sizeof(name));
if(StrContains(name,"Tank",true) > -1) { if(StrContains(name,"Tank",true) > -1) {
PrintToServer("Found existing tank with id %d", i);
TankClient = i; TankClient = i;
CreateTimer(0.1, BotControlTimer, _, TIMER_REPEAT); CreateTimer(0.1, BotControlTimer, _, TIMER_REPEAT);
break; break;
@ -175,7 +162,7 @@ stock void ShowHintToAll(const char[] format, any ...) {
* @param bufferSize The size of the buffer * @param bufferSize The size of the buffer
* @return True if item, false if no item * @return True if item, false if no item
*/ */
stock bool GetItemClassSlot(int client, int slot, char[] buffer, int bufferSize) { stock bool GetItemSlotClassName(int client, int slot, char[] buffer, int bufferSize) {
int item = GetPlayerWeaponSlot(client, slot); int item = GetPlayerWeaponSlot(client, slot);
if(item > -1) { if(item > -1) {
GetEdictClassname(item, buffer, bufferSize); GetEdictClassname(item, buffer, bufferSize);

View file

@ -3,7 +3,7 @@
#define DEBUG #define DEBUG
#define PLUGIN_NAME "Misc Tools" #define PLUGIN_NAME "L4D2 Misc Tools"
#define PLUGIN_DESCRIPTION "Includes: Notice on laser use, Timer for gauntlet runs" #define PLUGIN_DESCRIPTION "Includes: Notice on laser use, Timer for gauntlet runs"
#define PLUGIN_AUTHOR "jackzmc" #define PLUGIN_AUTHOR "jackzmc"
#define PLUGIN_VERSION "1.0" #define PLUGIN_VERSION "1.0"
@ -13,14 +13,12 @@
#include <sdktools> #include <sdktools>
//#include <sdkhooks> //#include <sdkhooks>
#pragma newdecls required
bool bLasersUsed[2048]; bool bLasersUsed[2048];
ConVar hLaserNotice, hFinaleTimer; ConVar hLaserNotice, hFinaleTimer;
int iFinaleStartTime; int iFinaleStartTime;
public Plugin myinfo = public Plugin myinfo = {
{
name = PLUGIN_NAME, name = PLUGIN_NAME,
author = PLUGIN_AUTHOR, author = PLUGIN_AUTHOR,
description = PLUGIN_DESCRIPTION, description = PLUGIN_DESCRIPTION,
@ -28,8 +26,7 @@ public Plugin myinfo =
url = PLUGIN_URL url = PLUGIN_URL
}; };
public void OnPluginStart() public void OnPluginStart() {
{
EngineVersion g_Game = GetEngineVersion(); EngineVersion g_Game = GetEngineVersion();
if(g_Game != Engine_Left4Dead && g_Game != Engine_Left4Dead2) if(g_Game != Engine_Left4Dead && g_Game != Engine_Left4Dead2)
{ {
@ -43,9 +40,10 @@ public void OnPluginStart()
HookEvent("gauntlet_finale_start", Event_GauntletStart); HookEvent("gauntlet_finale_start", Event_GauntletStart);
HookEvent("finale_start", Event_FinaleStart); HookEvent("finale_start", Event_FinaleStart);
HookEvent("finale_vehicle_leaving", Event_FinaleEnd); HookEvent("finale_vehicle_leaving", Event_FinaleEnd);
//RegAdminCmd("sm_respawn", Command_SpawnSpecial, ADMFLAG_CHEATS, "Respawn a dead survivor right where they died.");
} }
#if 1
//laserNotice //laserNotice
public void Event_PlayerUse(Event event, const char[] name, bool dontBroadcast) { public void Event_PlayerUse(Event event, const char[] name, bool dontBroadcast) {
if(hLaserNotice.BoolValue) { if(hLaserNotice.BoolValue) {
@ -70,34 +68,35 @@ public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast) {
bLasersUsed[i] = false; bLasersUsed[i] = false;
} }
} }
#endif
#if 1
//finaletimer //finaletimer
public void Event_GauntletStart(Event event, const char[] name, bool dontBroadcast) { public void Event_GauntletStart(Event event, const char[] name, bool dontBroadcast) {
if(hFinaleTimer.IntValue > 0) { if(hFinaleTimer.IntValue > 0) {
iFinaleStartTime = GetTime(); iFinaleStartTime = GetTime();
PrintToChatAll("The finale timer has been started"); PrintHintTextToAll("The finale timer has been started");
} }
} }
public void Event_FinaleStart(Event event, const char[] name, bool dontBroadcast) { public void Event_FinaleStart(Event event, const char[] name, bool dontBroadcast) {
if(hFinaleTimer.IntValue == 2) { if(hFinaleTimer.IntValue == 2) {
iFinaleStartTime = GetTime(); iFinaleStartTime = GetTime();
PrintToChatAll("The finale timer has been started"); PrintHintTextToAll("The finale timer has been started");
} }
} }
public void Event_FinaleEnd(Event event, const char[] name, bool dontBroadcast) { public void Event_FinaleEnd(Event event, const char[] name, bool dontBroadcast) {
if(hFinaleTimer.IntValue != 0) { if(hFinaleTimer.IntValue != 0) {
int difference = GetTime() - iFinaleStartTime; int difference = GetTime() - iFinaleStartTime;
iFinaleStartTime = 0;
char time[32]; char time[32];
FormatMs(difference, time, sizeof(time)); FormatSeconds(difference, time, sizeof(time));
PrintToChatAll("Finale took %s to complete", time); PrintToChatAll("Finale took %s to complete", time);
iFinaleStartTime = 0;
} }
} }
#endif
/** /**
* Prints human readable duration from milliseconds * Prints human readable duration from milliseconds
* *
@ -105,22 +104,20 @@ public void Event_FinaleEnd(Event event, const char[] name, bool dontBroadcast)
* @param str The char array to use for text * @param str The char array to use for text
* @param strSize The size of the string * @param strSize The size of the string
*/ */
stock void FormatMs(int ms, char[] str, int strSize) { stock void FormatSeconds(int raw_sec, char[] str, int strSize) {
int sec = ms / 1000; int hours = raw_sec / 3600;
int h = sec / 3600; int minutes = (raw_sec -(3600*hours))/60;
int m = (sec -(3600*h))/60; int seconds = (raw_sec -(3600*hours)-(minutes*60));
int s = (sec -(3600*h)-(m*60)); if(hours >= 1) {
if(h >= 1) { Format(str, strSize, "%d hours, %d.%d minutes", hours, minutes, seconds);
Format(str, strSize, "%d hour, %d.%d minutes", h, m, s); }else if(minutes >= 1) {
}else if(m >= 1) { Format(str, strSize, "%d minutes and %d seconds", minutes, seconds);
Format(str, strSize, "%d minutes and %d seconds", m, s);
}else { }else {
float raw_seconds = float(ms) / 1000; Format(str, strSize, "%d seconds", seconds);
Format(str, strSize, "%0.1f seconds", raw_seconds);
} }
} }
stock void ShowHintToAll(const char[] format, any ...) { stock void ShowDelayedHintToAll(const char[] format, any ...) {
char buffer[254]; char buffer[254];
VFormat(buffer, sizeof(buffer), format, 2); VFormat(buffer, sizeof(buffer), format, 2);
static int hintInt = 0; static int hintInt = 0;
@ -130,7 +127,7 @@ stock void ShowHintToAll(const char[] format, any ...) {
} }
hintInt++; hintInt++;
} }
stock void ShowHint(int client, const char[] format, any ...) { stock void ShowDelayedHint(int client, const char[] format, any ...) {
char buffer[254]; char buffer[254];
VFormat(buffer, sizeof(buffer), format, 2); VFormat(buffer, sizeof(buffer), format, 2);
static int hintInt = 0; static int hintInt = 0;
@ -140,3 +137,22 @@ stock void ShowHint(int client, const char[] format, any ...) {
} }
hintInt++; hintInt++;
} }
stock void CheatCommand(int client, const char[] command, const char[] argument1, const char[] argument2) {
int userFlags = GetUserFlagBits(client);
SetUserFlagBits(client, ADMFLAG_ROOT);
int flags = GetCommandFlags(command);
SetCommandFlags(command, flags & ~FCVAR_CHEAT);
FakeClientCommand(client, "%s %s %s", command, argument1, argument2);
SetCommandFlags(command, flags);
SetUserFlagBits(client, userFlags);
}
stock int GetAnyValidClient() {
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && !IsFakeClient(i))
{
return i;
}
}
return -1;
}

View file

@ -16,6 +16,7 @@
static bool bLateLoaded; static bool bLateLoaded;
static float ffDamage[MAXPLAYERS+1]; static float ffDamage[MAXPLAYERS+1];
static int ffCount[MAXPLAYERS+1]; static int ffCount[MAXPLAYERS+1];
ConVar hRedirectFFScale, hVictimFFReductionScale;
public Plugin myinfo = public Plugin myinfo =
{ {
@ -49,6 +50,9 @@ public void OnPluginStart()
} }
} }
} }
hRedirectFFScale = CreateConVar("sm_redirect_ff_scale","1.0","The redirected damage back to attacker. 0-> OFF | 1 -> All damage",FCVAR_NONE,true,0.0);
hVictimFFReductionScale = CreateConVar("sm_victim_ff_scale",".5","This is mulitplied by the damage the victim will receive. 0 -> No damage, 1 -> All damage", FCVAR_NONE, true, 0.0, true, 1.0);
HookEvent("round_start", Event_RoundStart); HookEvent("round_start", Event_RoundStart);
RegConsoleCmd("sm_view_ff", Command_ViewFF, "View all player's friendly fire counts"); RegConsoleCmd("sm_view_ff", Command_ViewFF, "View all player's friendly fire counts");
} }
@ -91,8 +95,14 @@ public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
//damage counting //damage counting
public Action OnTakeDamage(int victim, int& attacker, int& inflictor, float& damage, int& damagetype, int& weapon, float damageForce[3], float damagePosition[3]) { public Action OnTakeDamage(int victim, int& attacker, int& inflictor, float& damage, int& damagetype, int& weapon, float damageForce[3], float damagePosition[3]) {
if(attacker > 0 && attacker <= MaxClients) {
ffDamage[attacker] += damage; ffDamage[attacker] += damage;
ffCount[attacker]++; ffCount[attacker]++;
//apply the reduction scale to damage
float reflection_damage = damage * hRedirectFFScale.FloatValue;
damage = damage * hVictimFFReductionScale.FloatValue;
SDKHooks_TakeDamage(attacker, 0, 0, reflection_damage);
}
return Plugin_Continue; return Plugin_Continue;
} }