Four men are facing years in prison for their part in drug dealing and a shooting in Sunderland.
Tony Trott, Lee Barnett, James Lee Ratcliff, and Philip Steabler took part in a revenge attack after a house they were using to store drugs destined for the streets of Sunderland and Hartlepool was burgled.
Six shots were later fired through the front window of a house in Craigshaw Square, in Hylton Castle.
The four will learn their fate after a judge considers their cases overnight.
Prosecutor Peter Makepeace QC told Teesside Crown Court the shooting in September 2016 was in response to the earlier burglary.
"The safe drugs house was in Hylton Road in Sunderland," he added.
"Despite the serious nature of the burglary, the occupant did not call the police, but instead contacted Tony Trott, Barnett, and Steabler.
"Trott, in turn, recruited Ratcliff who was to do the actual shooting.
"The burglary that had taken place was undoubtedly a taxing by one drugs gang on another, and the shooting was a retaliatory attack."
Six 6.35mm Browning bullets were fired through the living room window of the house in Craigshaw Square, the court heard.
"Three adult males were in that room," said Mr Makepeace. "It is extraordinary good fortune that none were hurt.
"CCTV captured a Pajero car arriving at the scene, its lights extinguished just prior to arrival.
"Ratcliff and another male exited the vehicle, and walked into Craigshaw Square.
"The driver remained in the car, repositioning it as Ratcliff walked further into the square, discharged the gun, and fled back towards the Pajero,
"They were closely pursued by an occupant of the house, but were able to get back into the Pajero and make a fast getaway."
A second vehicle, a Peugeot, was used by the gang as a back-up and to help them disperse afterwards.
Mr Makepeace said the use of the Peugeot indicated the shooting and its aftermath was carefully planned.
Trott, Ratcliffe, and Steabler were each involved in a conspiracy to supply cocaine in Sunderland and Hartlepool.
On seven occasions in 2016 police observed drugs and cash handovers between the men and their contacts from elsewhere in the country, including Merseyside and Yorkshire.
The largest cash seizure was more than £29,000 found in a car which was stopped on the A19.
"The transaction had been arranged by Tony Trott," said Mr Makepeace.
"His father was a passenger, and the driver was his father's partner.
"The cash was in a child's rucksack, and the package bore the fingerprints of Tony Trott's partner.
"An examination of the car's sat nav showed it was on its way to Liverpool."
Trott, 30, of South Terrace, Sunderland, is due to be sentenced for possessing a firearm with intent to endanger life, and conspiracy to supply cocaine.
Barnett, 42, of Throston Grange, Hartlepool, is due to be sentenced for conspiracy to possess a firearm with intent to endanger life.
Ratcliff, 35, of no fixed abode, is due to be sentenced for conspiracy to possess a firearm with intent to endanger life, conspiracy to supply cocaine, and assault occasioning actual bodily harm.
Steabler, 41, of Thorndale Road, Sunderland, is due to be sentenced for assisting an offender, and for being concerned in the supply of cocaine.
Caroline Goodwin QC, for Trott, said he deserved credit for admitting the drugs offences.
Lawyers for Barnett and Ratcliff said both men had been model prisoners while on remand.
Amos Waldman, for Steabler, said his involvement in the shooting was limited to disposing of the Peugeot car
"He knew it had been involved in criminality," added Mr Waldman. "But it was a shock to Mr Steabler when he became aware of the seriousness of what he had become involved in."
Judge Deborah Sherwin said she will think about the case overnight and will pass sentence on the four men on Tuesday.
All four were remanded in custody.