//------------------------------------------------------------------------------
// Purpose :
// Input   :
// Output  :
//------------------------------------------------------------------------------
void CBaseHelicopter::UpdatePlayerDopplerShift( )
{
	// -----------------------------
	// make rotor, engine sounds
	// -----------------------------
	if (m_iSoundState == 0)
	{
		// Sound startup.
		InitializeRotorSound();
	}
	else
	{
		CBaseEntity *pPlayer = NULL;

		// UNDONE: this needs to send different sounds to every player for multiplayer.	
		// FIXME: this isn't the correct way to find a player!!!
		pPlayer = gEntList.FindEntityByName( NULL, "!player" );
		if (pPlayer)
		{
			Vector dir;
			VectorSubtract( pPlayer->GetAbsOrigin(), GetAbsOrigin(), dir );
			VectorNormalize(dir);

#if 1
			float velReceiver = DotProduct( pPlayer->GetAbsVelocity(), dir );
			float velTransmitter = -DotProduct( GetAbsVelocity(), dir );
			// speed of sound == 13049in/s
			int iPitch = (int)(100 * ((1 - velReceiver / 13049) / (1 + velTransmitter / 13049)));
#else
			// This is a bogus doppler shift, but I like it better
			float relV = DotProduct( GetAbsVelocity() - pPlayer->GetAbsVelocity(), dir );
			int iPitch = (int)(100 + relV / 50.0);
#endif

			// clamp pitch shifts
			if (iPitch > 250)
			{
				iPitch = 250;
			}
			if (iPitch < 50)
			{
				iPitch = 50;
			}

			UpdateRotorSoundPitch( iPitch );
			// Msg( "Pitch:%d\n", iPitch );
		}
		else
		{
			Msg( "Chopper didn't find a player!\n" );
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void QUA_helicopter::Spawn( void )
{
	m_aimYaw = 0;
	m_aimPitch = 0;
	m_bSuppressSound = false;
	m_flSiguienteAtaque=gpGlobals->curtime;
	m_flSiguienteSummon=gpGlobals->curtime;
	Precache();
	SetModel(HELI_MODEL);
	//SetVehicleType( VEHICLE_TYPE_CAR_RAYCAST );
	BaseClass::Spawn();
	SetCollisionGroup(COLLISION_GROUP_VEHICLE);
	m_flSequenceTime=gpGlobals->curtime+4.0f;
	m_flNextShootingTime=gpGlobals->curtime;
	aux=true;
	m_iAmmoType = GetAmmoDef()->Index("StriderMinigun"); 
	m_bInhelicopter=false;
	m_bhelicopterTurbo=false;

	acl=0;
	aclizq=0;
	aclder=0;
	
	
	//SetBlocksLOS( true );
	SetSolid( SOLID_BBOX );
	AddSolidFlags( FSOLID_NOT_STANDABLE );
	SetMoveType( MOVETYPE_FLY );
	AddSolidFlags( FSOLID_CUSTOMRAYTEST | FSOLID_CUSTOMBOXTEST );
	m_iCaps = FCAP_IMPULSE_USE;
//	SetBloodColor( BLOOD_COLOR_YELLOW );
	UTIL_SetSize(this,Vector(-220,-40,-80),Vector(170, 40, 40));

	//See if we're supposed to start burrowed
	

	// Do not dissolve
	//AddEFlags( EFL_NO_DISSOLVE );

	// We get a minute of free knowledge about the target
	
	// We need to bloat the absbox to encompass all the hitboxes
	/*Vector absMin = -Vector(100,100,0);
	Vector absMax = Vector(100,100,128);

	CollisionProp()->SetSurroundingBoundsType( USE_SPECIFIED_BOUNDS, &absMin, &absMax );
	*/InitializeRotorSound();
	m_iHealth=500;
	// Indispensable para que sea vulnerable
	m_takedamage		= DAMAGE_YES;
	m_iAmmoCount=40;
	m_iCannonCount=100;
	m_fReloadTime=gpGlobals->curtime+0.5f;
	m_fCannonCharge=gpGlobals->curtime+0.05f;
	m_vOriginalSpawnOrigin = GetAbsOrigin();
	m_vOriginalSpawnAngles = GetAbsAngles();
	m_flRespawnTime=gpGlobals->curtime+7.0f;
	m_bSpawn=false;
	SetActivity( ACT_IDLE );
	SetThink(&QUA_helicopter::Think);
	SetNextThink(gpGlobals->curtime);
	Vector maxcull,mincull;
	ExtractBbox(SelectHeaviestSequence(ACT_IDLE),maxcull,mincull);
	//CollisionProp()->SetSurroundingBoundsType( USE_BEST_COLLISION_BOUNDS );
}