Esempio n. 1
0
void AvHHive::ProcessHealing()
{
	// Regenerate nearby friendly aliens
	CBaseEntity* theEntity = NULL;
	const int theHiveHealRadius = BALANCE_VAR(kHiveHealRadius);

	while((theEntity = UTIL_FindEntityInSphere(theEntity, this->pev->origin, theHiveHealRadius)) != NULL)
	{
		AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theEntity);
		if(thePlayer)
		{
			if(thePlayer->GetIsRelevant() && (thePlayer->GetTeam() == this->GetTeamNumber()) && !thePlayer->GetIsBeingDigested())
			{
                // Hive heals percentage of player health
                float theRegenPercentage = BALANCE_VAR(kHiveRegenerationPercentage);
                int theMaxHealth = AvHPlayerUpgrade::GetMaxHealth(thePlayer->pev->iuser4, (AvHUser3)thePlayer->pev->iuser3, thePlayer->GetExperienceLevel());
                float theRegenAmount = (theRegenPercentage*theMaxHealth);
                thePlayer->Heal(theRegenAmount, true);
			}
		}
	}
	
	// Regenerate self
	bool theDidHeal = false;
	
	// If we aren't at full health, heal health
	if(this->pev->health < this->mMaxHitPoints)
	{
        float theHiveRegenAmount = BALANCE_VAR(kHiveRegenerationAmount);
        float theCombatModeScalar = /*GetGameRules()->GetIsCombatMode() ? (1.0f/BALANCE_VAR(kCombatModeTimeScalar)) :*/ 1.0f;

		this->pev->health = min((float)this->mMaxHitPoints, this->pev->health + theHiveRegenAmount*theCombatModeScalar);
		theDidHeal = true;
	}
	
	// Play regen event
	if(theDidHeal)
	{
		// Play regeneration event
		PLAYBACK_EVENT_FULL(0, this->edict(), gRegenerationEventID, 0, this->pev->origin, (float *)&g_vecZero, 1.0f, 0.0, /*theWeaponIndex*/ 0, 0, 0, 0 );
	}
}