diff --git a/doc/JSON_INFO.md b/doc/JSON_INFO.md index 1d11de1109c70..9d55fa5ad1717 100644 --- a/doc/JSON_INFO.md +++ b/doc/JSON_INFO.md @@ -585,6 +585,7 @@ This section describes each json file and their contents. Each json has their ow | stat_bonus | (_optional_) List of passive stat bonus. Stat are designated as follow: "DEX", "INT", "STR", "PER". | enchantments | (_optional_) List of enchantments applied by this CBM (see MAGIC.md for instructions on enchantment. NB: enchantments are not necessarily magic.) | learned_spells | (_optional_) Map of {spell:level} you gain when installing this CBM, and lose when you uninstall this CBM. Spell classes are automatically gained. +| learned_proficiencies | (_optional_) Array of proficiency ids you gain when installing this CBM, and lose when unintalling | installation_requirement | (_optional_) Requirment id pointing to a requirment defining the tools and componentsnt necessary to install this CBM. | vitamin_absorb_mod | (_optional_) Modifier to vitamin absorbtion, affects all vitamins. (default: `1.0`) diff --git a/src/bionics.cpp b/src/bionics.cpp index da90577cd3d89..51eb85a51addb 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -291,6 +291,7 @@ void bionic_data::load( const JsonObject &jsobj, const std::string & ) optional( jsobj, was_loaded, "is_remote_fueled", is_remote_fueled ); optional( jsobj, was_loaded, "learned_spells", learned_spells ); + optional( jsobj, was_loaded, "learned_proficiencies", proficiencies ); optional( jsobj, was_loaded, "canceled_mutations", canceled_mutations ); optional( jsobj, was_loaded, "included_bionics", included_bionics ); optional( jsobj, was_loaded, "included", included ); @@ -2692,6 +2693,10 @@ void Character::add_bionic( const bionic_id &b ) } } + for( const proficiency_id &learned : b->proficiencies ) { + add_proficiency( learned ); + } + calc_encumbrance(); recalc_sight_limits(); if( !b->enchantments.empty() ) { @@ -2728,6 +2733,10 @@ void Character::remove_bionic( const bionic_id &b ) } } + for( const proficiency_id &lost : b->proficiencies ) { + lose_proficiency( lost ); + } + *my_bionics = new_my_bionics; calc_encumbrance(); recalc_sight_limits(); diff --git a/src/bionics.h b/src/bionics.h index 97b31da691419..9c5b49eb91d46 100644 --- a/src/bionics.h +++ b/src/bionics.h @@ -88,6 +88,11 @@ struct bionic_data { std::vector enchantments; cata::value_ptr spell_on_activate; + + /** + * Proficiencies given on install (and removed on uninstall) of this bionic + */ + std::vector proficiencies; /** * Body part slots used to install this bionic, mapped to the amount of space required. */ diff --git a/src/character.cpp b/src/character.cpp index 2c38b8c9b8469..30e00319af8c5 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -11413,6 +11413,11 @@ void Character::add_proficiency( const proficiency_id &prof ) _proficiencies.insert( prof ); } +void Character::lose_proficiency( const proficiency_id &prof ) +{ + _proficiencies.erase( prof ); +} + const std::set &Character::proficiencies() const { return _proficiencies; diff --git a/src/character.h b/src/character.h index 3e9f10f366bd1..0f7959db8a39a 100644 --- a/src/character.h +++ b/src/character.h @@ -1581,6 +1581,7 @@ class Character : public Creature, public visitable // (bit short at the moment) bool has_proficiency( const proficiency_id &prof ) const; void add_proficiency( const proficiency_id &prof ); + void lose_proficiency( const proficiency_id &prof ); const std::set &proficiencies() const; // --------------- Other Stuff ---------------