The Battle Frontier is a feature (usually only accessible after defeating the Elite Four) that lets players battle powerful trainers. There are many different facilities within the Battle Frontier, which include the Battle Tower and Battle Factory.
The events and scripts for the Battle Tower are found in the example map "Battle Frontier". The information for the trainers and the Pokémon that they use are in the PBS files "battle_tower_trainers.txt" and "battle_tower_pokemon.txt" respectively.
The Battle Factory is a place where players use borrowed Pokémon to fight rather than their own. At the end of each battle, they are allowed to replace one of their rental Pokémon with one from the team they just defeated.