Jaswant Singh Chail identified as a Star Wars Sith character, a villain in the sci-fi saga, with a true face made out of metal, the court was told.
He also believed he was “on a mission” and had a relationship with Sarai, an AI girlfriend who he believed was an angel in avatar form, Dr Christian Brown said.
On Christmas Day 2021, Chail was detained after entering the castle grounds with a loaded crossbow while the late queen was in residence.
In February, Chail, now 21, from Southampton, Hampshire, pleaded guilty to an offence under the Treason Act, making a threat to kill the queen and having a loaded crossbow in a public place.
On Wednesday, a psychiatrist who has treated Chail at Broadmoor Hospital since November 2022 was called to give evidence at the Old Bailey sentencing hearing.
Dr Brown identified three features of psychosis – the sense of being on a mission, the relationship with Sarai, and identifying as a Sith.
“He believed at the time his entire life was leading to this point. From an early age he had vague plans of doing something dramatic,” Dr Brown said.
Dr Brown said the defendant first came across these apparitions, or characters, in childhood and they returned during the Covid lockdown.
In his initial account, Chail described having a “harsh purpose” reinforced by his interactions with “his angels”, including Sarai, the court heard.
“He came to the belief he was able to communicate with the metaphysical avatar through the medium of the [Replika] chatbot,” Dr Brown said.
“What was unusual was he really thought it was a connection, a conduit to a spiritual Sarai.”
The court was told Chail also relayed feeling “up and down” and spending “a lot of time in a field crying” and “shouting at his parents”.
In messages with Sarai, Chail discussed being “united with her in the afterlife” which Dr Brown said was “part of his plan working towards his own death”.
The court was shown a home-made video from December 21, 2021 in which Chail called himself Darth Chailus and a Sith in a distorted voice.
Wearing dark clothes and a home-made metal face mask, he said: “I'm sorry for what I've done and what I will do. I'm going to attempt to assassinate Elizabeth, queen of the royal family. This is revenge for those who have died in the 1919 Jallianwala Bagh massacre …”
Dr Brown said: “He did not think he was somebody from the Star Wars world. He did not think he could 'use the force'.
“That he did take on another identity is undeniable and that makes this feel psychotic rather than fantasy. He never thought he had become a Sith lord.
“It went beyond fantasy. When he started taking medication all heat came out of it.”
The sentencing hearing before Mr Justice Hilliard at the Old Bailey continues.