I'm quite sure there is more to random crits than just a formula. I played medic a lot, and if I got my uber ready, I was in really high danger of dying through a crit. Also heavies seem to get crits more often if their targets are just about getting away from their fire. There are some more examples I don't remember. I think players who are dominated have a higher chance to get a crit against the dominating player. And engineers really often get crit wrenches against spies, which is kind of unfair - for the spy

I don't think that's all just random.

It is all just random.

The Wrench tends to crit against Spies because the Sentry's damage dealt increases the Engineer's crit chance, just like any other damage dealing. The reason it appears to crit on Spies alone is because that's the only class you ever see the Engineer attack with his melee weapon.

The other examples are just BS. First of all, crits are rolled when the weapon is fired, not when the bullet/projectile/weapon hits the target, with the exception of items such as the Axtinguisher. So you can't get an increased crit chance against a single player; the shot either crits or it doesn't.

There's no formula in the game that increases your crit chance when your crosshair is on an enemy Medic with 99% Ubercharge, and I somehow doubt there's an intricate program in the game that can detect when a player is just about to run behind cover before they run behind cover, just to give Heavies an increased crit chance against fleeing opponents.