Fixed death given to the mother zombies, created cvars to control friendlyfire and blast damage, hitgroup file now allows you to disable shootable hitgroups on zombies.

This commit is contained in:
Greyscale 2009-04-23 06:39:11 +02:00
parent b99d253477
commit 2718b527ac
7 changed files with 204 additions and 103 deletions

View File

@ -5,7 +5,8 @@
// "hitgroup index" // Index of the hitgroup (listed below) // "hitgroup index" // Index of the hitgroup (listed below)
// { // {
// "name" "name of hitgroup" // Redundant as of now, used for readability. // "name" "name of hitgroup" // Redundant as of now, used for readability.
// "knockback" "1.0" (default) // The knockback multiplier for the hitgroup // "knockback" "1.0" (default) // The knockback multiplier for the hitgroup.
// "damage" "yes" (default // Toggle damage on and off for this hitgroup.
// } // }
// //
// Notes: // Notes:
@ -18,53 +19,62 @@
{ {
"name" "Generic" "name" "Generic"
"knockback" "1.0" "knockback" "1.0"
"damage" "yes"
} }
"1" "1"
{ {
"name" "Head" "name" "Head"
"knockback" "2.0" "knockback" "2.0"
"damage" "no"
} }
"2" "2"
{ {
"name" "Chest" "name" "Chest"
"knockback" "1.3" "knockback" "1.3"
"damage" "yes"
} }
"3" "3"
{ {
"name" "Stomach" "name" "Stomach"
"knockback" "1.2" "knockback" "1.2"
"damage" "yes"
} }
"4" "4"
{ {
"name" "Left Arm" "name" "Left Arm"
"knockback" "1.0" "knockback" "1.0"
"damage" "no"
} }
"5" "5"
{ {
"name" "Right Arm" "name" "Right Arm"
"knockback" "1.0" "knockback" "1.0"
"damage" "yes"
} }
"6" "6"
{ {
"name" "Left Leg" "name" "Left Leg"
"knockback" "0.9" "knockback" "0.9"
"damage" "no"
} }
"7" "7"
{ {
"name" "Right Leg" "name" "Right Leg"
"knockback" "0.9" "knockback" "0.9"
"damage" "yes"
} }
"10" "10"
{ {
"name" "Gear" "name" "Gear"
"knockback" "1.0" "knockback" "1.0"
"damage" "yes"
} }
} }

View File

@ -44,6 +44,9 @@
// Weapons (core) // Weapons (core)
#include "zr/weapons/weapons" #include "zr/weapons/weapons"
// Hitgroups (core)
#include "zr/hitgroups"
// Round End (core) // Round End (core)
#include "zr/roundend" #include "zr/roundend"
@ -53,9 +56,6 @@
// Damage (core) // Damage (core)
#include "zr/damage" #include "zr/damage"
// Hitgroups (core)
#include "zr/hitgroups"
// Account (module) // Account (module)
#include "zr/account" #include "zr/account"
@ -173,10 +173,8 @@ public OnMapStart()
// Forward event to modules. // Forward event to modules.
ClassLoad(); ClassLoad();
WeaponsLoad();
RoundEndOnMapStart(); RoundEndOnMapStart();
InfectOnMapStart(); InfectOnMapStart();
HitgroupsLoad();
SEffectsOnMapStart(); SEffectsOnMapStart();
AntiStickOnMapStart(); AntiStickOnMapStart();
Anticamp_Startup(); Anticamp_Startup();
@ -211,6 +209,9 @@ public OnConfigsExecuted()
FindMapSky(); FindMapSky();
// Forward event to modules. // Forward event to modules.
WeaponsLoad();
HitgroupsLoad();
InfectLoad();
SEffectsLoad(); SEffectsLoad();
} }

View File

@ -17,18 +17,25 @@ enum CvarsList
Handle:CVAR_ENABLE, Handle:CVAR_ENABLE,
Handle:CVAR_LOG, Handle:CVAR_LOG,
Handle:CVAR_LOGFLAGS, Handle:CVAR_LOGFLAGS,
Handle:CVAR_ROUNDEND_OVERLAY,
Handle:CVAR_ROUNDEND_OVERLAY_ZOMBIE,
Handle:CVAR_ROUNDEND_OVERLAY_HUMAN,
Handle:CVAR_CLASSES_SPAWN, Handle:CVAR_CLASSES_SPAWN,
Handle:CVAR_CLASSES_RANDOM, Handle:CVAR_CLASSES_RANDOM,
Handle:CVAR_CLASSES_DEFAULT_ZOMBIE, Handle:CVAR_CLASSES_DEFAULT_ZOMBIE,
Handle:CVAR_CLASSES_DEFAULT_HUMAN, Handle:CVAR_CLASSES_DEFAULT_HUMAN,
Handle:CVAR_CLASSES_DEFAULT_ADMIN, Handle:CVAR_CLASSES_DEFAULT_ADMIN,
Handle:CVAR_CLASSES_FILE, Handle:CVAR_CLASSES_FILE,
Handle:CVAR_WEAPONS,
Handle:CVAR_WEAPONS_RESTRICT,
Handle:CVAR_WEAPONS_ZMARKET_BUYZONE,
Handle:CVAR_HITGROUPS,
Handle:CVAR_DAMAGE_HITGROUPS,
Handle:CVAR_DAMAGE_BLOCK_FF,
Handle:CVAR_DAMAGE_BLOCK_BLAST,
Handle:CVAR_DAMAGE_SUICIDE_ZOMBIE, Handle:CVAR_DAMAGE_SUICIDE_ZOMBIE,
Handle:CVAR_DAMAGE_SUICIDE_HUMAN, Handle:CVAR_DAMAGE_SUICIDE_HUMAN,
Handle:CVAR_DAMAGE_SUICIDE_CMDS, Handle:CVAR_DAMAGE_SUICIDE_CMDS,
Handle:CVAR_ROUNDEND_OVERLAY,
Handle:CVAR_ROUNDEND_OVERLAY_ZOMBIE,
Handle:CVAR_ROUNDEND_OVERLAY_HUMAN,
Handle:CVAR_INFECT_SPAWNTIME_MIN, Handle:CVAR_INFECT_SPAWNTIME_MIN,
Handle:CVAR_INFECT_SPAWNTIME_MAX, Handle:CVAR_INFECT_SPAWNTIME_MAX,
Handle:CVAR_INFECT_CONSECUTIVE_BLOCK, Handle:CVAR_INFECT_CONSECUTIVE_BLOCK,
@ -43,10 +50,6 @@ enum CvarsList
Handle:CVAR_INFECT_SHAKE_AMP, Handle:CVAR_INFECT_SHAKE_AMP,
Handle:CVAR_INFECT_SHAKE_FREQUENCY, Handle:CVAR_INFECT_SHAKE_FREQUENCY,
Handle:CVAR_INFECT_SHAKE_DURATION, Handle:CVAR_INFECT_SHAKE_DURATION,
Handle:CVAR_WEAPONS,
Handle:CVAR_WEAPONS_RESTRICT,
Handle:CVAR_WEAPONS_ZMARKET_BUYZONE,
Handle:CVAR_HITGROUPS,
Handle:CVAR_ACCOUNT_CASHFILL, Handle:CVAR_ACCOUNT_CASHFILL,
Handle:CVAR_ACCOUNT_CASHFILL_VALUE, Handle:CVAR_ACCOUNT_CASHFILL_VALUE,
Handle:CVAR_SOUNDEFFECTS_MOAN, Handle:CVAR_SOUNDEFFECTS_MOAN,
@ -132,17 +135,6 @@ CvarsInit()
// (None) // (None)
// ===========================
// Round End (core)
// ===========================
g_hCvarsList[CVAR_ROUNDEND_OVERLAY] = CreateConVar("zr_roundend_overlay", "1", "");
// Old Desc: Shows an overlay to all clients when a team wins. (0: Disable)
g_hCvarsList[CVAR_ROUNDEND_OVERLAY_HUMAN] = CreateConVar("zr_roundend_overlays_human", "");
// Old Desc: overlays/zr/humans_win", "Path to \"humans win\" overlay
g_hCvarsList[CVAR_ROUNDEND_OVERLAY_ZOMBIE] = CreateConVar("zr_roundend_overlays_zombie", "overlays/zr/zombies_win", "");
// Old Desc: Path to \"zombies win\" overlay
// =========================== // ===========================
// Offsets (core) // Offsets (core)
// =========================== // ===========================
@ -172,39 +164,6 @@ CvarsInit()
g_hCvarsList[CVAR_CLASSES_FILE] = CreateConVar("zr_classes_file", "configs/zr/playerclasses.txt", ""); g_hCvarsList[CVAR_CLASSES_FILE] = CreateConVar("zr_classes_file", "configs/zr/playerclasses.txt", "");
// Old Desc: Class data file to read from, in Valves key/values format. The path is relative to the \"sourcemod\" folder. // Old Desc: Class data file to read from, in Valves key/values format. The path is relative to the \"sourcemod\" folder.
// ===========================
// Damage (core)
// ===========================
g_hCvarsList[CVAR_DAMAGE_SUICIDE_ZOMBIE] = CreateConVar("zr_damage_suicide_zombie", "1", "");
// Old Desc: Intercept human suicide attempts.
g_hCvarsList[CVAR_DAMAGE_SUICIDE_HUMAN] = CreateConVar("zr_damage_suicide_human", "1", "");
// Old Desc: Intercept zombie suicide attempts.
g_hCvarsList[CVAR_DAMAGE_SUICIDE_CMDS] = CreateConVar("zr_damage_suicide_cmds", "kill, spectate, jointeam", "");
// Old Desc: List of suicide commands to intercept. (Delimited by \", \"
// ===========================
// Infect (core)
// ===========================
g_hCvarsList[CVAR_INFECT_MZOMBIE_RATIO] = CreateConVar("zr_infect_motherzombie_ratio", "5", "");
g_hCvarsList[CVAR_INFECT_MZOMBIE_RESPAWN] = CreateConVar("zr_infect_motherzombie_respawn", "0", "");
g_hCvarsList[CVAR_INFECT_SPAWNTIME_MIN] = CreateConVar("zr_infect_spawntime_min", "30.0", "");
g_hCvarsList[CVAR_INFECT_SPAWNTIME_MAX] = CreateConVar("zr_infect_spawntime_max", "50.0", "");
g_hCvarsList[CVAR_INFECT_CONSECUTIVE_BLOCK] = CreateConVar("zr_infect_consecutive_block", "1", "");
// Effects
g_hCvarsList[CVAR_INFECT_FIREBALL] = CreateConVar("zr_infect_fireball", "1", "");
g_hCvarsList[CVAR_INFECT_SMOKE] = CreateConVar("zr_infect_smoke", "1", "");
g_hCvarsList[CVAR_INFECT_SPARKS] = CreateConVar("zr_infect_sparks", "1", "");
g_hCvarsList[CVAR_INFECT_SOUND] = CreateConVar("zr_infect_sound", "npc/fast_zombie/fz_scream1.wav", "");
g_hCvarsList[CVAR_INFECT_ESPLASH] = CreateConVar("zr_infect_esplash", "1", "");
g_hCvarsList[CVAR_INFECT_SHAKE] = CreateConVar("zr_infect_shake", "1", "");
g_hCvarsList[CVAR_INFECT_SHAKE_AMP] = CreateConVar("zr_infect_shake_amp", "15.0", "");
g_hCvarsList[CVAR_INFECT_SHAKE_FREQUENCY] = CreateConVar("zr_infect_shake_frequency", "1.0", "");
g_hCvarsList[CVAR_INFECT_SHAKE_DURATION] = CreateConVar("zr_infect_shake_duration", "5.0", "");
// =========================== // ===========================
// Weapons (core) // Weapons (core)
// =========================== // ===========================
@ -232,6 +191,62 @@ CvarsInit()
g_hCvarsList[CVAR_HITGROUPS] = CreateConVar("zr_hitgroups", "1", ""); g_hCvarsList[CVAR_HITGROUPS] = CreateConVar("zr_hitgroups", "1", "");
// Note make config file cvar. // Note make config file cvar.
// ===========================
// Round End (core)
// ===========================
g_hCvarsList[CVAR_ROUNDEND_OVERLAY] = CreateConVar("zr_roundend_overlay", "1", "");
// Old Desc: Shows an overlay to all clients when a team wins. (0: Disable)
g_hCvarsList[CVAR_ROUNDEND_OVERLAY_HUMAN] = CreateConVar("zr_roundend_overlays_human", "");
// Old Desc: overlays/zr/humans_win", "Path to \"humans win\" overlay
g_hCvarsList[CVAR_ROUNDEND_OVERLAY_ZOMBIE] = CreateConVar("zr_roundend_overlays_zombie", "overlays/zr/zombies_win", "");
// Old Desc: Path to \"zombies win\" overlay
// ===========================
// Infect (core)
// ===========================
g_hCvarsList[CVAR_INFECT_MZOMBIE_RATIO] = CreateConVar("zr_infect_motherzombie_ratio", "5", "");
g_hCvarsList[CVAR_INFECT_MZOMBIE_RESPAWN] = CreateConVar("zr_infect_motherzombie_respawn", "0", "");
g_hCvarsList[CVAR_INFECT_SPAWNTIME_MIN] = CreateConVar("zr_infect_spawntime_min", "30.0", "");
g_hCvarsList[CVAR_INFECT_SPAWNTIME_MAX] = CreateConVar("zr_infect_spawntime_max", "50.0", "");
g_hCvarsList[CVAR_INFECT_CONSECUTIVE_BLOCK] = CreateConVar("zr_infect_consecutive_block", "1", "");
// Effects
g_hCvarsList[CVAR_INFECT_FIREBALL] = CreateConVar("zr_infect_fireball", "1", "");
g_hCvarsList[CVAR_INFECT_SMOKE] = CreateConVar("zr_infect_smoke", "1", "");
g_hCvarsList[CVAR_INFECT_SPARKS] = CreateConVar("zr_infect_sparks", "1", "");
g_hCvarsList[CVAR_INFECT_SOUND] = CreateConVar("zr_infect_sound", "npc/fast_zombie/fz_scream1.wav", "");
g_hCvarsList[CVAR_INFECT_ESPLASH] = CreateConVar("zr_infect_esplash", "1", "");
g_hCvarsList[CVAR_INFECT_SHAKE] = CreateConVar("zr_infect_shake", "1", "");
g_hCvarsList[CVAR_INFECT_SHAKE_AMP] = CreateConVar("zr_infect_shake_amp", "15.0", "");
g_hCvarsList[CVAR_INFECT_SHAKE_FREQUENCY] = CreateConVar("zr_infect_shake_frequency", "1.0", "");
g_hCvarsList[CVAR_INFECT_SHAKE_DURATION] = CreateConVar("zr_infect_shake_duration", "5.0", "");
// ===========================
// Damage (core)
// ===========================
// Hitgroup Damage
g_hCvarsList[CVAR_DAMAGE_HITGROUPS] = CreateConVar("zr_damage_hitgroups", "1", "");
// Block Damage Types
g_hCvarsList[CVAR_DAMAGE_BLOCK_FF] = CreateConVar("zr_damage_block_ff", "1", "");
// note overrides mp_friendlyfire
g_hCvarsList[CVAR_DAMAGE_BLOCK_BLAST] = CreateConVar("zr_damage_block_blast", "1", "");
// Suicide Intercept
g_hCvarsList[CVAR_DAMAGE_SUICIDE_ZOMBIE] = CreateConVar("zr_damage_suicide_zombie", "1", "");
// Old Desc: Intercept human suicide attempts.
g_hCvarsList[CVAR_DAMAGE_SUICIDE_HUMAN] = CreateConVar("zr_damage_suicide_human", "1", "");
// Old Desc: Intercept zombie suicide attempts.
g_hCvarsList[CVAR_DAMAGE_SUICIDE_CMDS] = CreateConVar("zr_damage_suicide_cmds", "kill, spectate, jointeam", "");
// Old Desc: List of suicide commands to intercept. (Delimited by \", \"
// =========================== // ===========================
// Account (module) // Account (module)
// =========================== // ===========================

View File

@ -120,10 +120,36 @@ public DamageTraceAttack(client, inflictor, attacker, damage, hitbox, hitgroup)
// If the flags are the same on both clients, then stop. // If the flags are the same on both clients, then stop.
if (clientzombie == attackerzombie) if (clientzombie == attackerzombie)
{ {
// If friendly fire is blocked, then allow damage.
new bool:damageblockff = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_BLOCK_FF]);
if (!damageblockff)
{
return Hacks_Continue;
}
// Stop bullet from hurting client.
return 0; return 0;
} }
// Players are on differen't teams. // Here we know that attacker and client are different teams.
// If damage hitgroups cvar is disabled, then allow damage.
new bool:damagehitgroups = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_HITGROUPS]);
if (!damagehitgroups)
{
// Allow damage.
return Hacks_Continue;
}
// If damage is disabled for this hitgroup, then stop.
new bool:candamage = HitgroupsCanDamageHitgroup(hitgroup);
if (!candamage)
{
// Stop bullet from hurting client.
return 0;
}
// Allow damage.
return Hacks_Continue; return Hacks_Continue;
} }
@ -160,45 +186,8 @@ public DamageOnTakeDamage(client, inflictor, attacker, damage, damagetype, ammot
return Hacks_Continue; return Hacks_Continue;
} }
// Client was damaged by falling.
if (damagetype & DMG_FALL)
{
// 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 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. // Client was shot or knifed.
else if (damagetype & DMG_BULLET) 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))
@ -231,6 +220,50 @@ public DamageOnTakeDamage(client, inflictor, attacker, damage, damagetype, ammot
// Allow damage. // Allow damage.
return Hacks_Continue; return Hacks_Continue;
} }
// Client was damaged by explosion.
else if (damagetype & DMG_BLAST)
{
// If blast damage is blocked, then stop.
new bool:damageblockblast = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_BLOCK_BLAST]);
if (!damageblockblast)
{
return Hacks_Continue;
}
// 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 damaged by falling.
else if (damagetype & DMG_FALL)
{
// 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;
}
// Allow damage. // Allow damage.
return Hacks_Continue; return Hacks_Continue;

View File

@ -99,6 +99,7 @@ HitgroupsValidateConfig()
* Retrieve hitgroup knockback value. * Retrieve hitgroup knockback value.
* *
* @param hitgroup The hitgroup index. * @param hitgroup The hitgroup index.
* @return The knockback multiplier of the hitgroup.
*/ */
Float:HitgroupsGetHitgroupKnockback(hitgroup) Float:HitgroupsGetHitgroupKnockback(hitgroup)
{ {
@ -122,3 +123,38 @@ Float:HitgroupsGetHitgroupKnockback(hitgroup)
return 1.0; return 1.0;
} }
/**
* Retrieve hitgroup damage value.
*
* @param hitgroup The hitgroup index.
* @return True if hitgroup can be damaged, false if not.
*/
bool:HitgroupsCanDamageHitgroup(hitgroup)
{
// Reset keyvalue's traversal stack.
KvRewind(kvHitgroups);
if (KvGotoFirstSubKey(kvHitgroups))
{
decl String:sHitgroup[4];
decl String:damage[8];
do
{
KvGetSectionName(kvHitgroups, sHitgroup, sizeof(sHitgroup));
// If this is the right hitgroup, then return knockback for it.
if (hitgroup == StringToInt(sHitgroup))
{
// Get config setting string.
KvGetString(kvHitgroups, "damage", damage, sizeof(damage), "yes");
// Return hitgroup's damage setting.
return ZRConfigSettingToBool(damage);
}
} while (KvGotoNextKey(kvHitgroups));
}
// If hitgroup is missing, then default to "yes."
return true;
}

View File

@ -60,7 +60,13 @@ InfectOnMapStart()
{ {
// Reset timer handle. // Reset timer handle.
tInfect = INVALID_HANDLE; tInfect = INVALID_HANDLE;
}
/**
* Loads downloadable content data for infect module.
*/
InfectLoad()
{
// Get infection sound. // Get infection sound.
decl String:sound[PLATFORM_MAX_PATH]; decl String:sound[PLATFORM_MAX_PATH];
GetConVarString(g_hCvarsList[CVAR_INFECT_SOUND], sound, sizeof(sound)); GetConVarString(g_hCvarsList[CVAR_INFECT_SOUND], sound, sizeof(sound));
@ -517,10 +523,7 @@ InfectPlayer(client, attacker = -1, bool:motherinfect = false)
// Apply effects. // Apply effects.
InfectEffects(client); InfectEffects(client);
// Add a death to the zombie's score. // If attacker is valid, then continue.
AddPlayerDeath(client, 1);
// Fire death event and set weapon info if the attacker is specified.
if (ZRIsValidClient(attacker)) if (ZRIsValidClient(attacker))
{ {
// Create and send custom player_death event. // Create and send custom player_death event.
@ -536,6 +539,9 @@ InfectPlayer(client, attacker = -1, bool:motherinfect = false)
// Give client's infector a point. // Give client's infector a point.
AddPlayerScore(attacker, 1); AddPlayerScore(attacker, 1);
// Add a death to the zombie's score.
AddPlayerDeath(client, 1);
// Apply infect HP gain. // Apply infect HP gain.
new healthgain = ClassGetHealthInfectGain(attacker); new healthgain = ClassGetHealthInfectGain(attacker);
new health = GetClientHealth(attacker); new health = GetClientHealth(attacker);