Skip to content

Commit

Permalink
Professions can start with specific recipes (#68818)
Browse files Browse the repository at this point in the history
* Professions can start with specific recipes

* Trapper starts with Bear Trap recipe

* Fixed clang error, hopefully

* fixed static instance access error

* Update src/newcharacter.cpp

Co-authored-by: Anton Burmistrov <[email protected]>

* Update src/newcharacter.cpp

Co-authored-by: Anton Burmistrov <[email protected]>

* Update data/json/professions.json

* Update data/json/professions.json

---------

Co-authored-by: Anton Burmistrov <[email protected]>
Co-authored-by: Maleclypse <[email protected]>
  • Loading branch information
3 people authored Nov 24, 2023
1 parent a707f04 commit 5d3940a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions data/json/professions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3458,6 +3458,7 @@
"points": 3,
"skills": [ { "level": 6, "name": "traps" }, { "level": 4, "name": "survival" } ],
"proficiencies": [ "prof_fibers", "prof_fibers_rope", "prof_traps", "prof_trapsetting", "prof_knives_familiar" ],
"recipes": [ "beartrap" ],
"items": {
"both": {
"items": [
Expand Down
14 changes: 14 additions & 0 deletions src/newcharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,12 @@ void Character::initialize( bool learn_recipes )
add_proficiency( pri );
}

// Add profession recipes
for( const recipe_id &id : prof->recipes() ) {
const recipe &r = recipe_dictionary::get_craft( id->result() );
learn_recipe( &r );
}

// Add hobby proficiencies
set_proficiencies_from_hobbies();

Expand Down Expand Up @@ -2122,6 +2128,14 @@ static std::string assemble_profession_details( const avatar &u, const input_con
assembled += prof->name() + "\n";
}
}
// Recipes
std::vector<recipe_id> prof_recipe = sorted_profs[cur_id]->recipes();
if( !prof_recipe.empty() ) {
assembled += "\n" + colorize( _( "Profession recipes:" ), COL_HEADER ) + "\n";
for( const recipe_id &prof : prof_recipe ) {
assembled += prof->result_name() + "\n";
}
}
// Profession pet
if( !sorted_profs[cur_id]->pets().empty() ) {
assembled += "\n" + colorize( _( "Profession pets:" ), COL_HEADER ) + "\n";
Expand Down
6 changes: 6 additions & 0 deletions src/profession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ void profession::load( const JsonObject &jo, const std::string_view )
// TODO: use string_id<bionic_type> or so
optional( jo, was_loaded, "CBMs", _starting_CBMs, string_id_reader<::bionic_data> {} );
optional( jo, was_loaded, "proficiencies", _starting_proficiencies );
optional( jo, was_loaded, "recipes", _starting_recipes );
// TODO: use string_id<mutation_branch> or so
optional( jo, was_loaded, "traits", _starting_traits );
optional( jo, was_loaded, "forbidden_traits", _forbidden_traits,
Expand Down Expand Up @@ -553,6 +554,11 @@ std::vector<proficiency_id> profession::proficiencies() const
return _starting_proficiencies;
}

std::vector<recipe_id> profession::recipes() const
{
return _starting_recipes;
}

std::vector<matype_id> profession::ma_known() const
{
return _starting_martialarts;
Expand Down
2 changes: 2 additions & 0 deletions src/profession.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class profession
std::vector<addiction> _starting_addictions;
std::vector<bionic_id> _starting_CBMs;
std::vector<proficiency_id> _starting_proficiencies;
std::vector<recipe_id> _starting_recipes;
std::vector<trait_and_var> _starting_traits;
std::vector<matype_id> _starting_martialarts;
std::vector<matype_id> _starting_martialarts_choices;
Expand Down Expand Up @@ -118,6 +119,7 @@ class profession
std::vector<mtype_id> pets() const;
std::vector<bionic_id> CBMs() const;
std::vector<proficiency_id> proficiencies() const;
std::vector<recipe_id> recipes() const;
std::vector<matype_id> ma_known() const;
std::vector<matype_id> ma_choices() const;
int ma_choice_amount;
Expand Down

0 comments on commit 5d3940a

Please sign in to comment.