The trial of a man accused of murdering a 21-year-old with "the mind of a child" has heard how he had thoughts of killing almost all the time.
Dean Shorney had just returned from a day out in Porthcawl
Wayne Royston, 35, from Bargoed, Rhymney Valley, denies stabbing to death Dean Shorney, 21, at a park.
Cardiff Crown Court heard Mr Shorney was the victim of "a frenzied attack".
The prosecution said Mr Royston had for several years experienced homicidal thoughts and doctors had raised concerns with police as early as 2003.
Mr Shorney's body was found on 18 April with 38 stab wounds and his throat had been cut from ear to ear.
Opening the evidence for the prosecution, Peter Murphy QC described how Mr Royston, who was unemployed and claiming disability allowances, had been having thoughts of killing for several years.
These had been getting worse around the time of Mr Shorney's death, the court heard.
Severe personality disorder
A report by a psychiatric doctor in 2003 showed he had admitted a number of incidents, including trying to suffocate his first girlfriend, having homicidal thoughts about a manager at work and a woman he had been having an affair with.
Mr Shorney's body was found at a park in his home town of Bargoed
Doctors deemed him as having "high risk of severe violence, perhaps even of killing someone".
Mr Murphy told jurors that Gwent Police were told that year about the concerns - this knowledge ultimately led officers to arrest him after Mr Shorney's death.
Later he was diagnosed as suffering with dangerous severe personality disorder and was considered untreatable. Doctors once again highlighted their concerns to police.
The court heard that two years later, Mr Royston told doctors he was "having homicidal thoughts all the time" and that a month before Mr Shorney died, he said his thoughts about killing had worsened.
His medication was altered and five days before the killing he told the nurse it was helping.
However, the court heard the day before the killing he had run out of his supply of diazepam, and he was unable to get any more until next day.
Mr Murphy described the victim Mr Shorney as "a harmless soul who would never hurt a fly".
On the day he died, the said he had gone for a walk at the park near his home at about 6.30pm.
The jury heard that several people heard screams and a man's voice shouting from inside the park after 10pm. Mr Shorney's body was discovered 20 minutes later.
Carl Fortune, 20, a neighbour and friend of Mr Shorney, was walking through the park when he came across his body. He called an ambulance and put Mr Shorney in the recovery position.
It was then, said Mr Murphy, that he saw it was his friend and noticed his throat had been cut "from one side of the neck to the other".
In a distressed state, Mr Fortune went to seek help and saw Mr Shorney's father in a car looking for his son. He told him what had happened and at that moment the police arrived.
Police officers began to administer first aid before Mr Shorney was taken to hospital where he was pronounced dead.
The court heard how a post mortem examination showed he had sustained 38 stab wounds.
"The final injury was a slash-type injury to the front of the neck," said Mr Murphy.
Mr Royston also denies perverting the course of justice. The trial continues.