Esempio n. 1
0
bool AvHTurret::GetIsValidTarget(CBaseEntity* inEntity) const
{
	bool theTargetIsValid = false;
	
	if((inEntity->pev->team != this->pev->team) && (inEntity->pev->team != 0) && (inEntity->pev->takedamage))
	{
		float theDistanceToCurrentEnemy = AvHSUEyeToBodyXYDistance(this->pev, inEntity);
		if(theDistanceToCurrentEnemy <= this->GetXYRange())
		{
			// Players are targettable when 
			AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(inEntity);
			if(!thePlayer || !thePlayer->GetIsCloaked() || !thePlayer->GetIsBeingDigested()) //added digestion - elven
			{
				// TODO: Check to be sure enemy is still visible
				theTargetIsValid = true;
			}
			else
			{
				AvHCloakable* theCloakable = dynamic_cast<AvHCloakable*>(inEntity);
				if(!theCloakable || (theCloakable->GetOpacity() > 0.0f))
				{
					theTargetIsValid = true;
				}
			}
		}
	}

	return theTargetIsValid;
}
Esempio n. 2
0
void AvHGamerules::AwardExperience(AvHPlayer* inPlayer, int inTargetLevel, bool inAwardFriendliesInRange)
{
	PlayerListType thePlayerList;
	thePlayerList.push_back(inPlayer);

	if(inAwardFriendliesInRange)
	{
		// Award experience to player, and any other players nearby
		int theExperienceRadius = BALANCE_IVAR(kCombatFriendlyNearbyRange);

		// Make list of players to split it between.  If a player is at full experience, extra is wasted.
		CBaseEntity* theEntity = NULL;
		while ((theEntity = UTIL_FindEntityInSphere(theEntity, inPlayer->pev->origin, theExperienceRadius)) != NULL)
		{
			const char* theClassName = STRING(theEntity->pev->classname);
			if(!AvHSUGetIsExternalClassName(theClassName))
			{
				AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theEntity);
				if(thePlayer && (thePlayer != inPlayer) && (thePlayer->pev->team == inPlayer->pev->team) && thePlayer->GetIsRelevant() && !thePlayer->GetIsBeingDigested())
				{
					thePlayerList.push_back(thePlayer);
				}
			}
		}
	}
	
	ASSERT(thePlayerList.size() > 0);

	float theExperienceFactor = GetGameRules()->GetIsIronMan() ? BALANCE_FVAR(kCombatIronManExperienceScalar) : 1.0f;

	int theExperienceToAward = BALANCE_IVAR(kCombatExperienceBaseAward) + inTargetLevel*BALANCE_IVAR(kCombatExperienceLevelAward);

	float theExperienceForEach = (theExperienceToAward/(float)thePlayerList.size() + BALANCE_IVAR(kCombatExperienceCrowdAward))*theExperienceFactor;

	for(PlayerListType::iterator thePlayerIter = thePlayerList.begin(); thePlayerIter != thePlayerList.end(); thePlayerIter++)
	{
		AvHPlayer* theCurrentPlayer = (*thePlayerIter);
		theCurrentPlayer->SetExperience(theCurrentPlayer->GetExperience() + theExperienceForEach);
	}
}
Esempio n. 3
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 );
	}
}