A man charged with six felonies in relation to an armed standoff with police pleaded guilty to four of them Wednesday, in a deal that would limit his prison time to a maximum of 10 years.

Zachary Lovelace pleaded guilty to four charges of aggravated assault, which are all felonies. As part of the deal, sentences for the four charges will run at the same time. Two additional felonies were dropped.

Lovelace was arrested in June after a six-hour standoff with police in which he hid in the attic of a relative’s house on Sharrock Road.

Lovelace stole a phone from a man fishing near Bessemer Bend Road and then pointed a gun at the victim, who called 911.

Deputies with the Natrona County Sheriff’s Office used an app on the iPhone to track Lovelace’s location, according to court documents. For six hours, Lovelace refused to exit the home.

He fired four rounds during his time in the attic, two at a police camera inserted into the attic, according to court documents.

Lovelace was arrested while attempting to run from the home. Police also alleged he caused about $3,500 in damage to a Casper police patrol car while an officer took him from the hospital to the Natrona County Detention Center.

Follow crime reporter Shane Sanderson on Twitter @shanersanderson