# How to add new CBMs

**URL:** <https://discourse.cataclysmdda.org/t/how-to-add-new-cbms/18213>\
**Category:** The Toolbox\
**Created:** [January 5, 2019, 11:37am UTC](https://discourse.cataclysmdda.org/t/how-to-add-new-cbms/18213 "2019-01-05T11:37:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fris0uman](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/fris0uman/32/8607_2.png) [@Fris0uman](https://discourse.cataclysmdda.org/u/Fris0uman)\
**Post date:** [January 5, 2019, 11:37am UTC](https://discourse.cataclysmdda.org/t/how-to-add-new-cbms/18213/1 "2019-01-05T11:37:37Z")

</div>

So I checked [Guide to adding new content to CDDA for first time modders](https://discourse.cataclysmdda.org/t/guide-to-adding-new-content-to-cdda-for-first-time-modders/17781) , JSON\_INFO and JSON\_FLAGS and bionics.cpp. But I didn’t find what I was looking for.

I’d like to add LED Tattoo as a cosmetic CBM that could also serve as a nightlight. But I don’t understand how to add the nightlight effect. CBM effect seems to be hardcoded in bionics.cpp so I tried to find how cranial flashlight works since I thought It would be similar to nightlight. But Its only flag is BIONIC\_TOGGLED which doesn’t specify what it does and in bionics.cpp under `player::activate_bionic` there’s no entry for `bio_flashlight`.

Can anyone help me to understand how this works ?

---

<div class="post-metadata">

**Author:** ![mlangsdorf](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mlangsdorf/32/2462_2.png) [@mlangsdorf](https://discourse.cataclysmdda.org/u/mlangsdorf)\
**Post date:** [January 5, 2019, 2:09pm UTC](https://discourse.cataclysmdda.org/t/how-to-add-new-cbms/18213/2 "2019-01-05T14:09:56Z")

</div>

The reason I didn’t provide much detail on CBMs is that CBMs effects are hardcoded, which means you need to know C++ programming to do much with them.

But let’s look at your question. First, let’s find out what the C++ code does with bio\_flashlight:

```auto
$ git grep -n bio_flashlight src
src/player.cpp:194:static const bionic_id bio_flashlight( "bio_flashlight" );
src/player.cpp:2645: if( lumination < 60 && has_active_bionic( bio_flashlight ) ) {

```

The first instance is clearly just a static definition and can be ignored.

The second one is more interesting:

```auto
float player::active_light() const
{
    float lumination = 0;

    int maxlum = 0;
    has_item_with( [&maxlum]( const item & it ) {
        const int lumit = it.getlight_emit();
        if( maxlum < lumit ) {
            maxlum = lumit;
        }
        return false; // continue search, otherwise has_item_with would cancel the search
    } );

    lumination = static_cast<float>( maxlum );

    if( lumination < 60 && has_active_bionic( bio_flashlight ) ) {
        lumination = 60;
    } else if( lumination < 25 && has_artifact_with( AEP_GLOW ) ) {
        lumination = 25;
    } else if( lumination < 5 && has_effect( effect_glowing ) ) {
        lumination = 5;
    }
    return lumination;
}

```

So that’s how a bionic flashlight works. You can either add a check for the bionic\_led\_tattoo here and give it some small level of lumination, or have the activated bionic\_led\_tattoo give the effect\_glowing effect.

Hope that helps. Learn to use command line git, because `git grep` is your friend for actual code development.

---

<div class="post-metadata">

**Author:** ![Fris0uman](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/fris0uman/32/8607_2.png) [@Fris0uman](https://discourse.cataclysmdda.org/u/Fris0uman)\
**Post date:** [January 5, 2019, 5:32pm UTC](https://discourse.cataclysmdda.org/t/how-to-add-new-cbms/18213/3 "2019-01-05T17:32:22Z")

</div>

Thanks a lot !  
Indeed `git grep` is pretty useful !
