It is almost never a good idea for the beginning consultant to develop software for a client in return for a percentage of the profits the client will earn through selling your software to others. The client who offers you this kind of deal is usually looking for a way of getting free software for their own use and rarely if ever has the ability--or motivation--to sell your product to others.
The only time to consider a royalty deal for developing custom software is when you are offered an advance on future royalties that is equivalent to the amount you'd earn writing the software at a reasonable hourly rate. This is true not only because the advance may be the only money you ever get from the sale of the software, but also because a client who has his or her own money invested in the development of a product is much more likely to put up the rest of the money and effort it will take to market it.