LET'S TALK PHARMA;
Pharma might be an asshole, a guy who knows he's the best and doesn't hesitate letting others know that, but he isn't some 'toxic obsessive ex' or 'unhinged guiltless manic who kills people'.
He had a psychotic break after years of pressure to kill patients he cared for, and being forced to work with the opposing side of the war just to be able to keep the medical outpost he was positioned at safe. One he didn't even want to be at, shown in a flashback with Ratchet.
Then speaking of Ratchet, when Pharma was talking to him about life or death situations, he more than likely meant every word he told Ratchet about doing this out of desperation, and the moment Ratchet shown no care toward Pharma's side of the situation probably aided in his break.
That moment was when it was clear to Pharma that, as much as he probably tried to get him to in the past in the past due to his confirmed unrequited crush, Ratchet did not care for him past his medical achievements or doings, if he even cared for those to begin with. And it's further shown to the viewer how little Ratchet cared about Pharma as a person when all he had to say on the others presumed death was that 'He was a good medic.' which is not anything to actually do with Pharma, only his proficiency at his job.
All of that with Ratchet on top of a high stress situation, that was likely where Pharma broke. If not even Ratchet, the one he believes closest to him on a skill and intellectual level by a landslide, can understand his desperation and need for help, then he had nothing left to lose.
He genuinely wanted the best for those around him and took the route he thought would be best, rather than having the DJD come in and kill them ALL themselves, if patients were already dying, it wasn't the worst choice, given it was either comply or sentence him and all the staff he managed to death.
PERSONALLY I believe Pharma's hatred of Decepticons comes from being forced to work under the D.J.D's terms, having someone force you to literally harvest your patients organs to fed an addiction to transforming could have been Pharma's moment of 'Decepticon = Sicko' and so had extremely grown to despise anyone under the term Dcepticon. Like Pharma never hated Ambulon in the slightest, by all means he was a good mech trying his best, but anytime he saw him, all he could think of were the Decepticons who had ruined so much for him, which is why he immediately pins the blame on Ambulon.
Pharma is so much more than what people make him out to be, he had skill, passion, and care for those he worked with, just for it all to be taken away by something he could never even think of controlling, which must have been a lot to someone described as a 'control freak'.
During Luna-1, when Pharma was at his most broken and stitched back together, he clearly held guilt for at least some of the things he did, given he could not get through the guilt shield on the portal there.
Once more I personally believe that the moment with First Aid and Pharma where he mocks the death of Ambulon, Pharma knew what he was doing in provoking First Aid. He clearly knows how much of a caring person First Aid is, and to have killed Ambulon right in front of him, he should have known what would happen when provoking an armed First Aid. I think he intentionally led himself to death because he knew there was nothing for him anymore.
I do love the addition later on when Adaptus has taken Pharma's form and is threatening Tyrest and there is just enough sheer WILL in Pharma's spark to make one last comment about Ratchet. Which shows just how much Pharma cared for Ratchet in any way shape or form, to where the thing that persists in the final bits left of his spark is whatever admiring hatred Pharma now has for Ratchet.
----------------------------------------------------
Pharma is a bot who was broken by the control of those around him, how Ratchet left without saying goodbye, how he got transferred to Delphi just to get stuck between a rock and a hard place, and how by the end of the series he had been let down by the only one he would let know him, had his hands stolen from him, no hope left to pursue the paths he was passionate in (medicine and science), and for his death to never mourned.
When you break him down Pharma is greatness gone wrong, let down by the negative parts of his personality, yes, but also let down by the world around him to the point he turned harmful to others.
Thank you for coming to my ted talk if you bothered to read this, i am by no means good at breaking down characters or explaining them, but I just love Pharma so much and I need to speak.












