A thief who raided a Fife army cadet base was caught after drawing a map of where he had hidden the stolen guns.
Sean Barclay ransacked the centre in Newport-on-Tay, where he had once been a cadet, after climbing in through a smashed window.
Barclay, 28, fled with a firearms haul including three training rifles that he planned to sell.
He was jailed for eight years after he admitted the theft and two firearms charges.
The High Court in Glasgow heard that a staff sergeant discovered that there had been a break-in at the cadet base on 9 May last year.
A window had been smashed, a door forced open and three training drill purpose rifles, dummy rounds and five gun slings were missing.
A total of £100 in cash as well as a rucksack were also taken.
Barclay was not immediately traced as the culprit and he was locked up for other matters shortly after the raid.
But, two months later, police moved in on a flat in Cowdenbeath, Fife. It was the home of the sister of one of Barclay's friends.
Prosecutor Eric Robertson said the map was found in the flat, and it appeared to show a trail with "distinctive bends".
Officers then compared it to ordnance survey maps of north east Fife.
They were able to follow the directions taking them close to Inverdovat Farm in Newport-on-Tay.
After driving down a quiet, single track road, police went into woods. There, they found a camouflage bag stashed under bushes.
The guns stolen from the cadet centre were soon discovered inside.
The makeshift map was then analysed - and Barclay's DNA was on it.
Mr Robertson explained that it was drawn on paper from Perth Prison, where Barclay had been remanded.
The handwriting matched that from another document Barclay had completed while in jail. Tests also revealed his palm print was on the map.
Barclay was arrested and confessed to the break in.
Chris Fyffe, defending, described Barclay's crime as "opportunistic".
But, the lawyer added: "The fact that he wanted to sell them, I accept is an aggravating feature."
Sentencing, Lord Arthurson said planting the rifles had involved "stealth and carefully planned concealment".
Det Insp Christopher Mill said: "The theft and circulation of illicit firearms is completely unacceptable and when it occurs Police Scotland will take proactive steps to curtail this activity and bring those responsible to justice.
"While these were training weapons, they have the capacity to be converted into viable weapons, which could have caused real harm to the public.
"Thankfully these weapon were recovered and ultimately posed no risk to the Newport-on-Tay community."