What's that? One of your figures has broken? Well you're not alone, mass market figures break all the time. Usually the plastic is weak from air bubbles or flaws. To fix most hip and shoulder breakage at the peg you'll need a Dremel tool (or hand drill), a mini screwdriver, an assortment of screws to choose from, and superglue.
Fixing a true ball joint is about the same, where the ball has broken off inside the socket. The only difference is you'll be filing off the head of the screw and rouding it to match the curve of the ball afterwards. This technique works for just about any spinning joint inside a figure. Work slowly and have fun!