Code for butchering

Hi,

so, I am trying to figure out the butchering code in order to eventually add more butchering products.

if (fats > 0) { if (corpse->has_flag(MF_FAT)) { m.spawn_item(u.posx, u.posy, "fat", fats, 0, age); add_msg(m_good, _("You harvest some fat!")); }

This is the code in game.cpp, that handles fat being spawned after butchery. My question here is now, do I have to define the flag “MF_FAT” somewhere? Or is it automatically done for the corpse, as long as I give the monster in its json the flag “FAT”?

I might have more consecutive questions, but please answer me this one first, if possible.

do I have to define the flag "MF_FAT" somewhere?
It is already defined somewhere, otherwise the compiler would complain.

Have you looked up what [tt]corpse[/tt] is and where it comes from? Just in case, it’s a pointer to a monster type ([tt]mtype[/tt]), which is loaded from json, see monstergenerator.cpp - it also contains the logic to load those flags from json.

Or is it automatically done for the corpse, as long as I give the monster in its json the flag "FAT"?
As long as there is a translation entry in [tt]flag_map[/tt] (which translates the flag [i]string[/i] (from json) into the C++ [i]enumeration value[/i]), the flag will be loaded from the json and [b]added[/b] to the monster type definition. Than it's also present in the butchering code.

And in case you want to add a new flag, you have to define it in mtype.h and you have to add an entry in the [tt]flag_map[/tt].

Ah, BevapDin, you’re the best!

I couldn’t figure out that monstergenerator.cpp was the thing I was looking for.

Now, for further work, if I wanted to add a hypothetical flag [“TAINTED_BUTCHER”] for zombies to drop "tainted bones"and “tainted fat”, I’d have to give the zombies in their jsons the “TAINTED_BUTCHER” flag, add the “translation” to monstergenerator.cpp (?)and then also define the “MF_TAINTED_BUTCHER” in the mtype.h.