<P> The Federation starship USS Enterprise, following a trail of planets that have been destroyed by unknown means, picks up the automated distress beacon from her sister ship, the USS Constellation and proceed to her location . Upon arrival, they find the Constellation drifting in space, severely damaged and the bridge uninhabitable . Captain Kirk, Chief Medical Officer Dr. McCoy, Chief Engineer Scott and a damage control team transport to the ship to evaluate her, and in Auxiliary Control discover the only member of the crew still aboard, Commodore Matt Decker, her captain, who is suffering from severe mental trauma . </P> <P> Through an anguished exchange with Kirk, Decker explains that they had discovered a giant machine miles long that used beams of antiprotons to tear apart planets and consume the rubble, fueling its progress through this sector of the galaxy . He had ordered the Constellation to attack the machine, but the attack was ineffective and the Starship suffered heavy damage . Decker had evacuated his crew to one of the planets of the star system, but was aghast when the machine destroyed it . Kirk theorizes the machine may be an ancient doomsday machine, inadvertently activated, and they must find a way to stop it before it reaches more populated sectors of the galaxy . The Enterprise takes the Constellation in tow and McCoy takes Decker back to the Enterprise, while Scott's damage control team attempt repairs on the Constellation's impulse engines, weapons and shields . Kirk attends to the Constellation's nonfunctional viewscreen, which will be his only means of monitoring events outside the ship (besides communications from Enterprise). </P> <P> Spock informs Kirk of the sudden appearance of the so - called "planet killer" and it begins to pursue the Enterprise . As the boarding party prepares to beam back aboard, the machine attacks the Enterprise, damaging the transporter and disrupting communications . Obsessed with trying to destroy the planet killer, Decker pulls rank on First Officer Spock, assumes command of the Enterprise and orders a phaser attack . The phasers are useless against the machine, and the Starship is then caught in a tractor beam and is drawn towards the planet killer's maw . Kirk completes his repair of Constellation's viewscreen and is shocked to see the Enterprise engaging the machine . Scott has managed to recharge one of the Constellation's phaser banks and the crippled Starship fires at the planet killer, distracting the machine long enough for Enterprise to escape its tractor beam . After repairing the transporter and reestablishing voice communications, Enterprise retreats to a safe distance . Spock relieves Decker of command on Captain Kirk's orders and Decker is escorted to Sickbay . However, Decker subdues his security escort and steals a shuttlecraft, flying it straight into the maw of the machine . Although horrified as he is about to be swallowed by the planet killer, he does not deviate from his course, despite Kirk and Spock's pleading to return to the Enterprise . The shuttlecraft explodes within the machine and Decker is killed . </P> <P> Lt. Sulu reports that the shuttlecraft explosion has reduced the planet killer's power output by a small amount . Kirk comes up with a plan to explode the Constellation inside the planet killer after reasoning that Decker had had the right idea but not enough power to accomplish his goal . Kirk insists on piloting the damaged Starship into the machine over Mr. Spock's objections . Mr. Scott rigs the impulse engines with a thirty - second time delay before detonation, warning his captain that once the timer has been enabled, there is no way to abort it . </P>

Who built the doomsday machine in star trek