Skip to content

Commit

Permalink
Abandon camp NPC talk and bulletin board mission (#36697)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpwbrown authored and ZhilkinSerg committed Jan 7, 2020
1 parent 9c6802b commit 88009f4
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 3 deletions.
6 changes: 6 additions & 0 deletions data/json/npcs/TALK_FACTION_CAMP.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
"switch": true,
"default": true
},
{
"text": "We need to abandon this camp.",
"condition": { "npc_at_om_location": "FACTION_CAMP_ANY" },
"topic": "TALK_DONE",
"effect": "abandon_camp"
},
{
"text": "Show me what needs to be done at the camp.",
"topic": "TALK_DONE",
Expand Down
1 change: 1 addition & 0 deletions src/basecamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class basecamp
//change name of camp
void set_name( const std::string &new_name );
void query_new_name();
void abandon_camp();
void add_expansion( const std::string &terrain, const tripoint &new_pos );
void add_expansion( const std::string &bldg, const tripoint &new_pos,
const point &dir );
Expand Down
26 changes: 26 additions & 0 deletions src/faction_camp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,8 @@ void basecamp::get_available_missions( mission_data &mission_key )
"\n\nRisk: None\n"
"Time: Ongoing" ) );
mission_key.add( "Assign Jobs", _( "Assign Jobs" ), entry );
entry = _( "Notes:\nAbandon this camp" );
mission_key.add( "Abandon Camp", _( "Abandon Camp" ), entry );
}
// Missions assigned to the central tile that could be done by an expansion
get_available_missions_by_dir( mission_key, base_camps::base_dir );
Expand Down Expand Up @@ -1319,6 +1321,9 @@ bool basecamp::handle_mission( const std::string &miss_id, cata::optional<point>
if( miss_id == "Assign Jobs" ) {
job_assignment_ui();
}
if( miss_id == "Abandon Camp" ) {
abandon_camp();
}

if( miss_id == "Expand Base" ) {
start_mission( "_faction_camp_expansion", 3_hours, true,
Expand Down Expand Up @@ -1566,6 +1571,27 @@ void basecamp::start_upgrade( const std::string &bldg, const point &dir,
}
}

void basecamp::abandon_camp()
{
validate_assignees();
npc_ptr random_guy;
for( npc_ptr &guy : overmap_buffer.get_companion_mission_npcs( 10 ) ) {
npc_companion_mission c_mission = guy->get_companion_mission();
if( c_mission.role_id != base_camps::id ) {
continue;
}
random_guy = guy;
const std::string return_msg = _( "responds to the emergency recall…" );
finish_return( *guy, false, return_msg, "menial", 0, true );
}
for( npc_ptr &guy : get_npcs_assigned() ) {
talk_function::stop_guard( *guy );
}
overmap_buffer.remove_camp( *this );
g->m.remove_submap_camp( random_guy->pos() );
add_msg( m_info, _( "You abandon %s." ), name );
}

void basecamp::job_assignment_ui()
{
int term_x = TERMY > FULL_SCREEN_HEIGHT ? ( TERMY - FULL_SCREEN_HEIGHT ) / 2 : 0;
Expand Down
1 change: 1 addition & 0 deletions src/npctalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2571,6 +2571,7 @@ void talk_effect_t::parse_string_effect( const std::string &effect_id, const Jso
WRAP( do_farming ),
WRAP( assign_guard ),
WRAP( assign_camp ),
WRAP( abandon_camp ),
WRAP( stop_guard ),
WRAP( start_camp ),
WRAP( buy_cow ),
Expand Down
1 change: 1 addition & 0 deletions src/npctalk.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void goto_location( npc & );
void assign_base( npc & );
void assign_guard( npc & );
void assign_camp( npc & );
void abandon_camp( npc & );
void stop_guard( npc & );
void end_conversation( npc & );
void insult_combat( npc & );
Expand Down
9 changes: 9 additions & 0 deletions src/npctalk_funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,15 @@ void talk_function::assign_guard( npc &p )
p.set_omt_destination();
}

void talk_function::abandon_camp( npc &p )
{
cata::optional<basecamp *> bcp = overmap_buffer.find_camp( p.global_omt_location().xy() );
if( bcp ) {
basecamp *temp_camp = *bcp;
temp_camp->abandon_camp();
}
}

void talk_function::assign_camp( npc &p )
{
cata::optional<basecamp *> bcp = overmap_buffer.find_camp( p.global_omt_location().xy() );
Expand Down
4 changes: 2 additions & 2 deletions src/overmapbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1089,11 +1089,11 @@ std::vector<overmap *> overmapbuffer::get_overmaps_near( const point &p, const i
return get_overmaps_near( tripoint( p, 0 ), radius );
}

std::vector<shared_ptr_fast<npc>> overmapbuffer::get_companion_mission_npcs()
std::vector<shared_ptr_fast<npc>> overmapbuffer::get_companion_mission_npcs( int range )
{
std::vector<shared_ptr_fast<npc>> available;
// TODO: this is an arbitrary radius, replace with something sane.
for( const auto &guy : get_npcs_near_player( 100 ) ) {
for( const auto &guy : get_npcs_near_player( range ) ) {
if( guy->has_companion_mission() ) {
available.push_back( guy );
}
Expand Down
2 changes: 1 addition & 1 deletion src/overmapbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class overmapbuffer
* Get all (currently loaded!) npcs that have a companion
* mission set.
*/
std::vector<shared_ptr_fast<npc>> get_companion_mission_npcs();
std::vector<shared_ptr_fast<npc>> get_companion_mission_npcs( int range = 100 );
/**
* Uses overmap terrain coordinates, this also means radius is
* in overmap terrain.
Expand Down

0 comments on commit 88009f4

Please sign in to comment.