Skip to content

Commit

Permalink
Merge pull request #42582 from anothersimulacrum/implantme
Browse files Browse the repository at this point in the history
Allow bionics to teach proficiencies
  • Loading branch information
ZhilkinSerg authored Jul 31, 2020
2 parents eef9d95 + fa1bb07 commit afa58f5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)

Expand Down
9 changes: 9 additions & 0 deletions src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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() ) {
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions src/bionics.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ struct bionic_data {
std::vector<enchantment_id> enchantments;

cata::value_ptr<fake_spell> spell_on_activate;

/**
* Proficiencies given on install (and removed on uninstall) of this bionic
*/
std::vector<proficiency_id> proficiencies;
/**
* Body part slots used to install this bionic, mapped to the amount of space required.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<proficiency_id> &Character::proficiencies() const
{
return _proficiencies;
Expand Down
1 change: 1 addition & 0 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,7 @@ class Character : public Creature, public visitable<Character>
// (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<proficiency_id> &proficiencies() const;

// --------------- Other Stuff ---------------
Expand Down

0 comments on commit afa58f5

Please sign in to comment.