A pensioner accused of trying to hire three hitmen to murder his wealthy The Bill scriptwriter partner told jurors he was inspired by spy-turned-author Frederick Forsyth to research an "authentic" thriller.
David Harris told how his debts mounted up after he became "besotted" with a younger woman in a brothel and spent £50,000 wining and dining her.
He decided to make money by writing a novel based on his personal situation and a hitman character that was "essential to the plot", the Old Bailey heard.
The 68-year-old allegedly offered £200,000 to arrange a fatal accident for Hazel Allinson so he could get his hands on her money and £800,000 home in the upmarket village of Amberley, West Sussex.
Jurors have heard he wanted to live out the rest of his days with a young lover, Ugne Cekaviciute.
The first man Harris allegedly approached was mechanic and trainee private investigator Chris May who tried to warn Ms Allinson in a series of emails.
Harris then tried to engage 6ft 3in tall "man mountain" Zed - real name Duke Dean - who instead reported him to City of London Police after he was handed Ms Allinson's photograph and diary, the court has heard.
The defendant was arrested after he was secretly recorded telling an undercover officer he was "deadly serious" about the hit, jurors have heard.
Giving evidence, Harris denied soliciting the murder of Ms Allinson and insisted she was never in any danger.
He told jurors he had worked in television and films before his retirement and was location manager for The Bill for 18 years.
He met Ms Allinson in 1989 while working on the long-running ITV drama and she saved him from his addiction to alcohol, he said.
Harris told jurors he retired through "ill health" in 2006 while his partner stopped working when The Bill ended in 2010.
The defendant told jurors Ms Allinson gave him a monthly allowance of £400 reduced later to £300 as well as two lump sums of £25,000.
Harris told jurors he still had an "active libido" and would visit brothels to fulfil his sexual needs.
He met his younger girlfriend at a brothel in Worthing, he said: "I had become besotted with her. I thought that she was too young and too nice to be in a brothel and over the time we developed our friendship, our relationship, I discovered she wanted to go back to uni and study."
Harris said she was also working as a carer for adults with special needs and she left the brothel on his request.
He said: "Once Ugne came out of the brothel, I started to see her on a more regular basis, not more times a week, but as a regular person.
"It started to get very expensive having dinner, lunch, hotels and I just couldn't afford it so I started drawing out that capital that Hazel had given me."
By the time of his arrest, the money she gave him was "long gone", he said.
By 2016, Harris said he was "very stressed" and "anxious" as he struggled with money.
Harris told jurors he got the idea to write a book from reading thrillers on his Kindle.
He said: "I'm not a qualified writer by any size, shape or form. I have no writing qualification, just what I had picked up over the years.
"I decided to do some research. By listening to the Book Programme, the advice was to base it on something you know about."
Harris said the writers he had listened to were Lee Child and Karin Slaughter.
He went on: "I thought what was happening to me at that time, at that particular juncture, might form the basis of a good thriller.
"It was based on a guy based on me, my sort of age, meets a young girl, falls in love, becomes besotted and over development decides he wants to be with her and decides what he has to do about his wife Holly."
Harris said the main character was to be Tom Noble, a marketing sales director.
Harris said he took his lead from Frederick Forsyth, who advocated authenticity in his books rather than "schoolboy pranks".
Describing his first meeting with Mr May, Harris said he told him he did not need a "debt enforcer" but a "hitman".
The defendant, who denies soliciting murder, said: "Surprisingly, there was no difference in his demeanour.
"He didn't say absolutely not and jumped out of the car. He thought about it for a few seconds and said 'yah, we can do that'."
Tim Moloney QC, defending, asked how he felt after his first meeting with Mr May.
Harris replied: "I felt I might have achieved something and might be starting something and might be making progress with my storyline for my book.
"But I never thought at any time Hazel would be in danger."
Asked why not, he said: "I always felt I was in control of what was going down and what was happening."
The trial was adjourned until Thursday.