Renamed zr_consecutive_infect (fixed value mixup in the code), and fixed damage flags.

This commit is contained in:
Greyscale 2009-04-21 01:45:49 +02:00
parent 7111a8c594
commit 1ec47ef154
3 changed files with 81 additions and 84 deletions

View File

@ -62,7 +62,7 @@ enum CvarsList
Handle:CVAR_SUICIDE_WORLD_DAMAGE, Handle:CVAR_SUICIDE_WORLD_DAMAGE,
Handle:CVAR_SPAWN_MIN, Handle:CVAR_SPAWN_MIN,
Handle:CVAR_SPAWN_MAX, Handle:CVAR_SPAWN_MAX,
Handle:CVAR_CONSECUTIVE_INFECT, Handle:CVAR_INFECT_CONSECUTIVE_BLOCK,
Handle:CVAR_ZMARKET_BUYZONE, Handle:CVAR_ZMARKET_BUYZONE,
Handle:CVAR_ZSPAWN, Handle:CVAR_ZSPAWN,
Handle:CVAR_ZTELE, Handle:CVAR_ZTELE,
@ -302,7 +302,7 @@ CvarsInit()
// Old Desc: Minimum time a player is picked to be zombie after the round starts, in seconds // Old Desc: Minimum time a player is picked to be zombie after the round starts, in seconds
g_hCvarsList[CVAR_SPAWN_MAX] = CreateConVar("zr_spawn_max", "50", ""); g_hCvarsList[CVAR_SPAWN_MAX] = CreateConVar("zr_spawn_max", "50", "");
// Old Desc: Maximum time a player is picked to be zombie after the round starts, in seconds // Old Desc: Maximum time a player is picked to be zombie after the round starts, in seconds
g_hCvarsList[CVAR_CONSECUTIVE_INFECT] = CreateConVar("zr_consecutive_infect", "0", ""); g_hCvarsList[CVAR_INFECT_CONSECUTIVE_BLOCK] = CreateConVar("zr_infect_consecutive_block", "1", "");
// Old Desc: Allow player to be randomly chosen twice in a row to be a mother zombie (0: Disable) // Old Desc: Allow player to be randomly chosen twice in a row to be a mother zombie (0: Disable)
g_hCvarsList[CVAR_ZMARKET_BUYZONE] = CreateConVar("zr_zmarket_buyzone", "1", ""); g_hCvarsList[CVAR_ZMARKET_BUYZONE] = CreateConVar("zr_zmarket_buyzone", "1", "");
// Old Desc: Must be in buyzone to access !zmarket, if Market is installed (0: Can be used anywhere) // Old Desc: Must be in buyzone to access !zmarket, if Market is installed (0: Can be used anywhere)

View File

@ -12,13 +12,11 @@
/** /**
* @section Damage type flags. * @section Damage type flags.
*/ */
#define DMG_GENERIC 0 // generic damage was done #define DMG_FALL (1 << 5) /** Client was damaged by falling. */
#define DMG_BULLET (1 << 1) // shot #define DMG_BLAST (1 << 6) /** Client was damaged by explosion. */
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed #define DMG_BULLET (1 << 12) /** Client was shot or knifed. */
#define DMG_BURN (1 << 3) // heat burned #define DMG_HEADSHOT (1 << 30) /** Client was shot in the head. */
#define DMG_FALL (1 << 5) // fell too far
#define DMG_BLAST (1 << 6) // explosive blast damage
#define DMG_DROWN (1 << 14) // Drowning
/** /**
* @endsection * @endsection
*/ */
@ -37,8 +35,8 @@
*/ */
enum DamageHooks enum DamageHooks
{ {
Hook_TraceAttack, Hook_TraceAttack, /** TraceAttack HookID */
Hook_OnTakeDamage, Hook_OnTakeDamage, /** OnTakeDamage HookID */
} }
new g_iDamageHooks[MAXPLAYERS + 1][DamageHooks]; new g_iDamageHooks[MAXPLAYERS + 1][DamageHooks];
@ -74,8 +72,9 @@ DamageInit()
*/ */
DamageClientInit(client) DamageClientInit(client)
{ {
g_iDamageHooks[client][Hook_TraceAttack] = Hacks_Hook(client, HACKS_HTYPE_TRACEATTACK, DamageTraceAttack, false); // Hook damage callbacks.
g_iDamageHooks[client][Hook_OnTakeDamage] = Hacks_Hook(client, HACKS_HTYPE_ONTAKEDAMAGE, DamageOnTakeDamage, false); g_iDamageHooks[client][Hook_TraceAttack] = Hacks_Hook(client, HACKS_HTYPE_TRACEATTACK, DamageTraceAttack);
g_iDamageHooks[client][Hook_OnTakeDamage] = Hacks_Hook(client, HACKS_HTYPE_ONTAKEDAMAGE, DamageOnTakeDamage);
} }
/** /**
@ -85,6 +84,7 @@ DamageClientInit(client)
*/ */
DamageOnClientDisconnect(client) DamageOnClientDisconnect(client)
{ {
// Unhook damage callbacks.
Hacks_Unhook(g_iDamageHooks[client][Hook_TraceAttack]); Hacks_Unhook(g_iDamageHooks[client][Hook_TraceAttack]);
Hacks_Unhook(g_iDamageHooks[client][Hook_OnTakeDamage]); Hacks_Unhook(g_iDamageHooks[client][Hook_OnTakeDamage]);
} }
@ -160,79 +160,76 @@ public DamageOnTakeDamage(client, inflictor, attacker, damage, damagetype, ammot
return Hacks_Continue; return Hacks_Continue;
} }
switch(damagetype) // Client was damaged by falling.
if (damagetype & DMG_FALL)
{ {
// Client fell too far. // If client isn't a zombie, then allow damage.
case DMG_FALL: if (!IsPlayerZombie(client))
{ {
// If client isn't a zombie, then allow damage.
if (!IsPlayerZombie(client))
{
return Hacks_Continue;
}
// If class has "nofalldamage" disabled, then allow damage.
new bool:blockfalldamage = ClassGetNoFallDamage(client);
if (!blockfalldamage)
{
return Hacks_Continue;
}
// Stop damage.
return 0;
}
// Client is being damaged by a blast.
case DMG_BLAST:
{
// If attacker isn't valid, then allow damage.
if (!ZRIsValidClient(attacker))
{
return Hacks_Continue;
}
// If client is a zombie, then allow damage.
if (IsPlayerZombie(client))
{
return Hacks_Continue;
}
// Stop damage.
return 0;
}
// Client is being shot.
case DMG_BULLET:
{
// If attacker isn't valid, then allow damage.
if (!ZRIsValidClient(attacker))
{
return Hacks_Continue;
}
// Get zombie flag for each client.
new bool:clientzombie = IsPlayerZombie(client);
new bool:attackerzombie = IsPlayerZombie(attacker);
// If client and attacker are on the same team, then let CS:S handle the rest.
if (clientzombie == attackerzombie)
{
return Hacks_Continue;
}
// We know that clientzombie is the opposite of attacker zombie.
// If the client is a zombie, then allow damage.
if (clientzombie)
{
return Hacks_Continue;
}
// Client is about to be infected, re-add HP so they aren't killed by knife.
new health = GetClientHealth(client);
SetEntityHealth(client, health + damage);
// Allow damage.
return Hacks_Continue; return Hacks_Continue;
} }
// If class has "nofalldamage" disabled, then allow damage.
new bool:blockfalldamage = ClassGetNoFallDamage(client);
if (!blockfalldamage)
{
return Hacks_Continue;
}
// Stop damage.
return 0;
}
// Client was damaged by explosion.
else if (damagetype & DMG_BLAST)
{
// If attacker isn't valid, then allow damage.
if (!ZRIsValidClient(attacker))
{
return Hacks_Continue;
}
// If client is a zombie, then allow damage.
if (IsPlayerZombie(client))
{
return Hacks_Continue;
}
// Stop damage.
return 0;
}
// Client was shot or knifed.
else if (damagetype & DMG_BULLET)
{
// If attacker isn't valid, then allow damage.
if (!ZRIsValidClient(attacker))
{
return Hacks_Continue;
}
// Get zombie flag for each client.
new bool:clientzombie = IsPlayerZombie(client);
new bool:attackerzombie = IsPlayerZombie(attacker);
// If client and attacker are on the same team, then let CS:S handle the rest.
if (clientzombie == attackerzombie)
{
return Hacks_Continue;
}
// We know that clientzombie is the opposite of attacker zombie.
// If the client is a zombie, then allow damage.
if (clientzombie)
{
return Hacks_Continue;
}
// Client is about to be infected, re-add HP so they aren't killed by knife.
new health = GetClientHealth(client);
SetEntityHealth(client, health + damage);
// Allow damage.
return Hacks_Continue;
} }
// Allow damage. // Allow damage.

View File

@ -288,10 +288,10 @@ InfectPlayer(client, attacker = -1, bool:motherinfect = false)
// Check if consecutive infection protection is enabled. // Check if consecutive infection protection is enabled.
new bool:consecutive_infect = GetConVarBool(g_hCvarsList[CVAR_CONSECUTIVE_INFECT]); new bool:infectconsecutiveblock = GetConVarBool(g_hCvarsList[CVAR_INFECT_CONSECUTIVE_BLOCK]);
// Flag player to be immune from being mother zombie twice, if consecutive infect protection is enabled. // Flag player to be immune from being mother zombie twice, if consecutive infect protection is enabled.
bMotherInfectImmune[client] = consecutive_infect ? motherinfect : false; bMotherInfectImmune[client] = infectconsecutiveblock ? motherinfect : false;
// Forward event to modules. // Forward event to modules.
ClassOnClientInfected(client, motherinfect); ClassOnClientInfected(client, motherinfect);