If I had pasted the exact code I used, it would have confused you more
See, you don't need that giant if block. As the code tells the servo to move closer and closer to the center of the target, the value of PAN_SERVO decreases more and more, until it reaches 127. So if you left it alone, it would slow down as it reached the center for you.
Depending on your turret design, the code that I gave would have turned back and forth over and over trying to line itself up correctly. It may have worked how it was, it depends on your robot design.
The tilt code is going to be very, very similar to the pan code.
You may need to add some limit switches, mechanical stops, or both to prevent the turret from spinning too far.