Skip to content

Commit

Permalink
Hobbies can give recipes (#79555)
Browse files Browse the repository at this point in the history
* Hobbies can give recipes

* Update src/newcharacter.cpp

Co-authored-by: Marc <altairre.atsu@gmail.com>

* Update src/newcharacter.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: Marc <altairre.atsu@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 7, 2025
1 parent 6f4035b commit c346c0b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -2507,6 +2507,7 @@ class Character : public Creature, public visitable
int get_proficiency_bonus( const std::string &category, proficiency_bonus_type prof_bonus ) const;
void add_default_background();
void set_proficiencies_from_hobbies();
void set_recipes_from_hobbies();

// tests only!
void set_proficiency_practice( const proficiency_id &id, const time_duration &amount );
Expand Down
13 changes: 13 additions & 0 deletions src/newcharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,16 @@ void Character::set_skills_from_hobbies( bool no_override )
}
}

void Character::set_recipes_from_hobbies()
{
for( const profession *profession : hobbies ) {
for( const recipe_id &recipeID : profession->recipes() ) {
const recipe &r = recipe_dictionary::get_craft( recipeID->result() );
learn_recipe( &r );
}
}
}

void Character::set_proficiencies_from_hobbies()
{
for( const profession *profession : hobbies ) {
Expand Down Expand Up @@ -995,6 +1005,9 @@ void Character::initialize( bool learn_recipes )
// Add hobby proficiencies
set_proficiencies_from_hobbies();

// Add hobby recipes
set_recipes_from_hobbies();

// Activate some mutations right from the start.
for( const trait_id &mut : get_mutations() ) {
const mutation_branch &branch = mut.obj();
Expand Down
1 change: 1 addition & 0 deletions src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ void npc::randomize( const npc_class_id &type, const npc_template_id &tem_id )
add_default_background();
set_skills_from_hobbies( true ); // Only trains skills that are still at 0 at this point
set_proficiencies_from_hobbies();
set_recipes_from_hobbies();
set_bionics_from_hobbies(); // Just in case, for mods
}

Expand Down

0 comments on commit c346c0b

Please sign in to comment.