Changed default for suicide intercept, also added an option to only block mother zombies.

This commit is contained in:
Greyscale 2009-06-25 19:38:03 -07:00
parent b4789dc5ef
commit 061954fdc2
4 changed files with 47 additions and 12 deletions

View File

@ -324,12 +324,16 @@ zr_damage_block_blast "1"
// Suicide Intercept // Suicide Intercept
// Intercept suicide commands attempted by zombies. // Intercept suicide commands attempted by zombies.
// Default: "0"
zr_damage_suicide_zombie "0"
// Intercept suicide commands attempted by mother zombies.
// Default: "1" // Default: "1"
zr_damage_suicide_zombie "1" zr_damage_suicide_mzombie "1"
// Intercept suicide commands attempted by humans. // Intercept suicide commands attempted by humans.
// Default: "1" // Default: "0"
zr_damage_suicide_human "1" zr_damage_suicide_human "0"
// List of client commands to intercept as suicide attempts. [Delimiter: ", "] // List of client commands to intercept as suicide attempts. [Delimiter: ", "]
// Default: "kill, spectate, jointeam" // Default: "kill, spectate, jointeam"

View File

@ -73,6 +73,7 @@ enum CvarsList
Handle:CVAR_DAMAGE_BLOCK_FF, Handle:CVAR_DAMAGE_BLOCK_FF,
Handle:CVAR_DAMAGE_BLOCK_BLAST, Handle:CVAR_DAMAGE_BLOCK_BLAST,
Handle:CVAR_DAMAGE_SUICIDE_ZOMBIE, Handle:CVAR_DAMAGE_SUICIDE_ZOMBIE,
Handle:CVAR_DAMAGE_SUICIDE_MZOMBIE,
Handle:CVAR_DAMAGE_SUICIDE_HUMAN, Handle:CVAR_DAMAGE_SUICIDE_HUMAN,
Handle:CVAR_DAMAGE_SUICIDE_CMDS, Handle:CVAR_DAMAGE_SUICIDE_CMDS,
Handle:CVAR_SAYHOOKS_QUIET, Handle:CVAR_SAYHOOKS_QUIET,
@ -307,8 +308,9 @@ CvarsCreate()
g_hCvarsList[CVAR_DAMAGE_BLOCK_BLAST] = CreateConVar("zr_damage_block_blast", "1", "Block blast damage inflicted on self or teammates."); g_hCvarsList[CVAR_DAMAGE_BLOCK_BLAST] = CreateConVar("zr_damage_block_blast", "1", "Block blast damage inflicted on self or teammates.");
// Suicide Intercept // Suicide Intercept
g_hCvarsList[CVAR_DAMAGE_SUICIDE_ZOMBIE] = CreateConVar("zr_damage_suicide_zombie", "1", "Intercept suicide commands attempted by zombies."); g_hCvarsList[CVAR_DAMAGE_SUICIDE_ZOMBIE] = CreateConVar("zr_damage_suicide_zombie", "0", "Intercept suicide commands attempted by zombies.");
g_hCvarsList[CVAR_DAMAGE_SUICIDE_HUMAN] = CreateConVar("zr_damage_suicide_human", "1", "Intercept suicide commands attempted by humans."); g_hCvarsList[CVAR_DAMAGE_SUICIDE_MZOMBIE] = CreateConVar("zr_damage_suicide_mzombie", "1", "Intercept suicide commands attempted by mother zombies.");
g_hCvarsList[CVAR_DAMAGE_SUICIDE_HUMAN] = CreateConVar("zr_damage_suicide_human", "0", "Intercept suicide commands attempted by humans.");
g_hCvarsList[CVAR_DAMAGE_SUICIDE_CMDS] = CreateConVar("zr_damage_suicide_cmds", "kill, spectate, jointeam", "List of client commands to intercept as suicide attempts. [Delimiter: \", \"]"); g_hCvarsList[CVAR_DAMAGE_SUICIDE_CMDS] = CreateConVar("zr_damage_suicide_cmds", "kill, spectate, jointeam", "List of client commands to intercept as suicide attempts. [Delimiter: \", \"]");

View File

@ -48,6 +48,11 @@ new g_iDamageTraceAttackHookID[MAXPLAYERS + 1] = {-1, ...};
*/ */
new g_iDamageOnTakeDamageHookID[MAXPLAYERS + 1] = {-1, ...}; new g_iDamageOnTakeDamageHookID[MAXPLAYERS + 1] = {-1, ...};
/**
* Array to keep track of normal/mother zombies.
*/
new bool:g_bDamageMotherZombie[MAXPLAYERS + 1];
/** /**
* Hook commands related to damage here. * Hook commands related to damage here.
*/ */
@ -106,6 +111,18 @@ DamageOnClientDisconnect(client)
} }
} }
/**
* A client was infected.
*
* @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;
}
/** /**
* Hook: TraceAttack * Hook: TraceAttack
* Called right before the bullet enters a client. * Called right before the bullet enters a client.
@ -317,18 +334,29 @@ public Action:DamageSuicideIntercept(client, argc)
return Plugin_Continue; return Plugin_Continue;
} }
// Get zombie flag on client.
new bool:clientzombie = InfectIsClientInfected(client);
// Get cvar values for suicide interception. // Get cvar values for suicide interception.
new bool:suicidezombie = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_SUICIDE_ZOMBIE]); 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]); new bool:suicidehuman = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_SUICIDE_HUMAN]);
// Determine whether to block suicide based off of the client's zombie flag and cvar values. // Check if client is a zombie.
new bool:blocksuicide = clientzombie ? suicidezombie : suicidehuman; if (InfectIsClientInfected(client))
{
// If client is a normal zombie, and suicide intercept is disabled for zombies, then let command go.
if (!g_bDamageMotherZombie[client] && !suicidezombie)
{
return Plugin_Continue;
}
// If cvar for this team is disabled, then stop. // If client is a mother zombie, and suicide intercept is disabled for mother zombies, then let command go.
if (!blocksuicide) if (g_bDamageMotherZombie[client] && !suicidezombiemother)
{
return Plugin_Continue;
}
}
// If client is a human, and suicide intercept is disabled for humans, then let command go.
if (InfectIsClientHuman(client) && !suicidehuman)
{ {
return Plugin_Continue; return Plugin_Continue;
} }

View File

@ -669,6 +669,7 @@ InfectHumanToZombie(client, attacker = -1, bool:motherinfect = false, bool:respa
// Forward event to modules. // Forward event to modules.
ClassOnClientInfected(client, motherinfect); ClassOnClientInfected(client, motherinfect);
RoundEndOnClientInfected(); RoundEndOnClientInfected();
DamageOnClientInfected(client, motherinfect);
SEffectsOnClientInfected(client); SEffectsOnClientInfected(client);
ZTeleOnClientInfected(client); ZTeleOnClientInfected(client);
ZHPOnClientInfected(client); ZHPOnClientInfected(client);