Skip to content

Commit

Permalink
Merge pull request #35354 from CleverRaven/basecamp_all_missions
Browse files Browse the repository at this point in the history
basecamps: all missions from any expansion
  • Loading branch information
ZhilkinSerg authored Nov 7, 2019
2 parents e67ea0b + b10ecea commit 16728ff
Show file tree
Hide file tree
Showing 6 changed files with 476 additions and 486 deletions.
2 changes: 2 additions & 0 deletions src/avatar.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ class avatar : public player
int kill_xp() const;

faction *get_faction() const override;
// Set in npc::talk_to_you for use in further NPC interactions
bool dialogue_by_radio = false;

void set_movement_mode( character_movemode mode ) override;

Expand Down
23 changes: 13 additions & 10 deletions src/basecamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ std::string basecamp::board_name() const
return string_format( _( "%s Board" ), name );
}

void basecamp::set_by_radio( bool access_by_radio )
{
by_radio = access_by_radio;
}

// read an expansion's terrain ID of the form faction_base_$TYPE_$CURLEVEL
// find the last underbar, strip off the prefix of faction_base_ (which is 13 chars),
// and the pull out the $TYPE and $CURLEVEL
Expand All @@ -144,9 +149,8 @@ void basecamp::add_expansion( const std::string &terrain, const tripoint &new_po

const point dir = talk_function::om_simple_dir( omt_pos, new_pos );
expansions[ dir ] = parse_expansion( terrain, new_pos );
bool by_radio = rl_dist( g->u.global_omt_location(), omt_pos ) > 2;
resources_updated = false;
reset_camp_resources( by_radio );
reset_camp_resources();
update_provides( terrain, expansions[ dir ] );
directions.push_back( dir );
}
Expand Down Expand Up @@ -433,7 +437,7 @@ void basecamp::update_in_progress( const std::string &bldg, const point &dir )
}
}

void basecamp::reset_camp_resources( bool by_radio )
void basecamp::reset_camp_resources()
{
reset_camp_workers();
if( !resources_updated ) {
Expand All @@ -452,7 +456,7 @@ void basecamp::reset_camp_resources( bool by_radio )
}
}
}
form_crafting_inventory( by_radio );
form_crafting_inventory();
}

// available companion list manipulation
Expand Down Expand Up @@ -568,8 +572,7 @@ std::list<item> basecamp::use_charges( const itype_id &fake_id, int &quantity )
return ret;
}

void basecamp::consume_components( map &target_map, const recipe &making, int batch_size,
bool by_radio )
void basecamp::consume_components( map &target_map, const recipe &making, int batch_size )
{
const tripoint &origin = target_map.getlocal( get_dumping_spot() );
const auto &req = making.requirements();
Expand All @@ -592,15 +595,15 @@ void basecamp::consume_components( map &target_map, const recipe &making, int ba
}
}

void basecamp::consume_components( const recipe &making, int batch_size, bool by_radio )
void basecamp::consume_components( const recipe &making, int batch_size )
{
if( by_radio ) {
tinymap target_map;
target_map.load( tripoint( omt_pos.x * 2, omt_pos.y * 2, omt_pos.z ), false );
consume_components( target_map, making, batch_size, by_radio );
consume_components( target_map, making, batch_size );
target_map.save();
} else {
consume_components( g->m, making, batch_size, by_radio );
consume_components( g->m, making, batch_size );
}
}

Expand Down Expand Up @@ -656,7 +659,7 @@ void basecamp::form_crafting_inventory( map &target_map )
}
}

void basecamp::form_crafting_inventory( const bool by_radio )
void basecamp::form_crafting_inventory()
{
if( by_radio ) {
tinymap target_map;
Expand Down
37 changes: 17 additions & 20 deletions src/basecamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ class basecamp
inline const std::string &camp_name() const {
return name;
}
void set_by_radio( bool access_by_radio );

std::string board_name() const;
std::vector<point> directions;
std::vector<tripoint> fortifications;
Expand Down Expand Up @@ -186,12 +188,11 @@ class basecamp
// from a building
std::map<recipe_id, translation> recipe_deck( const std::string &bldg ) const;
int recipe_batch_max( const recipe &making ) const;
void form_crafting_inventory( bool by_radio = false );
void form_crafting_inventory();
void form_crafting_inventory( map &target_map );
std::list<item> use_charges( const itype_id &fake_id, int &quantity );
void consume_components( const recipe &making, int batch_size, bool by_radio = false );
void consume_components( map &target_map, const recipe &making, int batch_size,
bool by_radio = false );
void consume_components( const recipe &making, int batch_size = false );
void consume_components( map &target_map, const recipe &making, int batch_size );
std::string get_gatherlist() const;
/**
* spawn items or corpses based on search attempts
Expand All @@ -201,8 +202,7 @@ class basecamp
* @param difficulty a random number from 0 to difficulty is created for each attempt, and
* if skill is higher, an item or corpse is spawned
*/
void search_results( int skill, const Group_tag &group_id, int attempts, int difficulty,
bool by_radio = false );
void search_results( int skill, const Group_tag &group_id, int attempts, int difficulty );
/**
* spawn items or corpses based on search attempts
* @param skill skill level of the search
Expand All @@ -212,16 +212,15 @@ class basecamp
* @param difficulty a random number from 0 to difficulty is created for each attempt, and
* if skill is higher, an item or corpse is spawned
*/
void hunting_results( int skill, const std::string &task, int attempts, int difficulty,
bool by_radio = false );
void hunting_results( int skill, const std::string &task, int attempts, int difficulty );
inline const tripoint &get_dumping_spot() const {
return dumping_spot;
}
// dumping spot in absolute co-ords
inline void set_dumping_spot( const tripoint &spot ) {
dumping_spot = spot;
}
void place_results( item result, bool by_radio );
void place_results( item result );

// mission description functions
void add_available_recipes( mission_data &mission_key, const point &dir,
Expand All @@ -240,13 +239,13 @@ class basecamp
std::string craft_description( const recipe_id &itm );

// main mission description collection
void get_available_missions( mission_data &mission_key, bool by_radio = false );
void get_available_missions( mission_data &mission_key );
void get_available_missions_by_dir( mission_data &mission_key, const point &dir );
// available companion list manipulation
void reset_camp_workers();
comp_list get_mission_workers( const std::string &mission_id, bool contains = false );
// main mission start/return dispatch function
bool handle_mission( const std::string &miss_id, cata::optional<point> miss_dir,
bool by_radio = false );
bool handle_mission( const std::string &miss_id, cata::optional<point> opt_miss_dir );

// mission start functions
/// generic mission start function that wraps individual mission
Expand All @@ -258,22 +257,20 @@ class basecamp
bool must_feed, const std::string &desc, bool group,
const std::vector<item *> &equipment,
const std::map<skill_id, int> &required_skills = {} );
void start_upgrade( const std::string &bldg, const point &dir, const std::string &key,
bool by_radio );
void start_upgrade( const std::string &bldg, const point &dir, const std::string &key );
std::string om_upgrade_description( const std::string &bldg, bool trunc = false ) const;
void start_menial_labor();
void job_assignment_ui();
void start_crafting( const std::string &cur_id, const point &cur_dir,
const std::string &type, const std::string &miss_id,
bool by_radio = false );
const std::string &type, const std::string &miss_id );

/// Called when a companion is sent to cut logs
void start_cut_logs();
void start_clearcut();
void start_setup_hide_site();
void start_relay_hide_site();
/// Called when a compansion is sent to start fortifications
void start_fortifications( std::string &bldg_exp, bool by_radio );
void start_fortifications( std::string &bldg_exp );
void start_combat_mission( const std::string &miss );
/// Called when a companion starts a chop shop @ref task mission
bool start_garage_chop( const point &dir, const tripoint &omt_tgt );
Expand Down Expand Up @@ -306,8 +303,7 @@ class basecamp
bool survey_return();
bool menial_return();
/// Called when a companion completes a gathering @ref task mission
bool gathering_return( const std::string &task, time_duration min_time,
bool by_radio = false );
bool gathering_return( const std::string &task, time_duration min_time );
void recruit_return( const std::string &task, int score );
/**
* Perform any mix of the three farm tasks.
Expand All @@ -327,7 +323,7 @@ class basecamp
void load_data( const std::string &data );
private:
// lazy re-evaluation of available camp resources
void reset_camp_resources( bool by_radio = false );
void reset_camp_resources();
void add_resource( const itype_id &camp_resource );
bool resources_updated = false;
// omt pos
Expand All @@ -344,6 +340,7 @@ class basecamp
std::vector<basecamp_resource> resources;
static const int range = 20;
inventory _inv;
bool by_radio;
};

#endif
Loading

0 comments on commit 16728ff

Please sign in to comment.