The Good, The Bad and The Ugly was the last of the Dollars Trilogy filmed by Sergio Leone.  Eli Wallach played The Ugly, Tuco Ramirez, who was about as despicable as you get.  Greedy, robbing dead soldiers for pocket change, an all around bad guy, but no wimp.   He survives torture, being abandoned in the desert with his hands tied, and escapes capture by jumping off a train (handcuffed to another villian, who he mangages to murder).  He also had some mechanical abilities, as shown when he wanders in out of the desert into an unsuspecting gun shop.  He doesn't care for the proprietors offerings, but takes apart several guns and builds his own from their parts, and he seems to have an ear for it.  For all his faults, he knows his guns!