When I've helped defend other companies (two of which are among the largest/most prominent in the games industry), I've just provided expert witness testimony as to the existence of prior art. I've never had to testify about it in court, so I'm fairly sure that each time the trolls dropped it before going to court.
As to how much it costs - no idea. They had pricey lawyers though, so there's certainly some cost involved. I suppose it depends on how big the balls on the troll are, or perhaps how easily they think the defendant will be intimidated into just settling.
At least invalidating the patent.
Another strategy is to try and invalidate the patent via the USPTO before it goes to trial. This often does work with bogus patents, but it’s still not cheap. I have heard the ballpark figure is $100k.