I think I said something like "My English is Presidential, but I know a guy." I called up the roommate of a friend, and we got all excited. "We'll be done by Christmas!" We got a two bedroom apartment by the Lawrence Caltrain station and filled it with computers. Writing that book took forever. I still call it "the hardest thing I ever finished." but, it was super rewarding, and I still brag about it. I am very glad I did it.
Now, don't get me wrong, I personally am super proud of the tiny checks I get quarterly; and hell, they seem to still be coming in, like 6+ years later, and I am the sort of person who refuses to pretend like salary doesn't matter, but on an objective level? It's just so little money compared to what I get as a bay-area contractor that sometimes I think I'd be happier framing the checks than cashing them. I made literally thousands of dollars!
When I negotiated, it was explained that I got a better percentage for giving up the advance, so I did, because the advance was like a week's pay from the dayjob, but if I could go back and tell myself what to change in that negotiation? I'd tell me to take the percentage payout as if I had taken the advance, in exchange for the publisher promising to spend the advance money on publicity for the book.
Honestly, I have no idea if that's a standard thing, but I don't see why they wouldn't do it if I asked.
Also note, in my case? the e-book royalties were comparatively quite substantial, even though my book isn't available in the Kindle store; you can only buy the e-book, as far as I can tell, direct from no-starch, and it costs almost as much as the regular book and the e-book. They don't sell very many e-books, but my percentage on the e-book was way higher. I imagine that percentage drops a lot if you sell the e-book through amazon; I believe the vig on a kindle book is more than what it costs to print a book, (though I know printing a book is not the only cost of distribution, so the kindle book is likely still cheaper, as the 30% covers not only printing, but distribution and retail profit.)
The people I know who make good money off books are already famous, and they sell without a publisher. But... that's really hard to do if you aren't already famous.
I went with a publisher because going with a publisher gives you a lot of credibility if you are not yet famous, and because seeing my physical book in physical stores tickles me to no end. And because it was their idea, and to be completely honest, I never would have finished without the publisher working with me.
I guess my main point is that you should think carefully about the non-monetary things you want when deciding which publisher you want, way more than you should think about the monetary things. Sure, get the best deal you can, because why not, but looking back? I totally would have traded away some money for more fame.