LOS ANGELES—A California sheriff’s deputy was fatally shot this weekend when his SWAT team tried to rescue people held hostage inside a San Joaquin Valley home by a man armed with an AK-47-style rifle and a handgun, authorities said Monday. Four other people were also killed in the shootout, including the gunman—who had been previously arrested multiple times for domestic violence offenses, according to Lt. Joel Swanson, a spokesperson for the Kern County Sheriff’s Office. Swanson did not know the specifics of the 41-year-old shooter’s previous arrests and he has not yet been named publicly. A restraining order against the gunman—filed by one of the victims and effective June 3 —was supposed to stop him from coming to the home where the killings occurred. Three people inside the home—believed to be the gunman’s sons and their mother—were fatally shot during the standoff Sunday afternoon in Wasco, a small community in …