Kevin,
I assume there will be no direct fee for writing it, apart from the Royalty? "Royalty" usually means you own the copyright... but if you were also paid your normal fee to do the work and are not an employee, you would still own the copyright unless you specifically assign it to the customer. So this seems to be skewed a bit in the customer's favor- presumably because they are contributing lots of IP and might go elsewhere?
If you are sacrificing the fee, make sure the customer is going to invest enough in reselling your work to make the risk worthwhile. JMHO.
"... They ne'er cared for us
yet: suffer us to famish, and their store-houses
crammed with grain; make edicts for usury, to
support usurers; repeal daily any wholesome act
established against the rich, and provide more
piercing statutes daily, to chain up and restrain
the poor. If the wars eat us not up, they will; and
there's all the love they bear us."
-- Shakespeare: Coriolanus, Act 1, scene 1