A man who was shot to be brought under control having hurled petrol bombs at police is to remain in hospital.
Krzystof Andruczak turned on a team of officers who attended at his flat in Inverness on March 31 last year.
The 41-year-old – who was wearing a gas mask and was in camouflage clothes – was also armed with two knives and a metal chain.
The officers luckily escaped any serious harm, but Andruczak left a nearly £2 million repair bill due to the damage caused at the block of flats.
During a clean-up, workmen went on to discover a cache of deadly weapons in the landing including a crossbow, bayonet, slingshot and hatchet.
Andruczak had faced a series of charges at a hearing in February which included the attempted murder of five police officers, wilful fire-raising and assault.
But, he was acquitted after prosecutors accepted he was suffering from a mental disorder at the time.
A further hearing called at the High Court in Glasgow.
Facebook page showed pictures of knives and petrol bombs
Lord Matthews imposed a compulsion order without limit of time for Andruczak to remain at the State Hospital in Carstairs for treatment.
The court previously was told how Andruczak’s sister had raised concerns about him prior to the incident.
She was aware of photos on his Facebook page showing pictures of knives and bottles that appeared to contain petrol.
The woman went on to contact mental health officials, police and the local psychiatric hospital.
The constables were among those who later turned up at the flat in Polvanie View, Inverness to talk to Andruczak.
Officers decided to force entry although it appeared the door had been barricaded.
When police finally got in, Andrusczak was in a “crouched position” clutching a lit petrol bomb as if ready to launch it.
Prosecutor Chris Macintosh said: “There were numerous other unlit petrol bombs at his feet.
“One officer opened an internal door to act as a barrier.
“The constable felt a strong thud to the back of the door, heard smashing glass and then felt an intense burst of heat.”
Police retreated outside before Andrusczak hurled another petrol bomb from a window narrowly missing an officer.
He went on to lower himself down from his first-floor flat using a rope.
As the block billowed with smoke, Andruczak whipped out two knives from his waistband and started swinging a bike chain.
Police formed a cordon to try and contain him.
Firearms officers eventually arrived at the scene.
£2 million of damage to building
A taser was discharged twice and he was also hit with a rubber bullet, but it had no effect.
It was only when he was shot in the leg that he sank to the ground.
The hearing was told the damage Andruczak caused to the local authority building was “extensive”.
Mr Macintosh said the costs of repairs and having to rehouse other tenants was in the region of £1.8 million.
The court heard Andrusczak was suffering from a mental disorder at the time and did not “appreciate the wrongfulness of his conduct”.