The essential OnSpawn code will look something like this:
SetCreatureBodyPart(CREATURE_PART_HEAD, nHead, oNPC);
SetColor(oNPC, COLOR_CHANNEL_SKIN, nSkin);
SetColor(oNPC, COLOR_CHANNEL_HAIR, nHair);
SetColor(oNPC, COLOR_CHANNEL_TATTOO_1, nTatoo1);
SetColor(oNPC, COLOR_CHANNEL_TATTOO_2, nTatoo2);
where the integers nHead, nSkin etc are values chosen at random from a list.
For example, you might choose from the following colours:
const string SKIN_COLOR = "000 001 002 004 005 008 009 012";
const string HAIR_COLOR = "000 004 008 012 020 116 124";
Unfortunately, there is an engine bug which can spawn NPCs with no head or other invisible parts. This can be minimised by
- Choosing a random NPC template with the desired clothing (rather than equipping random clothing).
- Actioning the NPC to jump to an empty area, then immediately jump back.
I imagine you can tint the clothing randomly, too, but I haven't tested that.