add Aura for motherzombies where all zombies have increased health regen
This commit is contained in:
parent
db60e23e3a
commit
2f9bd13cb1
@ -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.
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user