A man accused of knifing four members of the same family planned to kill himself afterwards, a court heard.
Redvers Bickley, 21, is accused of launching a brutal assault on siblings Tyler, Cody and Shannen Denton at his home in Rhyl.
He denies murdering his housemate Tyler in September 2017 and attempting to murder her sisters and father Paul.
Mr Bickley had paranoid suspicions and believed people were plotting against him, Mold Crown Court heard.
The group had been celebrating Tyler's partner Hayley Barnett's 25th birthday when Mr Bickley started attacking them, the court was told.
Psychiatrist Dr Noir Thomas said Mr Bickley had hoped to have a relationship with Tyler, but the situation frustrated him.
This was exacerbated when he became angry because she did not invite him to go on a drive and he accessed her iPad, finding comments about him, Dr Thomas said.
The psychiatrist said the defendant suffered from a mental disorder that significantly impaired his ability to control himself.
Dr Thomas added his relationships "were marked by his expectation that other people are going to harm him".
"His rage was more frequent and intrusive leading up to the offences," Dr Thomas added.
'I will kill myself'
He described Mr Bickley imagining harming people who had bullied him in his life and said an alter ego, he calls James, would use knives and swords to mutilate them.
Under cross-examination, Mr Bickley said he had made a promise that however many times he failed "one day I am going to kill myself, even if it takes the rest of my life".
He said he had attempted to do so on the night of the attacks.
The trial continues.