# Adding flag to items dropped by killed zeds

**URL:** <https://discourse.cataclysmdda.org/t/adding-flag-to-items-dropped-by-killed-zeds/10673>\
**Category:** The Toolbox\
**Created:** [October 11, 2015, 4:01pm UTC](https://discourse.cataclysmdda.org/t/adding-flag-to-items-dropped-by-killed-zeds/10673 "2015-10-11T16:01:28Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Valiant](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/valiant/32/4788_2.png) [@Valiant](https://discourse.cataclysmdda.org/u/Valiant)\
**Post date:** [October 11, 2015, 4:01pm UTC](https://discourse.cataclysmdda.org/t/adding-flag-to-items-dropped-by-killed-zeds/10673/1 "2015-10-11T16:01:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kevin.granade](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/kevin.granade/32/1316_2.png) [@kevin.granade](https://discourse.cataclysmdda.org/u/kevin.granade)\
**Post date:** [October 11, 2015, 7:26pm UTC](https://discourse.cataclysmdda.org/t/adding-flag-to-items-dropped-by-killed-zeds/10673/2 "2015-10-11T19:26:22Z")

</div>

yes

---

<div class="post-metadata">

**Author:** ![Valiant](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/valiant/32/4788_2.png) [@Valiant](https://discourse.cataclysmdda.org/u/Valiant)\
**Post date:** [October 12, 2015, 4:46am UTC](https://discourse.cataclysmdda.org/t/adding-flag-to-items-dropped-by-killed-zeds/10673/3 "2015-10-12T04:46:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kevin.granade](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/kevin.granade/32/1316_2.png) [@kevin.granade](https://discourse.cataclysmdda.org/u/kevin.granade)\
**Post date:** [October 12, 2015, 5:57am UTC](https://discourse.cataclysmdda.org/t/adding-flag-to-items-dropped-by-killed-zeds/10673/4 "2015-10-12T05:57:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Valiant](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/valiant/32/4788_2.png) [@Valiant](https://discourse.cataclysmdda.org/u/Valiant)\
**Post date:** [October 12, 2015, 6:48am UTC](https://discourse.cataclysmdda.org/t/adding-flag-to-items-dropped-by-killed-zeds/10673/5 "2015-10-12T06:48:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Coolthulhu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/coolthulhu/32/2446_2.png) [@Coolthulhu](https://discourse.cataclysmdda.org/u/Coolthulhu)\
**Post date:** [October 12, 2015, 6:57am UTC](https://discourse.cataclysmdda.org/t/adding-flag-to-items-dropped-by-killed-zeds/10673/6 "2015-10-12T06:57:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Valiant](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/valiant/32/4788_2.png) [@Valiant](https://discourse.cataclysmdda.org/u/Valiant)\
**Post date:** [October 12, 2015, 7:05am UTC](https://discourse.cataclysmdda.org/t/adding-flag-to-items-dropped-by-killed-zeds/10673/7 "2015-10-12T07:05:05Z")

</div>

> [@Coolthulhu](#):
>
> 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.

I will try to go it this way.

> [@Coolthulhu](#):
>
> Note that filthy items will still be reduced to clean rags when cut.

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.

---

<div class="post-metadata">

**Author:** ![Litppunk](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/litppunk/32/409_2.png) [@Litppunk](https://discourse.cataclysmdda.org/u/Litppunk)\
**Post date:** [October 12, 2015, 7:56am UTC](https://discourse.cataclysmdda.org/t/adding-flag-to-items-dropped-by-killed-zeds/10673/8 "2015-10-12T07:56:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Valiant](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/valiant/32/4788_2.png) [@Valiant](https://discourse.cataclysmdda.org/u/Valiant)\
**Post date:** [October 14, 2015, 12:23pm UTC](https://discourse.cataclysmdda.org/t/adding-flag-to-items-dropped-by-killed-zeds/10673/9 "2015-10-14T12:23:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Coolthulhu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/coolthulhu/32/2446_2.png) [@Coolthulhu](https://discourse.cataclysmdda.org/u/Coolthulhu)\
**Post date:** [October 14, 2015, 1:57pm UTC](https://discourse.cataclysmdda.org/t/adding-flag-to-items-dropped-by-killed-zeds/10673/10 "2015-10-14T13:57:33Z")

</div>

> [@Valiant](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![Valiant](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/valiant/32/4788_2.png) [@Valiant](https://discourse.cataclysmdda.org/u/Valiant)\
**Post date:** [October 14, 2015, 2:29pm UTC](https://discourse.cataclysmdda.org/t/adding-flag-to-items-dropped-by-killed-zeds/10673/11 "2015-10-14T14:29:37Z")

</div>

But if I

> [@Coolthulhu](#):
>
> get the C++ sources and edit those, compile it, test it and PR the changes.

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

---

<div class="post-metadata">

**Author:** ![vache](https://avatars.discourse-cdn.com/v4/letter/v/ea666f/32.png) [@vache](https://discourse.cataclysmdda.org/u/vache)\
**Post date:** [October 14, 2015, 2:37pm UTC](https://discourse.cataclysmdda.org/t/adding-flag-to-items-dropped-by-killed-zeds/10673/12 "2015-10-14T14:37:32Z")

</div>

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