Based on a request in the gpr forums: http://registry.gimp.org/node/13251
This consists of two scripts, one to multifill, and one to flatten.
Multifill takes every background coloured space (selectable) and will fill them with sequential palette entries, or randomly. It does NOT check to see if adjacent colours are the same, but use of a large palette should reduce the likelihood.
There is an option to use either the width and height OR the area of each zone for the checks in multifill.
There is a check to ignore (fill with black) a certain size as well (set it to zero to disable). This will have the result once flatten is run to make little spots take the colour of the nearest area.
Lastly, to speed up workflow, there is a checkbox option to make a copy of the lineart layer and set it to multiply (on top of the multicoloured one), and a checkbox option to flatten the multifilled layer automatically afterward.
This means that starting with lineart, you should end up with the original lineart in a multiply layer with a flattened layer of colours below it, already active and ready for you to start using the colour
I am not a cartoonist, but this has been tested by the original requester and I am told it works ;)