2009-04-19 19:54:21 +02:00
|
|
|
/*
|
|
|
|
* ============================================================================
|
|
|
|
*
|
2009-07-05 08:49:23 +02:00
|
|
|
* Zombie:Reloaded
|
2009-04-19 19:54:21 +02:00
|
|
|
*
|
2009-06-12 05:51:26 +02:00
|
|
|
* File: damage.inc
|
|
|
|
* Type: Core
|
|
|
|
* Description: Modify damage stuff here.
|
|
|
|
*
|
2013-01-12 08:47:36 +01:00
|
|
|
* Copyright (C) 2009-2013 Greyscale, Richard Helgeby
|
2009-06-12 05:51:26 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-04-19 19:54:21 +02:00
|
|
|
*
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2015-08-01 15:31:03 +02:00
|
|
|
* @section Suicide intercept defines.
|
2009-04-19 19:54:21 +02:00
|
|
|
*/
|
2015-08-01 15:31:03 +02:00
|
|
|
#define DAMAGE_SUICIDE_MAX_CMDS 5
|
|
|
|
#define DAMAGE_SUICIDE_MAX_LENGTH 16
|
2009-05-14 02:28:26 +02:00
|
|
|
/**
|
2015-08-01 15:31:03 +02:00
|
|
|
* @endsection
|
2009-05-14 02:28:26 +02:00
|
|
|
*/
|
2009-04-19 19:54:21 +02:00
|
|
|
|
2009-06-26 04:38:03 +02:00
|
|
|
/**
|
|
|
|
* Array to keep track of normal/mother zombies.
|
|
|
|
*/
|
|
|
|
new bool:g_bDamageMotherZombie[MAXPLAYERS + 1];
|
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
/**
|
2009-05-14 02:28:26 +02:00
|
|
|
* Hook commands related to damage here.
|
2010-02-14 17:26:28 +01:00
|
|
|
* Note: This isn't OnCommandsHook because this depends on cvars.
|
2009-04-19 19:54:21 +02:00
|
|
|
*/
|
2010-02-14 17:26:28 +01:00
|
|
|
new bool:g_bSuicideCmdsHooked = false;
|
|
|
|
DamageLoad()
|
2009-04-19 19:54:21 +02:00
|
|
|
{
|
2010-02-14 17:26:28 +01:00
|
|
|
if (g_bSuicideCmdsHooked)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
// Create command callbacks (intercepts) for listed suicide commands.
|
2009-05-14 02:28:26 +02:00
|
|
|
decl String:suicidecmds[DAMAGE_SUICIDE_MAX_CMDS * DAMAGE_SUICIDE_MAX_LENGTH];
|
2009-04-20 02:56:26 +02:00
|
|
|
GetConVarString(g_hCvarsList[CVAR_DAMAGE_SUICIDE_CMDS], suicidecmds, sizeof(suicidecmds));
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
// Create array to store cmds
|
|
|
|
new String:arrayCmds[DAMAGE_SUICIDE_MAX_CMDS][DAMAGE_SUICIDE_MAX_LENGTH];
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
// Explode string into array indexes.
|
2009-07-24 00:05:14 +02:00
|
|
|
new cmdcount = ExplodeString(suicidecmds, ",", arrayCmds, sizeof(arrayCmds), sizeof(arrayCmds[]));
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// x = Array index.
|
2009-04-19 19:54:21 +02:00
|
|
|
// arrayCmds[x] = suicide command.
|
|
|
|
for (new x = 0; x <= cmdcount - 1; x++)
|
|
|
|
{
|
2009-07-24 00:05:14 +02:00
|
|
|
// Trim whitespace.
|
|
|
|
TrimString(arrayCmds[x]);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
// Prepare intercept for this command.
|
2017-01-22 15:09:22 +01:00
|
|
|
AddCommandListener(DamageSuicideIntercept, arrayCmds[x]);
|
2009-04-19 19:54:21 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2010-02-14 17:26:28 +01:00
|
|
|
// Important: If ZR can be unloaded some day, make sure to remove the listeners and set this to false.
|
|
|
|
g_bSuicideCmdsHooked = true;
|
2009-04-19 19:54:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Client is joining the server.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
|
|
|
* @param client The client index.
|
2009-04-22 04:53:19 +02:00
|
|
|
*/
|
2009-04-19 19:54:21 +02:00
|
|
|
DamageClientInit(client)
|
|
|
|
{
|
2009-04-21 01:45:49 +02:00
|
|
|
// Hook damage callbacks.
|
2015-08-01 15:31:03 +02:00
|
|
|
SDKHook(client, SDKHook_TraceAttack, DamageTraceAttack);
|
|
|
|
SDKHook(client, SDKHook_OnTakeDamage, DamageOnTakeDamage);
|
2019-09-29 01:13:13 +02:00
|
|
|
SDKHook(client, SDKHook_OnTakeDamageAlivePost, DamageOnTakeDamageAlivePost);
|
2009-04-19 19:54:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Client is leaving the server.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-04-19 19:54:21 +02:00
|
|
|
* @param client The client index.
|
|
|
|
*/
|
|
|
|
DamageOnClientDisconnect(client)
|
|
|
|
{
|
2015-08-01 15:31:03 +02:00
|
|
|
SDKUnhook(client, SDKHook_TraceAttack, DamageTraceAttack);
|
|
|
|
SDKUnhook(client, SDKHook_OnTakeDamage, DamageOnTakeDamage);
|
2019-09-29 01:13:13 +02:00
|
|
|
SDKUnhook(client, SDKHook_OnTakeDamageAlivePost, DamageOnTakeDamageAlivePost);
|
2009-04-19 19:54:21 +02:00
|
|
|
}
|
|
|
|
|
2009-06-26 04:38:03 +02:00
|
|
|
/**
|
|
|
|
* A client was infected.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-06-26 04:38:03 +02:00
|
|
|
* @param client The client index.
|
|
|
|
* @param motherinfect True if the zombie is mother, false if not.
|
|
|
|
*/
|
|
|
|
DamageOnClientInfected(client, bool:motherinfect)
|
|
|
|
{
|
|
|
|
// Update if client is a mother zombie or not.
|
|
|
|
g_bDamageMotherZombie[client] = motherinfect;
|
|
|
|
}
|
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
/**
|
|
|
|
* Hook: TraceAttack
|
|
|
|
* Called right before the bullet enters a client.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-04-19 19:54:21 +02:00
|
|
|
* @param client The client index.
|
2009-05-11 04:47:09 +02:00
|
|
|
* @param attacker The client index of the attacker.
|
2019-09-27 16:40:58 +02:00
|
|
|
* @param inflictor The entity index of the inflictor.
|
2009-05-11 04:47:09 +02:00
|
|
|
* @param damage The amount of damage inflicted.
|
2009-04-19 19:54:21 +02:00
|
|
|
* @param hitbox The hitbox index.
|
2016-02-06 00:47:47 +01:00
|
|
|
* @param hitgroup The hitgroup index.
|
2016-06-11 14:20:40 +02:00
|
|
|
* @return Return Plugin_Handled to stop bullet from hitting client.
|
|
|
|
* Plugin_Continue to allow bullet to hit client.
|
2009-04-19 19:54:21 +02:00
|
|
|
*/
|
2019-09-27 16:40:58 +02:00
|
|
|
public Action DamageTraceAttack(int client, int &attacker, int &inflictor, float &damage, int &damagetype, int &ammotype, int hitbox, int hitgroup)
|
2009-04-19 19:54:21 +02:00
|
|
|
{
|
|
|
|
// If attacker isn't valid, then stop.
|
2009-04-24 05:02:19 +02:00
|
|
|
if (!ZRIsClientValid(attacker))
|
|
|
|
{
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Continue;
|
2009-04-24 05:02:19 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-24 05:02:19 +02:00
|
|
|
// If client is attacking himself, then stop.
|
|
|
|
if(attacker == client)
|
2009-04-19 19:54:21 +02:00
|
|
|
{
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Continue;
|
2009-04-19 19:54:21 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
// Get zombie flag for each client.
|
2009-04-24 05:02:19 +02:00
|
|
|
new bool:clientzombie = InfectIsClientInfected(client);
|
|
|
|
new bool:attackerzombie = InfectIsClientInfected(attacker);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
// If the flags are the same on both clients, then stop.
|
|
|
|
if (clientzombie == attackerzombie)
|
|
|
|
{
|
2009-04-23 06:39:11 +02:00
|
|
|
// If friendly fire is blocked, then allow damage.
|
|
|
|
new bool:damageblockff = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_BLOCK_FF]);
|
|
|
|
if (!damageblockff)
|
|
|
|
{
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Continue;
|
2009-04-23 06:39:11 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-23 06:39:11 +02:00
|
|
|
// Stop bullet from hurting client.
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Handled;
|
2009-04-19 19:54:21 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-23 06:39:11 +02:00
|
|
|
// Here we know that attacker and client are different teams.
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2013-01-05 02:44:46 +01:00
|
|
|
// Check if immunity module requires damage to be blocked.
|
2019-09-29 01:13:13 +02:00
|
|
|
if (ImmunityOnClientTraceAttack(client, attacker, inflictor, damage, damagetype, ammotype, hitgroup))
|
2013-01-05 02:44:46 +01:00
|
|
|
{
|
|
|
|
// Block damage.
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Handled;
|
2013-01-05 02:44:46 +01:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-26 09:00:05 +02:00
|
|
|
// If client is a human, then allow damage.
|
|
|
|
if (InfectIsClientHuman(client))
|
|
|
|
{
|
|
|
|
// Allow damage.
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Continue;
|
2009-06-26 09:00:05 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-23 06:39:11 +02:00
|
|
|
// If damage hitgroups cvar is disabled, then allow damage.
|
2013-08-20 19:37:04 +02:00
|
|
|
// TODO: There are two cvars: zr_hitgroups and zr_damage_hitgroups. Maybe
|
|
|
|
// just use zr_hitgroups?
|
2009-04-23 06:39:11 +02:00
|
|
|
new bool:damagehitgroups = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_HITGROUPS]);
|
|
|
|
if (!damagehitgroups)
|
|
|
|
{
|
|
|
|
// Allow damage.
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Continue;
|
2009-04-23 06:39:11 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-23 06:39:11 +02:00
|
|
|
// If damage is disabled for this hitgroup, then stop.
|
2009-05-29 08:43:15 +02:00
|
|
|
new index = HitgroupToIndex(hitgroup);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// If index can't be found, then allow damage.
|
|
|
|
if (index == -1)
|
|
|
|
{
|
|
|
|
// Allow damage.
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Continue;
|
2009-05-29 08:43:15 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
new bool:candamage = HitgroupsCanDamage(index);
|
2009-04-23 06:39:11 +02:00
|
|
|
if (!candamage)
|
|
|
|
{
|
|
|
|
// Stop bullet from hurting client.
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Handled;
|
2009-04-23 06:39:11 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-23 06:39:11 +02:00
|
|
|
// Allow damage.
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Continue;
|
2009-04-19 19:54:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hook: OnTakeDamage
|
|
|
|
* Called right before damage is done.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-04-19 19:54:21 +02:00
|
|
|
* @param client The client index.
|
2009-05-11 04:47:09 +02:00
|
|
|
* @param inflictor The entity index of the inflictor.
|
|
|
|
* @param attacker The client index of the attacker.
|
|
|
|
* @param damage The amount of damage inflicted.
|
|
|
|
* @param damagetype The type of damage inflicted.
|
2016-02-06 00:47:47 +01:00
|
|
|
* @param ammotype The ammo type of the attacker's weapon.
|
2016-06-11 14:20:40 +02:00
|
|
|
* @return Return Plugin_Handled to stop the damage to client.
|
|
|
|
* Plugin_Continue to allow damage to client.
|
2009-04-19 19:54:21 +02:00
|
|
|
*/
|
2019-09-29 01:13:13 +02:00
|
|
|
public Action DamageOnTakeDamage(int client, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon,
|
|
|
|
float damageForce[3], float damagePosition[3], int damagecustom)
|
2009-04-19 19:54:21 +02:00
|
|
|
{
|
2019-09-29 01:13:13 +02:00
|
|
|
bool custom = view_as<bool>(damagecustom & ZR_KNOCKBACK_CUSTOM);
|
|
|
|
if (custom)
|
|
|
|
return Plugin_Continue;
|
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
// Get classname of the inflictor.
|
|
|
|
decl String:classname[64];
|
|
|
|
GetEdictClassname(inflictor, classname, sizeof(classname));
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2016-08-08 10:20:23 +02:00
|
|
|
// Get the attacker weapon name.
|
|
|
|
new String:weaponname[64];
|
2016-09-25 22:00:29 +02:00
|
|
|
if(attacker >= 1 && attacker <= MAXPLAYERS)
|
2016-08-08 10:20:23 +02:00
|
|
|
GetClientWeapon(attacker, weaponname, sizeof(weaponname));
|
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
// If entity is a trigger, then allow damage. (Map is damaging client)
|
|
|
|
if (StrContains(classname, "trigger") > -1)
|
|
|
|
{
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Continue;
|
2009-04-19 19:54:21 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-07-17 03:34:56 +02:00
|
|
|
// Forward this hook to another module an return (or not) what it wants.
|
2016-09-25 22:00:29 +02:00
|
|
|
new Action:action = Action:NapalmOnTakeDamage(client, damagetype);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-11-04 21:37:26 +01:00
|
|
|
// If the napalm module wants to return here, then return the int casted into the action type.
|
2015-08-01 15:31:03 +02:00
|
|
|
if (action > Action:-1)
|
2009-07-17 03:34:56 +02:00
|
|
|
{
|
2015-08-01 15:31:03 +02:00
|
|
|
return action;
|
2009-07-17 03:34:56 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-23 06:39:11 +02:00
|
|
|
// Client was shot or knifed.
|
2015-08-08 18:38:23 +02:00
|
|
|
if (damagetype & DMG_BULLET || damagetype & DMG_NEVERGIB)
|
2009-04-21 01:45:49 +02:00
|
|
|
{
|
2009-04-23 06:39:11 +02:00
|
|
|
// If attacker isn't valid, then allow damage.
|
2009-04-24 05:02:19 +02:00
|
|
|
if (!ZRIsClientValid(attacker))
|
2009-04-21 01:45:49 +02:00
|
|
|
{
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Continue;
|
2009-04-21 01:45:49 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-23 06:39:11 +02:00
|
|
|
// Get zombie flag for each client.
|
2009-04-24 05:02:19 +02:00
|
|
|
new bool:clientzombie = InfectIsClientInfected(client);
|
|
|
|
new bool:attackerzombie = InfectIsClientInfected(attacker);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-23 06:39:11 +02:00
|
|
|
// If client and attacker are on the same team, then let CS:S handle the rest.
|
|
|
|
if (clientzombie == attackerzombie)
|
2009-04-21 01:45:49 +02:00
|
|
|
{
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Continue;
|
2009-04-21 01:45:49 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-23 06:39:11 +02:00
|
|
|
// We know that clientzombie is the opposite of attacker zombie.
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-23 06:39:11 +02:00
|
|
|
// If the client is a zombie, then allow damage.
|
|
|
|
if (clientzombie)
|
|
|
|
{
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Continue;
|
2009-04-23 06:39:11 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2017-09-07 20:11:27 +02:00
|
|
|
if (!clientzombie && attackerzombie && !(StrEqual(weaponname, "weapon_bayonet") || strncmp(weaponname, "weapon_knife", 12) == 0))
|
2016-08-08 10:20:23 +02:00
|
|
|
{
|
|
|
|
damage = 1.0;
|
|
|
|
return Plugin_Changed;
|
|
|
|
}
|
|
|
|
|
2013-01-11 10:07:18 +01:00
|
|
|
// Check if immunity module blocked or modified the damage.
|
|
|
|
new Action:immunityAction = ImmunityOnClientDamage(client, attacker, damage);
|
|
|
|
if (immunityAction != Plugin_Continue)
|
2013-01-05 02:44:46 +01:00
|
|
|
{
|
2013-01-11 10:07:18 +01:00
|
|
|
// Damage was blocked or modified.
|
|
|
|
return immunityAction;
|
2013-01-05 02:44:46 +01:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2016-05-08 22:25:30 +02:00
|
|
|
// Check if distance between clients is too high. (Anti lagcompensation / longknife)
|
|
|
|
new Float:maxDistance = GetConVarFloat(g_hCvarsList[CVAR_INFECT_MAX_DISTANCE]);
|
|
|
|
if (maxDistance != 0.0)
|
|
|
|
{
|
|
|
|
new Float:clientPosition[3];
|
|
|
|
new Float:attackerPosition[3];
|
|
|
|
|
|
|
|
GetClientAbsOrigin(client, clientPosition);
|
|
|
|
GetClientAbsOrigin(attacker, attackerPosition);
|
|
|
|
|
2016-08-18 06:47:48 +02:00
|
|
|
// ignore z axis
|
|
|
|
clientPosition[2] = 0.0;
|
|
|
|
attackerPosition[2] = 0.0;
|
|
|
|
|
2016-05-08 22:25:30 +02:00
|
|
|
new Float:distance = GetVectorDistance(clientPosition, attackerPosition);
|
|
|
|
|
|
|
|
// Block infection if distance is higher than allowed.
|
|
|
|
if (distance > maxDistance)
|
|
|
|
{
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-05 02:44:46 +01:00
|
|
|
// Client is about to be infected, re-add HP so they aren't killed by
|
|
|
|
// knife. But only do this when immunity mode is disabled.
|
|
|
|
if (ClassGetImmunityMode(client) == Immunity_None)
|
|
|
|
{
|
|
|
|
new health = GetClientHealth(client);
|
|
|
|
SetEntityHealth(client, health + RoundToNearest(damage));
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2013-01-05 02:44:46 +01:00
|
|
|
// Allow damage.
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Continue;
|
2013-01-05 02:44:46 +01:00
|
|
|
}
|
2009-04-21 01:45:49 +02:00
|
|
|
}
|
|
|
|
// Client was damaged by explosion.
|
2015-08-08 18:38:23 +02:00
|
|
|
else if (damagetype & DMG_BLAST)
|
2009-04-21 01:45:49 +02:00
|
|
|
{
|
2009-04-23 06:39:11 +02:00
|
|
|
// If blast damage is blocked, then stop.
|
|
|
|
new bool:damageblockblast = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_BLOCK_BLAST]);
|
|
|
|
if (!damageblockblast)
|
|
|
|
{
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Continue;
|
2009-04-23 06:39:11 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-21 01:45:49 +02:00
|
|
|
// If attacker isn't valid, then allow damage.
|
2009-04-24 05:02:19 +02:00
|
|
|
if (!ZRIsClientValid(attacker))
|
2009-04-21 01:45:49 +02:00
|
|
|
{
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Continue;
|
2009-04-21 01:45:49 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-21 01:45:49 +02:00
|
|
|
// If client is a zombie, then allow damage.
|
2009-04-24 05:02:19 +02:00
|
|
|
if (InfectIsClientInfected(client))
|
2009-04-21 01:45:49 +02:00
|
|
|
{
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Continue;
|
2009-04-21 01:45:49 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-21 01:45:49 +02:00
|
|
|
// Stop damage.
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Handled;
|
2009-04-21 01:45:49 +02:00
|
|
|
}
|
2017-09-10 18:05:34 +02:00
|
|
|
// Client was damaged by fire.
|
|
|
|
else if (damagetype & DMG_BURN)
|
|
|
|
{
|
|
|
|
// If its not an inferno, then allow damage.
|
|
|
|
if (strncmp(classname, "inferno", 7) != 0)
|
|
|
|
{
|
|
|
|
return Plugin_Continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If attacker isn't valid, then allow damage.
|
|
|
|
if (!ZRIsClientValid(attacker))
|
|
|
|
{
|
|
|
|
return Plugin_Continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If client is a zombie, then allow damage.
|
|
|
|
if (InfectIsClientInfected(client))
|
|
|
|
{
|
|
|
|
return Plugin_Continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stop damage.
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
2009-04-23 06:39:11 +02:00
|
|
|
// Client was damaged by falling.
|
2015-08-08 18:38:23 +02:00
|
|
|
else if (damagetype & DMG_FALL)
|
2009-04-19 19:54:21 +02:00
|
|
|
{
|
2009-04-23 06:39:11 +02:00
|
|
|
// If class has "nofalldamage" disabled, then allow damage.
|
|
|
|
new bool:blockfalldamage = ClassGetNoFallDamage(client);
|
|
|
|
if (!blockfalldamage)
|
2009-04-19 19:54:21 +02:00
|
|
|
{
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Continue;
|
2009-04-19 19:54:21 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-23 06:39:11 +02:00
|
|
|
// Stop damage.
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Handled;
|
2009-04-19 19:54:21 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
// Allow damage.
|
2015-08-01 15:31:03 +02:00
|
|
|
return Plugin_Continue;
|
2009-04-19 19:54:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-01-21 02:48:13 +01:00
|
|
|
* Command callback (kill, spectate, jointeam, joinclass)
|
2009-04-19 19:54:21 +02:00
|
|
|
* Block command if plugin thinks they are trying to commit suicide.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-04-19 19:54:21 +02:00
|
|
|
* @param client The client index.
|
|
|
|
* @param argc The number of arguments in command string.
|
2016-02-06 00:47:47 +01:00
|
|
|
*/
|
2017-01-22 15:09:22 +01:00
|
|
|
public Action:DamageSuicideIntercept(int client, const char[] command, int argc)
|
2009-04-19 19:54:21 +02:00
|
|
|
{
|
2010-05-19 15:34:26 +02:00
|
|
|
// Get suicide interception settings.
|
|
|
|
new bool:suicideAfterInfect = GetConVarBool(g_hCvarsList[CVAR_SUICIDE_AFTER_INFECT]);
|
|
|
|
new bool:suicideZombie = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_SUICIDE_ZOMBIE]);
|
|
|
|
new bool:suicideZombieMother = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_SUICIDE_MZOMBIE]);
|
|
|
|
new bool:suicideHuman = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_SUICIDE_HUMAN]);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2010-05-19 15:34:26 +02:00
|
|
|
// Check various criterias that will _allow_ the command. If no criterias
|
|
|
|
// match, block it.
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2010-05-19 15:34:26 +02:00
|
|
|
// Check general criterias.
|
2015-03-22 18:06:40 +01:00
|
|
|
if ((suicideAfterInfect && !InfectHasZombieSpawned()) || // Check if it should block suicides before mother zombie.
|
2010-05-19 15:34:26 +02:00
|
|
|
!ZRIsClientValid(client) || // Validate client (to stop console).
|
|
|
|
!IsPlayerAlive(client)) // Check if dead.
|
2009-04-19 19:54:21 +02:00
|
|
|
{
|
2010-05-19 15:34:26 +02:00
|
|
|
// Allow command.
|
2009-04-19 19:54:21 +02:00
|
|
|
return Plugin_Continue;
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2010-05-19 15:34:26 +02:00
|
|
|
// Check zombie criterias.
|
2009-06-26 04:38:03 +02:00
|
|
|
if (InfectIsClientInfected(client))
|
|
|
|
{
|
2010-05-19 15:34:26 +02:00
|
|
|
if (g_bDamageMotherZombie[client] && !suicideZombieMother || // Check if suicide is allowed for mother zombies.
|
|
|
|
(!g_bDamageMotherZombie[client] && !suicideZombie)) // Check if suicide is allowed for regular zombies.
|
2009-06-26 04:38:03 +02:00
|
|
|
{
|
2010-05-19 15:34:26 +02:00
|
|
|
// Allow command.
|
|
|
|
return Plugin_Continue;
|
2009-06-26 04:38:03 +02:00
|
|
|
}
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2010-05-19 15:34:26 +02:00
|
|
|
// Check human criterias.
|
|
|
|
// Allow suicide if player is a human and humans can suicide.
|
|
|
|
if (InfectIsClientHuman(client) && !suicideHuman)
|
2009-04-19 19:54:21 +02:00
|
|
|
{
|
2010-05-19 15:34:26 +02:00
|
|
|
// Allow command.
|
|
|
|
return Plugin_Continue;
|
2009-04-19 19:54:21 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2010-05-19 15:34:26 +02:00
|
|
|
// Tell client their command has been intercepted, and log.
|
|
|
|
TranslationPrintToChat(client, "Damage suicide intercept");
|
|
|
|
LogEvent(false, LogType_Normal, LOG_GAME_EVENTS, LogModule_Damage, "Suicide Intercept", "\"%L\" attempted suicide.", client);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2010-05-19 15:34:26 +02:00
|
|
|
// Block command.
|
|
|
|
return Plugin_Handled;
|
2009-05-01 11:22:45 +02:00
|
|
|
}
|
2019-09-29 01:13:13 +02:00
|
|
|
|
|
|
|
public void DamageOnTakeDamageAlivePost(int victim, int attacker, int inflictor, float damage, int damagetype, int weapon,
|
|
|
|
const float damageForce[3], const float damagePosition[3], int damagecustom)
|
|
|
|
{
|
|
|
|
// If attacker is invalid, then stop.
|
|
|
|
if (!ZRIsClientValid(attacker))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool custom = view_as<bool>(damagecustom & ZR_KNOCKBACK_CUSTOM);
|
|
|
|
|
|
|
|
char weaponname[64];
|
|
|
|
if (inflictor == attacker)
|
|
|
|
{
|
|
|
|
weapon = WeaponsGetActiveWeaponIndex(attacker);
|
|
|
|
if (weapon > 0)
|
|
|
|
GetEdictClassname(weapon, weaponname, sizeof(weaponname));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
GetEdictClassname(inflictor, weaponname, sizeof(weaponname));
|
|
|
|
|
|
|
|
ReplaceString(weaponname, sizeof(weaponname), "weapon_", "");
|
|
|
|
ReplaceString(weaponname, sizeof(weaponname), "_projectile", "");
|
|
|
|
|
|
|
|
int hitgroup = HITGROUP_GENERIC;
|
|
|
|
if (!(damagetype & DMG_BLAST) && !custom)
|
|
|
|
hitgroup = ToolsGetClientLastHitGroup(victim);
|
|
|
|
|
|
|
|
KnockbackOnClientHurt(victim, attacker, inflictor, weaponname, hitgroup, damage, damagetype, weapon, damagecustom);
|
|
|
|
|
|
|
|
// If attacker is a human and is getting damaged through DamageProxy, then stop.
|
|
|
|
// We don't want to get infected if we're being knifed inside of a human item.
|
|
|
|
if (custom && InfectIsClientHuman(victim))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ClassAlphaUpdate(victim);
|
|
|
|
InfectOnClientHurt(victim, attacker, weaponname);
|
|
|
|
AccountOnClientHurt(victim, attacker, RoundToFloor(damage));
|
|
|
|
SEffectsOnClientHurt(victim);
|
|
|
|
NapalmOnClientHurt(victim, attacker, weaponname, RoundToFloor(damage));
|
|
|
|
ZHPOnClientHurt(victim);
|
|
|
|
}
|