Adding flag to items dropped by killed zeds

Is it possible to add flag to items only if they are dropped by killed zeds?

yes

Uhm, need some help with code for this. Also, where the code should be located?

It would be much easier to help you with your problem if you explained what it is rather than asking questions with no context.

Items are dropped in monster.cpp in the method monster::drop_items_on_death() when it calls map::put_items_from_loc(), which returns a vector of pointers to the dropped items. You can use that vector to manipulate the items after they are placed.

If you need any more help, you’re going to need to explain your problem in more detail.

I plan to make a mod that adds “squeamish” trait. All clothing that were dropped by zeds will have some flag, let’s say “Filthy”. It will prevent characters with aforementioned trait to wear it, much like wool allergy prevents from wearing items made of wool (or maybe it will give huge morale penalty for wearing it).
I suppose all this information should be in The Lab, but I have some coding difficulties.
I understand how to add flag and how to add trait (sort of). But I failed when I tried to look into a matter of dropping items and adding flag to them.

The way I understand it, the question is about modding an item group to spawn items with flags inserted. Which, to my knowledge, isn’t possible at the moment without changes to code itself.

item_group.h has Item_modifier class, which contains fields like damage, charges, contents etc., but no flags or properties.

[quote=“Valiant, post:5, topic:10673”]I plan to make a mod that adds “squeamish” trait. All clothing that were dropped by zeds will have some flag, let’s say “Filthy”. It will prevent characters with aforementioned trait to wear it, much like wool allergy prevents from wearing items made of wool (or maybe it will give huge morale penalty for wearing it).
I suppose all this information should be in The Lab, but I have some coding difficulties.
I understand how to add flag and how to add trait (sort of). But I failed when I tried to look into a matter of dropping items and adding flag to them.[/quote]

The only easy way I see to add it would be to edit monster::drop_items_on_death(), check for some sort of “filthy_monster” flag there, then add it to all armors dropped.

Note that filthy items will still be reduced to clean rags when cut.

I will try to go it this way.

Maybe I’ll add items like “filthy rag”, “filthy leather patch” etc. Or maybe (more probable) assume that when cutting clothing out, player will take all the filth away.

perhaps you can program some beloved RNG in there so when (filthy) flagged items are cut once the number of rags is decided it is then split randomly for clean and filthy rags

One more question: to modify source code for my mod, I have to use Lua?

Lua isn’t enough. You need to get the C++ sources and edit those, compile it, test it and PR the changes.

But if I

it will be in master, right? How should I edit sources so they fit namely my mod, not the master?

Can’t be done. But, the main game can have code that is only used by mods.