[ASK] How do we modify specific diet for a race?

Started by deliveryservice, November 30, 2016, 12:17:48 AM

Previous topic - Next topic

deliveryservice

I wanted to add an Item designed to be an only diet for my unique race. But after a while I thought it would necessary to add new diet type (in racedef).

Based on the existing diet, I observed we have,
1. the carnivore (for Carnivore animal i.e dogs, consisting any meats nutrition, but also meals and kibbles),
2. strict-carnivore (For warg that prefer raw meat, especially corpses, and kibbles),
3. herbivore (For the cattles), and
4. the omnivore (For vanilla colonist).

The ultimate question I ponder about is;

Is it possible to make them, say eats only rotten corpses or maybe nutrient paste by modding the xml only?

Thirite

#1
According to the source code, these are all the available possibilities for the foodType xml entry:

None = 0,
VegetableOrFruit = 1,
Meat = 2,
Fluid = 4,
Corpse = 8,
Seeds = 16,
AnimalProduct = 32,
Plant = 64,
Tree = 128,
Meal = 256,
Processed = 512,
Liquor = 1024,
Kibble = 2048,
VegetarianAnimal = 3345,
VegetarianRoughAnimal = 3409,
CarnivoreAnimal = 2314,
CarnivoreAnimalStrict = 10,
OmnivoreAnimal = 3355,
OmnivoreRoughAnimal = 3419,
DendrovoreAnimal = 2193,
OvivoreAnimal = 2336,
OmnivoreHuman = 1855

So probably the closest you could get to "Rotten corpses and nutrient paste" would be:
<foodType>Corpse, Processed</foodType>

Foodtypes are computed by adding their numerical values together to get a unique number. Everything after Kibble is just a "group" of other previous types. So some of these like "CarnivoreStrict(10)" is exactly the same as "Meat/2 + Corpse/8 " = 10. CarnivoreAnimal/2314 is the same as Kibble/2048 + Meal/256 + Corpse/8 + Meat/2... etc.

deliveryservice

#2
Quote from: Thirite on November 30, 2016, 01:30:42 AM
According to the source code, these are all the available possibilities for the foodType xml entry:

None = 0,
VegetableOrFruit = 1,
Meat = 2,
Fluid = 4,
Corpse = 8,
Seeds = 16,
AnimalProduct = 32,
Plant = 64,
Tree = 128,
Meal = 256,
Processed = 512,
Liquor = 1024,
Kibble = 2048,
VegetarianAnimal = 3345,
VegetarianRoughAnimal = 3409,
CarnivoreAnimal = 2314,
CarnivoreAnimalStrict = 10,
OmnivoreAnimal = 3355,
OmnivoreRoughAnimal = 3419,
DendrovoreAnimal = 2193,
OvivoreAnimal = 2336,
OmnivoreHuman = 1855

So probably the closest you could get to "Rotten corpses and nutrient paste" would be:
<foodType>Corpse, Processed</foodType>

Foodtypes are computed by adding their numerical values together to get a unique number. Everything after Kibble is just a "group" of other previous types. So some of these like "CarnivoreStrict(10)" is exactly the same as "Meat/2 + Corpse/8 " = 10. CarnivoreAnimal/2314 is the same as Kibble/2048 + Meal/256 + Corpse/8 + Meat/2... etc.

Thank you Thirite, sir! This is useful, very!
Now I wondered about new things which is if the strings in foodtype, has related tag to use in fooddef to make the system think it's part of a certain foodtype. But I think I can do small research on my own.

That unique arithmetic method of defining a diet seems interesting, I thought at first they were primary number at least not the one that is a sum, but it wasn't, they hide a secret pattern it seems :P

Edit: nvm, it was 2x (or rather 2(n-1))

harpo99999

it is a eleven bit BINARY bit pattern
eg 00100100100
the clue from the kibble of 2048(binary 10000000000) sets the maximum limits of the flag size

deliveryservice

Quote from: harpo99999 on November 30, 2016, 02:22:27 AM
it is a eleven bit BINARY bit pattern
eg 00100100100
the clue from the kibble of 2048(binary 10000000000) sets the maximum limits of the flag size

Interesting it seems to have a limit. But compared to using class, or array function, it's relatively compact. I love it.