Don't Accept Royalties
It is very, very rare for a piece of software to go on to be a huge revenue generator for a company. As such, it's a bad idea to get in to an arrangement where your services will be paid via future profits from the project. The numbers may sound very attractive, but neither you or the client are likely to be in a good position to truly assess the risk of failure.
If a potential client does suggest this form of payment, it's probably because they're looking for free work. Don't be fooled. Another way to look at the situation is to phrase it this way. If the client isn't willing to put their own money in to the project (i.e. by paying you) then why should you (i.e. giving up time you could've billed to another client)?
The above situation shouldn't be confused with a true partnership. If you are partner in a business then you're not really working for free. Or more precisely, you and your partner are working to advance the business. This situation, of course, is perfectly reasonable.