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,10 +160,8 @@ 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.
case DMG_FALL:
{ {
// If client isn't a zombie, then allow damage. // If client isn't a zombie, then allow damage.
if (!IsPlayerZombie(client)) if (!IsPlayerZombie(client))
@ -181,8 +179,8 @@ public DamageOnTakeDamage(client, inflictor, attacker, damage, damagetype, ammot
// Stop damage. // Stop damage.
return 0; return 0;
} }
// Client is being damaged by a blast. // Client was damaged by explosion.
case DMG_BLAST: else if (damagetype & DMG_BLAST)
{ {
// If attacker isn't valid, then allow damage. // If attacker isn't valid, then allow damage.
if (!ZRIsValidClient(attacker)) if (!ZRIsValidClient(attacker))
@ -199,8 +197,8 @@ public DamageOnTakeDamage(client, inflictor, attacker, damage, damagetype, ammot
// Stop damage. // Stop damage.
return 0; return 0;
} }
// Client is being shot. // Client was shot or knifed.
case DMG_BULLET: else if (damagetype & DMG_BULLET)
{ {
// If attacker isn't valid, then allow damage. // If attacker isn't valid, then allow damage.
if (!ZRIsValidClient(attacker)) if (!ZRIsValidClient(attacker))
@ -233,7 +231,6 @@ public DamageOnTakeDamage(client, inflictor, attacker, damage, damagetype, ammot
// Allow damage. // Allow damage.
return Hacks_Continue; return Hacks_Continue;
} }
}
// Allow damage. // Allow damage.
return Hacks_Continue; return Hacks_Continue;

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);