diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index f5432d3..9ddc8cf 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -185,6 +185,9 @@ enum CvarsList Handle:CVAR_ZHP, Handle:CVAR_ZHP_DEFAULT, Handle:CVAR_KNOCKBACK_MAXVEL, + Handle:CVAR_AURA_MZOMBIE, + Handle:CVAR_AURA_MZOMBIE_MULTIPLIER, + Handle:CVAR_AURA_MZOMBIE_RANGE, } /** @@ -525,6 +528,14 @@ CvarsCreate() // =========================== g_hCvarsList[CVAR_KNOCKBACK_MAXVEL] = CreateConVar("zr_knockback_maxvel", "0", "Set maximum velocity zombies can get from knockback ['0' = Off]."); + + // =========================== + // Aura Motherzombie (module) + // =========================== + g_hCvarsList[CVAR_AURA_MZOMBIE] = CreateConVar("zr_aura_mzombie", "1", "Enables an Aura arround motherzombies where other zombies have increased healthregen."); + g_hCvarsList[CVAR_AURA_MZOMBIE_MULTIPLIER] = CreateConVar("zr_aura_mzombie_multiplier", "2", "Multiplier by which the healthregen of zombies affected by Aura should be increased. [Dependency: zr_aura_mzombie]"); + g_hCvarsList[CVAR_AURA_MZOMBIE_RANGE] = CreateConVar("zr_aura_mzombie_range", "150", "Range arround a motherzombie where Aura is active. [Dependency: zr_aura_mzombie]"); + ZTele_OnCvarsCreate(); // Auto-generate config file if it doesn't exist, then execute. diff --git a/src/zr/infect.inc b/src/zr/infect.inc index 83dc761..1bec120 100644 --- a/src/zr/infect.inc +++ b/src/zr/infect.inc @@ -1157,6 +1157,24 @@ bool:InfectIsClientInfected(client) return g_bZombie[client]; } +/** + * Returns if a client is infected and a motherzombie. + * + * @param client The client index. + * @return True if the client has been infected as motherzombie, false otherwise. + */ +bool:InfectIsClientMotherZombie(client) +{ + // If client is invalid, then stop. + if (!ZRIsClientValid(client)) + { + return false; + } + + // Return client's motherzombie flag. + return g_bInfectMotherLast[client]; +} + /** * Returns if a client is a human. * diff --git a/src/zr/playerclasses/healthregen.inc b/src/zr/playerclasses/healthregen.inc index 3bdfa89..777a127 100644 --- a/src/zr/playerclasses/healthregen.inc +++ b/src/zr/playerclasses/healthregen.inc @@ -103,8 +103,14 @@ public Action:ClassHealthRegenTimer(Handle:timer, any:client) // Check if the health is below the limit. if (health < ClientHealthRegenMax[client]) { - // Apply the health regen. - health += ClientHealthRegenAmount[client]; + if (!GetConVarBool(g_hCvarsList[CVAR_AURA_MZOMBIE]) || !IsMotherZombieNearby(client)) + { + health += ClientHealthRegenAmount[client]; //default regen + } + else + { + health += ClientHealthRegenAmount[client] * GetConVarFloat(g_hCvarsList[CVAR_AURA_MZOMBIE_MULTIPLIER]); //increased regen when motherzombies are nearby + } // Clamp the health regen to the limit. if (health > ClientHealthRegenMax[client]) @@ -118,3 +124,26 @@ public Action:ClassHealthRegenTimer(Handle:timer, any:client) return Plugin_Continue; } + +/** + * Returns true if a motherzombie is near the client. + */ +bool:IsMotherZombieNearby(client) +{ + new Float:fVec1[3]; + new Float:fVec2[3]; + GetClientAbsOrigin(client, fVec1); + + for (new i = 0; i < MAXPLAYERS + 1; i++) + { + if (!InfectIsClientMotherZombie(i)) + continue; + + GetClientAbsOrigin(i, fVec2); + + if (GetVectorDistance(fVec1, fVec2, false) <= GetConVarFloat(g_hCvarsList[CVAR_AURA_MZOMBIE_RANGE])) + return true; + } + + return false; +} \ No newline at end of file