mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-06 19:13:21 +00:00
TKStopper: Minor tweaks
This commit is contained in:
parent
7fd2af923c
commit
074cf2fd3c
2 changed files with 56 additions and 30 deletions
Binary file not shown.
|
@ -33,6 +33,7 @@ enum struct PlayerData {
|
||||||
int idleStartTime;
|
int idleStartTime;
|
||||||
int lastFFTime;
|
int lastFFTime;
|
||||||
int jumpAttempts;
|
int jumpAttempts;
|
||||||
|
int ffCount;
|
||||||
|
|
||||||
float TKDamageBuffer;
|
float TKDamageBuffer;
|
||||||
float totalDamageFF;
|
float totalDamageFF;
|
||||||
|
@ -84,7 +85,7 @@ public void OnPluginStart() {
|
||||||
AutoExecConfig(true, "l4d2_tkstopper");
|
AutoExecConfig(true, "l4d2_tkstopper");
|
||||||
|
|
||||||
HookEvent("finale_vehicle_ready", Event_FinaleVehicleReady);
|
HookEvent("finale_vehicle_ready", Event_FinaleVehicleReady);
|
||||||
HookEvent("player_disconnect", Event_PlayerDisconnect);
|
HookEvent("player_team", Event_PlayerDisconnect);
|
||||||
|
|
||||||
HookEvent("charger_carry_start", Event_ChargerCarry);
|
HookEvent("charger_carry_start", Event_ChargerCarry);
|
||||||
HookEvent("charger_carry_end", Event_ChargerCarry);
|
HookEvent("charger_carry_end", Event_ChargerCarry);
|
||||||
|
@ -115,6 +116,7 @@ public void OnPluginStart() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LoadTranslations("common.phrases");
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Special Infected Events
|
// Special Infected Events
|
||||||
|
@ -202,31 +204,39 @@ public void OnClientDisconnect(int client) {
|
||||||
pData[client].TKDamageBuffer = 0.0;
|
pData[client].TKDamageBuffer = 0.0;
|
||||||
pData[client].jumpAttempts = 0;
|
pData[client].jumpAttempts = 0;
|
||||||
pData[client].underAttack = false;
|
pData[client].underAttack = false;
|
||||||
|
pData[client].ffCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only clear things when they fully left on their own accord:
|
// Only clear things when they fully left on their own accord:
|
||||||
public void Event_PlayerDisconnect(Event event, const char[] name, bool dontBroadcast) {
|
public void Event_PlayerDisconnect(Event event, const char[] name, bool dontBroadcast) {
|
||||||
|
if(!event.GetBool("disconnect")) return;
|
||||||
|
|
||||||
int client = GetClientOfUserId(event.GetInt("userid"));
|
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||||
if(client > 0 && !IsFakeClient(client) && GetClientTeam(client) <= 2) {
|
if(client > 0 && event.GetInt("team") <= 2) {
|
||||||
if (pData[client].isTroll) {
|
if (pData[client].isTroll && !IsFakeClient(client)) {
|
||||||
BanClient(client, hBanTime.IntValue, BANFLAG_AUTO | BANFLAG_AUTHID, "Excessive FF", "Excessive Friendly Fire", "TKStopper");
|
BanClient(client, hBanTime.IntValue, BANFLAG_AUTO | BANFLAG_AUTHID, "Excessive FF (Auto)", "Excessive Friendly Fire", "TKStopper");
|
||||||
pData[client].isTroll = false;
|
pData[client].isTroll = false;
|
||||||
pData[client].autoRFFScaleFactor = 0.0;
|
|
||||||
pData[client].totalDamageFF = 0.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float minutesSinceiLastFFTime = (GetTime() - pData[client].lastFFTime) / 60.0;
|
if(!IsFakeClient(client)) {
|
||||||
float activeRate = pData[client].autoRFFScaleFactor - (minutesSinceiLastFFTime * hFFAutoScaleForgivenessAmount.FloatValue);
|
float minutesSinceiLastFFTime = GetLastFFMinutes(client);
|
||||||
if(activeRate < 0.0) activeRate = 0.0;
|
float activeRate = GetActiveRate(client);
|
||||||
PrintToConsoleAll("[TKStopper] FF Summary for %N:", client);
|
PrintToConsoleAll("[TKStopper] FF Summary for %N:", client);
|
||||||
PrintToConsoleAll("\t\t%.2f TK-FF buffer (%.2f total ff) | %.3f (buf %f) rFF rate | lastff %.1f min ago | %d suicide jumps",
|
PrintToConsoleAll("\t\t%.2f TK-FF buffer (%.2f total ff, %d freq.) | %.3f (buf %f) rFF rate | lastff %.1f min ago | %d suicide jumps",
|
||||||
pData[client].TKDamageBuffer,
|
pData[client].TKDamageBuffer,
|
||||||
pData[client].totalDamageFF,
|
pData[client].totalDamageFF,
|
||||||
activeRate,
|
pData[client].ffCount,
|
||||||
pData[client].autoRFFScaleFactor,
|
activeRate,
|
||||||
minutesSinceiLastFFTime,
|
pData[client].autoRFFScaleFactor,
|
||||||
pData[client].jumpAttempts
|
minutesSinceiLastFFTime,
|
||||||
);
|
pData[client].jumpAttempts
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
pData[client].autoRFFScaleFactor = 0.0;
|
||||||
|
pData[client].totalDamageFF = 0.0;
|
||||||
|
pData[client].ffCount = 0;
|
||||||
|
pData[client].immunityFlags = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,12 +298,13 @@ public Action Event_OnTakeDamage(int victim, int& attacker, int& inflictor, flo
|
||||||
}
|
}
|
||||||
pData[attacker].TKDamageBuffer += damage;
|
pData[attacker].TKDamageBuffer += damage;
|
||||||
pData[attacker].totalDamageFF += damage;
|
pData[attacker].totalDamageFF += damage;
|
||||||
|
pData[attacker].ffCount++;
|
||||||
|
|
||||||
// Auto reverse ff logic
|
// Auto reverse ff logic
|
||||||
int prevFFTime = pData[attacker].lastFFTime;
|
int prevFFTime = pData[attacker].lastFFTime;
|
||||||
pData[attacker].lastFFTime = time;
|
pData[attacker].lastFFTime = time;
|
||||||
// If not immune to RFF, damage is direct, _or admin shit_
|
// If not immune to RFF, damage is direct, _or admin shit_
|
||||||
if(~pData[attacker].immunityFlags & Immune_RFF && isDamageDirect && (!hFFAutoScaleIgnoreAdmins.BoolValue || !isAdmin)) {
|
if(~pData[attacker].immunityFlags & Immune_RFF && isDamageDirect) {
|
||||||
// Decrement any forgiven ratio (computed on demand)
|
// Decrement any forgiven ratio (computed on demand)
|
||||||
float minutesSinceiLastFFTime = (time - pData[attacker].lastFFTime) / 60.0;
|
float minutesSinceiLastFFTime = (time - pData[attacker].lastFFTime) / 60.0;
|
||||||
pData[attacker].autoRFFScaleFactor -= minutesSinceiLastFFTime * hFFAutoScaleForgivenessAmount.FloatValue;
|
pData[attacker].autoRFFScaleFactor -= minutesSinceiLastFFTime * hFFAutoScaleForgivenessAmount.FloatValue;
|
||||||
|
@ -315,7 +326,12 @@ public Action Event_OnTakeDamage(int victim, int& attacker, int& inflictor, flo
|
||||||
|
|
||||||
// Check for excessive friendly fire damage in short timespan
|
// Check for excessive friendly fire damage in short timespan
|
||||||
// If not immune to TK, if over TK threshold, not when escaping, and direct damage
|
// If not immune to TK, if over TK threshold, not when escaping, and direct damage
|
||||||
if(~pData[attacker].immunityFlags & Immune_TK && pData[attacker].TKDamageBuffer > hThreshold.IntValue && !isFinaleEnding && isDamageDirect) {
|
if(~pData[attacker].immunityFlags & Immune_TK
|
||||||
|
&& pData[attacker].TKDamageBuffer > hThreshold.IntValue
|
||||||
|
&& !isFinaleEnding
|
||||||
|
&& isDamageDirect
|
||||||
|
&& !IsFakeClient(victim) // Don't increment on bot-ff for now
|
||||||
|
) {
|
||||||
float diffJoinMin = (float(GetTime()) - float(pData[attacker].joinTime)) / 60.0;
|
float diffJoinMin = (float(GetTime()) - float(pData[attacker].joinTime)) / 60.0;
|
||||||
float lastFFMin = (float(GetTime()) - float(prevFFTime)) / 60.0;
|
float lastFFMin = (float(GetTime()) - float(prevFFTime)) / 60.0;
|
||||||
LogAction(-1, attacker, "Excessive FF (%.2f HP/%.2f total) (%.2f RFF Rate) (joined %.1fm ago) (%.1fmin last FF)",
|
LogAction(-1, attacker, "Excessive FF (%.2f HP/%.2f total) (%.2f RFF Rate) (joined %.1fm ago) (%.1fmin last FF)",
|
||||||
|
@ -332,7 +348,7 @@ public Action Event_OnTakeDamage(int victim, int& attacker, int& inflictor, flo
|
||||||
} else if(hTKAction.IntValue == 2) {
|
} else if(hTKAction.IntValue == 2) {
|
||||||
LogMessage("[TKStopper] Banning %N for excessive FF (%.2f HP) for %d minutes.", attacker, pData[attacker].TKDamageBuffer, hBanTime.IntValue);
|
LogMessage("[TKStopper] Banning %N for excessive FF (%.2f HP) for %d minutes.", attacker, pData[attacker].TKDamageBuffer, hBanTime.IntValue);
|
||||||
NotifyAllAdmins("[Notice] Banning %N for excessive FF (%.2f HP) for %d minutes.", attacker, pData[attacker].TKDamageBuffer, hBanTime.IntValue);
|
NotifyAllAdmins("[Notice] Banning %N for excessive FF (%.2f HP) for %d minutes.", attacker, pData[attacker].TKDamageBuffer, hBanTime.IntValue);
|
||||||
BanClient(attacker, hBanTime.IntValue, BANFLAG_AUTO | BANFLAG_AUTHID, "Excessive FF", "Excessive Friendly Fire", "TKStopper");
|
BanClient(attacker, hBanTime.IntValue, BANFLAG_AUTO | BANFLAG_AUTHID, "Excessive FF (Auto)", "Excessive Friendly Fire", "TKStopper");
|
||||||
} else if(hTKAction.IntValue == 3) {
|
} else if(hTKAction.IntValue == 3) {
|
||||||
LogMessage("[TKStopper] %N will be banned for FF on disconnect (%.2f HP) for %d minutes. ", attacker, pData[attacker].TKDamageBuffer, hBanTime.IntValue);
|
LogMessage("[TKStopper] %N will be banned for FF on disconnect (%.2f HP) for %d minutes. ", attacker, pData[attacker].TKDamageBuffer, hBanTime.IntValue);
|
||||||
NotifyAllAdmins("[Notice] %N will be banned for FF on disconnect (%.2f HP) for %d minutes. Use \"/ignore <player> tk\" to make them immune.", attacker, pData[attacker].TKDamageBuffer, hBanTime.IntValue);
|
NotifyAllAdmins("[Notice] %N will be banned for FF on disconnect (%.2f HP) for %d minutes. Use \"/ignore <player> tk\" to make them immune.", attacker, pData[attacker].TKDamageBuffer, hBanTime.IntValue);
|
||||||
|
@ -358,10 +374,11 @@ public Action Event_OnTakeDamage(int victim, int& attacker, int& inflictor, flo
|
||||||
}else if(isFinaleEnding) {
|
}else if(isFinaleEnding) {
|
||||||
// Keep admins immune if escape vehicle out, or if victim is a bot
|
// Keep admins immune if escape vehicle out, or if victim is a bot
|
||||||
if(isAdmin || IsFakeClient(victim)) return Plugin_Continue;
|
if(isAdmin || IsFakeClient(victim)) return Plugin_Continue;
|
||||||
SDKHooks_TakeDamage(attacker, attacker, attacker, damage * 2.0);
|
if(isDamageDirect)
|
||||||
|
SDKHooks_TakeDamage(attacker, attacker, attacker, damage * 2.0);
|
||||||
damage = 0.0;
|
damage = 0.0;
|
||||||
return Plugin_Changed;
|
return Plugin_Changed;
|
||||||
}else if(isDamageDirect && !isAdmin && pData[attacker].autoRFFScaleFactor > 0.3) { // Ignore fire and propane damage, mistakes can happen
|
}else if(isDamageDirect && pData[attacker].autoRFFScaleFactor > 0.3) { // Ignore fire and propane damage, mistakes can happen
|
||||||
// Apply their reverse ff damage, and have victim take a decreasing amount
|
// Apply their reverse ff damage, and have victim take a decreasing amount
|
||||||
SDKHooks_TakeDamage(attacker, attacker, attacker, pData[attacker].autoRFFScaleFactor * damage);
|
SDKHooks_TakeDamage(attacker, attacker, attacker, pData[attacker].autoRFFScaleFactor * damage);
|
||||||
if(pData[attacker].isTroll) return Plugin_Stop;
|
if(pData[attacker].isTroll) return Plugin_Stop;
|
||||||
|
@ -416,10 +433,9 @@ public Action Command_TKInfo(int client, int args) {
|
||||||
} else {
|
} else {
|
||||||
ReplyToCommand(client, "Immunity: (none, use /ignore <player> [immunity] to toggle)", target);
|
ReplyToCommand(client, "Immunity: (none, use /ignore <player> [immunity] to toggle)", target);
|
||||||
}
|
}
|
||||||
float minutesSinceiLastFFTime = (time - pData[target].lastFFTime) / 60.0;
|
float minutesSinceiLastFFTime = GetLastFFMinutes(target);
|
||||||
float activeRate = pData[target].autoRFFScaleFactor - (minutesSinceiLastFFTime * hFFAutoScaleForgivenessAmount.FloatValue);
|
float activeRate = GetActiveRate(target);
|
||||||
if(activeRate < 0.0) activeRate = 0.0;
|
ReplyToCommand(client, "FF Frequency: %d", pData[target].ffCount);
|
||||||
|
|
||||||
ReplyToCommand(client, "Total FF Damage: %.1f (%.1f min ago last ff)", pData[target].totalDamageFF, minutesSinceiLastFFTime);
|
ReplyToCommand(client, "Total FF Damage: %.1f (%.1f min ago last ff)", pData[target].totalDamageFF, minutesSinceiLastFFTime);
|
||||||
if(~pData[target].immunityFlags & Immune_TK)
|
if(~pData[target].immunityFlags & Immune_TK)
|
||||||
ReplyToCommand(client, "Recent FF (TKDetectBuff): %.1f", pData[target].TKDamageBuffer);
|
ReplyToCommand(client, "Recent FF (TKDetectBuff): %.1f", pData[target].TKDamageBuffer);
|
||||||
|
@ -492,10 +508,10 @@ public Action Command_IgnorePlayer(int client, int args) {
|
||||||
|
|
||||||
for (int i = 0; i < target_count; i++) {
|
for (int i = 0; i < target_count; i++) {
|
||||||
int target = target_list[i];
|
int target = target_list[i];
|
||||||
if (GetUserAdmin(target) != INVALID_ADMIN_ID) {
|
/*if (GetUserAdmin(target) != INVALID_ADMIN_ID) {
|
||||||
ReplyToCommand(client, "%N is an admin and is already immune.");
|
ReplyToCommand(client, "%N is an admin and is already immune.", target);
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (flags & Immune_TK) {
|
if (flags & Immune_TK) {
|
||||||
if (pData[target].immunityFlags & Immune_TK) {
|
if (pData[target].immunityFlags & Immune_TK) {
|
||||||
|
@ -528,6 +544,16 @@ public Action Command_IgnorePlayer(int client, int args) {
|
||||||
|
|
||||||
/// STOCKS
|
/// STOCKS
|
||||||
|
|
||||||
|
float GetLastFFMinutes(int client) {
|
||||||
|
return (GetTime() - pData[client].lastFFTime) / 60.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
float GetActiveRate(int client) {
|
||||||
|
float activeRate = pData[client].autoRFFScaleFactor - (GetLastFFMinutes(client) * hFFAutoScaleForgivenessAmount.FloatValue);
|
||||||
|
if(activeRate < 0.0) activeRate = 0.0;
|
||||||
|
return activeRate;
|
||||||
|
}
|
||||||
|
|
||||||
stock bool GetNearestPlayerPosition(int client, float pos[3]) {
|
stock bool GetNearestPlayerPosition(int client, float pos[3]) {
|
||||||
static float targetPos[3], lowestDist;
|
static float targetPos[3], lowestDist;
|
||||||
int lowestID = -1;
|
int lowestID = -1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue