diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index e28a292..8eab79e 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -62,7 +62,7 @@ enum CvarsList Handle:CVAR_SUICIDE_WORLD_DAMAGE, Handle:CVAR_SPAWN_MIN, Handle:CVAR_SPAWN_MAX, - Handle:CVAR_CONSECUTIVE_INFECT, + Handle:CVAR_INFECT_CONSECUTIVE_BLOCK, Handle:CVAR_ZMARKET_BUYZONE, Handle:CVAR_ZSPAWN, 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 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 - 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) 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) diff --git a/src/zr/damage.inc b/src/zr/damage.inc index 5c82c24..52dde3a 100644 --- a/src/zr/damage.inc +++ b/src/zr/damage.inc @@ -12,13 +12,11 @@ /** * @section Damage type flags. */ -#define DMG_GENERIC 0 // generic damage was done -#define DMG_BULLET (1 << 1) // shot -#define DMG_SLASH (1 << 2) // cut, clawed, stabbed -#define DMG_BURN (1 << 3) // heat burned -#define DMG_FALL (1 << 5) // fell too far -#define DMG_BLAST (1 << 6) // explosive blast damage -#define DMG_DROWN (1 << 14) // Drowning +#define DMG_FALL (1 << 5) /** Client was damaged by falling. */ +#define DMG_BLAST (1 << 6) /** Client was damaged by explosion. */ +#define DMG_BULLET (1 << 12) /** Client was shot or knifed. */ +#define DMG_HEADSHOT (1 << 30) /** Client was shot in the head. */ + /** * @endsection */ @@ -37,8 +35,8 @@ */ enum DamageHooks { - Hook_TraceAttack, - Hook_OnTakeDamage, + Hook_TraceAttack, /** TraceAttack HookID */ + Hook_OnTakeDamage, /** OnTakeDamage HookID */ } new g_iDamageHooks[MAXPLAYERS + 1][DamageHooks]; @@ -74,8 +72,9 @@ DamageInit() */ DamageClientInit(client) { - g_iDamageHooks[client][Hook_TraceAttack] = Hacks_Hook(client, HACKS_HTYPE_TRACEATTACK, DamageTraceAttack, false); - g_iDamageHooks[client][Hook_OnTakeDamage] = Hacks_Hook(client, HACKS_HTYPE_ONTAKEDAMAGE, DamageOnTakeDamage, false); + // Hook damage callbacks. + 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) { + // Unhook damage callbacks. Hacks_Unhook(g_iDamageHooks[client][Hook_TraceAttack]); Hacks_Unhook(g_iDamageHooks[client][Hook_OnTakeDamage]); } @@ -160,79 +160,76 @@ public DamageOnTakeDamage(client, inflictor, attacker, damage, damagetype, ammot 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 (!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; } + + // 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. diff --git a/src/zr/zombie.inc b/src/zr/zombie.inc index 58ef595..364b38f 100644 --- a/src/zr/zombie.inc +++ b/src/zr/zombie.inc @@ -288,10 +288,10 @@ InfectPlayer(client, attacker = -1, bool:motherinfect = false) // 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. - bMotherInfectImmune[client] = consecutive_infect ? motherinfect : false; + bMotherInfectImmune[client] = infectconsecutiveblock ? motherinfect : false; // Forward event to modules. ClassOnClientInfected(client, motherinfect);