As a freelance writer, I've done an awful lot of jobs that offered no great prospects. Novels that paid a flat fee and nothing more, regardless of how many copies they sold, features and articles that brought a single payment, yet keep getting reprinted. I went in eyes wide open, it was my choice to sign up. But the dream is always to get a commission that pays good money now [not easy, especially in these bereft times] and the hope of further funds.
Even if you get a royalty deal, there's no guarantee your project will sell enough to clear its advance. I spent so much time and money researching a particular non-fiction tome, I probably lost money on it [curse you, Michael Caine!]. Then again, I suspect the publisher took a bath on that book too, so the pain get shared round. But sometimes a job comes good and you get a nice little trickle of money back from it. That's the joy of royalties.
In the last week I've have two such bursts of joy. Turns out six of my Big Finish audio dramas have now sold enough to generate royalties. Nothing huge, but a nice wee bonus. And the hardback edition of my magnificent octopus about the history of 2000 AD has effectively sold out, also bringing a royalty payment. THRILL-POWER OVERLOAD has just been published in paperback, meaning every copy sold now on will generate future royalties. Nice.