Complex sentence: The eidolons possess some of the automatons and attack them, but Leo saves the day by using the fortune cookie to learn the activation code for one of the devices and destroys the possessed automatons with it, trapping the eidolons.
Split into simpler sentences: The eidolons possess some of the automatons and attack them, but Leo saves the day by using the fortune cookie to learn the activation code for one of the devices. He destroys the possessed automatons with it, trapping the eidolons.