You can’t put C++ code from a .cpp file in a .json file. That will not work at all.
bio_ads is interesting, because the support code for it is actually in player::absorb_hit():
// The bio_ads CBM absorbs damage before hitting armor
if( has_active_bionic( bio_ads ) ) {
if( elem.amount > 0 && power_level > 24 ) {
if( elem.type == DT_BASH ) {
elem.amount -= rng( 1, 8 );
} else if( elem.type == DT_CUT ) {
elem.amount -= rng( 1, 4 );
} else if( elem.type == DT_STAB ) {
elem.amount -= rng( 1, 2 );
}
charge_power(-25);
}
if( elem.amount < 0 ) {
elem.amount = 0;
}
}
you would want similar code in the same place, but with a different check in the if statement, and draining UPS power instead of bionic charge.
You’d have to do a similar analysis for each behavior you wanted implemented: “how does the game do something similar? can I reuse that code as is? could I refactor that code so my thing could also use it? Should I just copy and change that code?”
For stat boosters, you’ll want to go to Character::reset_stats() and… wow, that code is not great. I would feel bad for recommending you copy that code.
Okay, for stat boosters, you’ll want to go to Character::reset_stats(), rewrite it to loop through all of the character’s traits, bionics, and items, and add or subtract the appropriate bonus or penalty from the thing in question. Then you’ll need to edit all of those things Json load functions, to parse and store a Json array that looks like “bonuses”: [ [ “stat_or_skill1”, NUM1 ], [ “stat_or_skill2”, NUM2 ] ] . And then you’ll need to through the existing traits and bionics .json files and add the bonus descriptors. And then after that, adding equipment bonuses will be easy, plus modding in new bonus mutations and bionics will be easier.