Esempio n. 1
0
void AvHMovementChamber::EnergyAliensThink()
{
	// Don't teleport until it's "warmed up"
	SetUse(&AvHMovementChamber::TeleportUse);

	// Loop through all players
	CBaseEntity* theBaseEntity = NULL;
	int theNumEntsProcessed = 0;
	
	while(((theBaseEntity = UTIL_FindEntityInSphere(theBaseEntity, this->pev->origin, BALANCE_VAR(kMovementChamberEnergyRange))) != NULL) && (theNumEntsProcessed < BALANCE_VAR(kAlienChamberMaxPlayers)))
	{
		if(theBaseEntity->pev->team == this->pev->team)
		{
			float theEnergizeAmount = BALANCE_VAR(kMovementChamberEnergyAmount);
			AvHBaseBuildable* theBuildable = dynamic_cast<AvHBaseBuildable*>(theBaseEntity);
			AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theBaseEntity);
			if(thePlayer && thePlayer->IsAlive())
			{
				if(thePlayer->Energize(theEnergizeAmount))
				{
					theNumEntsProcessed++;
				}
			}
			// Energize alien buildables
//			else if(theBuildable)
//			{
//				if(theBuildable->Energize(theEnergizeAmount))
//				{
//					theNumEntsProcessed++;
//				}
//			}
		}
	}

	// Play an animation (spin the arms if energizing)
	int theIdle = this->GetIdle2Animation();

	// Play sound
	if(theNumEntsProcessed > 0)
	{
		EMIT_SOUND(this->edict(), CHAN_AUTO, kAlienEnergySound, 1.0f, ATTN_NORM);

		theIdle = this->GetIdle1Animation();
	}

	this->PlayAnimationAtIndex(theIdle);
	
	// Set next think
	this->pev->nextthink = gpGlobals->time + BALANCE_VAR(kMovementChamberThinkInterval);
}
Esempio n. 2
0
void AvHDefenseChamber::RegenAliensThink()
{
	// Loop through all players
	CBaseEntity* theBaseEntity = NULL;
	int theNumEntsHealed = 0;
	
	while(((theBaseEntity = UTIL_FindEntityInSphere(theBaseEntity, this->pev->origin, BALANCE_VAR(kDefensiveChamberHealRange))) != NULL) && (theNumEntsHealed < BALANCE_VAR(kAlienChamberMaxPlayers)))
	{
		if(theBaseEntity->pev->team == this->pev->team)
		{
			AvHBaseBuildable* theBuildable = dynamic_cast<AvHBaseBuildable*>(theBaseEntity);
			AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theBaseEntity);
			float thePercent=BALANCE_VAR(kDefensiveChamberRegenPercent)/100.0f;
			float amount=BALANCE_VAR(kDefensiveChamberRegenAmount) + (theBaseEntity->pev->max_health*thePercent);
			if(thePlayer && thePlayer->IsAlive())
			{
				if(thePlayer->Heal(amount, true, true))
				{
					theNumEntsHealed++;
				}
			}
			else if(theBuildable && theBuildable->GetIsBuilt() && (theBuildable != this))
			{
				if(theBuildable->Regenerate(amount, true, true))
				{
					theNumEntsHealed++;
				}
			}
		}
	}
	
	// Set next think
	this->pev->nextthink = gpGlobals->time + BALANCE_VAR(kDefenseChamberThinkInterval);
	
	// Play a random idle animation
	int theIdle = this->GetIdle1Animation();
	
	if(RANDOM_LONG(0, 1))
	{
		theIdle = this->GetIdle2Animation();
	}
	
	this->PlayAnimationAtIndex(theIdle);
}