From fd8893ae6c2f4dff8bbf3560a10afe08ed868ceb Mon Sep 17 00:00:00 2001 From: zaCade Date: Thu, 22 Feb 2018 15:32:17 +0100 Subject: [PATCH] GENERAL: Allow napalm scaling, depending on damage. --- src/zr/cvars.inc | 2 ++ src/zr/event.inc | 2 +- src/zr/napalm.inc | 20 +++++++++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index 758feda..700c104 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -165,6 +165,7 @@ enum CvarsList Handle:CVAR_RESPAWN_TEAM_ZOMBIE_WORLD, Handle:CVAR_NAPALM_IGNITE, Handle:CVAR_NAPALM_TIME_RESET, + Handle:CVAR_NAPALM_TIME_SCALE, Handle:CVAR_NAPALM_DOUSE, Handle:CVAR_JUMPBOOST_BHOP_PROTECT, Handle:CVAR_JUMPBOOST_BHOP_MAX, @@ -472,6 +473,7 @@ CvarsCreate() // =========================== g_hCvarsList[CVAR_NAPALM_IGNITE] = CreateConVar("zr_napalm_ignite", "1", "Ignite grenade in mid-air after player throws it. [Dependency: Human Attribute 'has_napalm']"); g_hCvarsList[CVAR_NAPALM_TIME_RESET] = CreateConVar("zr_napalm_time_reset", "1", "The burn-time is reset when being naded multiple times. [0: Original burn-time is used.]"); + g_hCvarsList[CVAR_NAPALM_TIME_SCALE] = CreateConVar("zr_napalm_time_scale", "75", "The amount of damage that's needed to apply full burn duration."); g_hCvarsList[CVAR_NAPALM_DOUSE] = CreateConVar("zr_napalm_douse", "0", "Minimum water-saturation before flame is extinguished. ['0' = Disabled | '1' = Feet | '2' = Waist | '3' = Full submersion]"); diff --git a/src/zr/event.inc b/src/zr/event.inc index f567ed1..5216180 100644 --- a/src/zr/event.inc +++ b/src/zr/event.inc @@ -229,7 +229,7 @@ public Action:EventPlayerHurt(Handle:event, const String:name[], bool:dontBroadc AccountOnClientHurt(index, attacker, dmg_health); SEffectsOnClientHurt(index); KnockbackOnClientHurt(index, attacker, weapon, hitgroup, dmg_health); - NapalmOnClientHurt(index, attacker, weapon); + NapalmOnClientHurt(index, attacker, weapon, dmg_health); ZHPOnClientHurt(index); } diff --git a/src/zr/napalm.inc b/src/zr/napalm.inc index 7180197..74f3c46 100644 --- a/src/zr/napalm.inc +++ b/src/zr/napalm.inc @@ -102,7 +102,7 @@ NapalmOnTakeDamage(client, damagetype) * @param attacker The attacker index. * @param weapon The weapon name. */ -NapalmOnClientHurt(client, attacker, const String:weapon[]) +NapalmOnClientHurt(client, attacker, const String:weapon[], dmg_health) { // If there's no attacker, then stop. if (!attacker) @@ -137,6 +137,24 @@ NapalmOnClientHurt(client, attacker, const String:weapon[]) if (reset || !(flags & FL_ONFIRE)) { + new Float:timescale = GetConVarFloat(g_hCvarsList[CVAR_NAPALM_TIME_SCALE]) + if (timescale > 0.0) + { + // Figure out our scale value. + timescale = dmg_health / timescale; + + // Make sure we dont go over 100%. + if (timescale > 1.0) + timescale = 1.0; + + // Make sure we dont go below 0%. + if (timescale < 0.0) + timescale = 0.0; + + // Scale our class time, accordingly. + napalm_time = napalm_time * timescale; + } + // Ignite the client or extend the current flames life. NapalmIgniteEntity(client, napalm_time); }