The gunman who killed three people and wounded several others at the Kansas plant where he worked had been served a restraining order less than two hours before he opened fire, investigators said Friday.

The shooter, identified as 38-year-old Cedric Ford, showed no indication he’d unleash a rampage when the protection from abuse order was served Thursday afternoon, Harvey County Sheriff T. Walton said. He described Ford as “upset” at the time, but not unusually so.

Still, the sheriff said the order likely triggered the shootings, which ended when a police officer who stormed the building alone killed the shooter.

Walton said such protection orders are usually filed because there’s some type of violence in a relationship, but he didn’t disclose the nature of the relationship in question.

Investigators said Ford shot two people while driving to the Excel Industries plant in Hesston and shot another person in the parking lot before going inside. The gunman then shot 15 others in the lawnmower parts factory at random, killing three of them.

Officials from the Bureau of Alcohol, Tobacco, Firearms and Explosives said they were looking into how Ford obtained his guns and ammunition. A SWAT team stormed Ford’s mobile home in Newton after the shootings, but it’s unclear what investigators found there.

Walton described the officer who killed Ford as a “tremendous hero” because there were still 200 or 300 other people in the factory and that the shooter intended to continue his rampage.

“Had that Hesston officer not done what he did, this would be a whole lot more tragic,” Walton said. He did not name the officer, saying a separate investigation into the actions of law enforcement was underway.

A federal law enforcement official tells Fox News that assets from the FBI’s Kansas City field office are helping in the investigation.

Ford had several convictions in Florida over the last decade, including for burglary, grand theft, fleeing from an officer, aggravated fleeing, carrying a concealed weapon, all from Broward and Miami-Dade counties.

Online records show Ford was released from the custody of the Florida Department of Corrections in February 2007. It was unclear from the public records whether he had completed probation.

According to the Wichita Eagle, Ford has also had criminal cases in Harvey County, including a misdemeanor conviction in a 2008 fighting or brawling case and various traffic violations from 2014 and 2015.

Walton said Ford had been “in my jail a couple of times before.”

Excel was “deeply saddened by the horrific event that occurred yesterday,” president and CEO Paul Mullet said. 

The shooting came less than a week after authorities say a man opened fire at several locations in the Kalamazoo, Michigan, area, leaving six people dead and two severely wounded. Authorities haven’t disclosed a possible motive in those attacks.

Eleven of the people wounded in Thursday’s attack were taken to two Wichita hospitals, where one was in critical condition, five were in serious condition, and five were in fair condition Friday morning, hospital officials said. The others were taken to a Newton hospital, and their conditions weren’t immediately available.

Walton said his office served the suspect with the protection from abuse order at around 3:30 p.m., which was about 90 minutes before the first shooting happened.

While driving to the factory, the gunman shot a man on the street in the nearby town of Newton, striking him in the shoulder. A short time later, he shot someone else in the leg at an intersection.

“The shooter proceeded north to Excel Industries in Hesston, where one person was shot in the parking lot before he opened fire inside the building,” the department said in a release. “He was seen entering the building with an assault-style long gun.”

Martin Espinoza, who works at Excel, was in the plant during the attack. He heard people yelling to others to get out of the building, then heard popping, then saw the shooter, a co-worker he described as typically pretty calm.

Espinoza said the shooter pointed a gun at him and pulled the trigger, but the gun was empty. At that point, the gunman got a different gun and Espinoza ran.

“I took off running. He came outside after a few people, shot outside a few times, shot at the officers coming onto the scene at the moment and then reloaded in front of the company,” Espinoza told The Associated Press. “After he reloaded he went inside the lobby in front of the building and that is the last I seen him.”

A Hesston officer responding to the scene exchanged fire with the shooter and killed him. The officer was not injured.

Walton said the attacker had an “assault-style” rifle and a pistol.

Erin McDaniel, a spokeswoman for the nearby city of Newton, said the suspect was known to local authorities. She wouldn’t elaborate.

Hesston is a community of about 3,700 residents about 35 miles north of Wichita.

Excel Industries was founded there in 1960. The company manufactures Hustler and Big Dog mowing equipment and was awarded the Governor’s Exporter of the Year award in 2013 from the Kansas Department of Commerce.

Fox News’ Matt Dean and The Associated Press contributed to this report.