Drone technology is advancing rapidly and represents significant benefits during firefighting operations. This paper presents a novel approach for autonomous firefighting missions for Unmanned Aerial Vehicles (UAVs). The proposed UAV framework consists of a local planner module that finds an obstacle-free path to guide the vehicle toward a target zone. After detecting the target point, the UAV plans an optimal trajectory to perform a precision ballistic launch of an extinguishing ball, exploiting its kinematics. The generated trajectory minimises the overall traversal time and the final state error while respecting UAV dynamic limits. The performance of the proposed system is evaluated both in simulations and real tests with randomly positioned obstacles and target locations. The proposed framework has been employed in the 2022 UAV Competition of the International Conference on Unmanned Aircraft Systems (ICUAS), where it successfully completed the mission in several runs of increasing difficulty, both in simulation and in real scenarios, achieving third place overall. A video attachment to this paper is available on the website https://www.youtube.com/watch?v=_hdxX2xXkVQ.