Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abandon camp NPC talk and bulletin board mission #36697

Merged
merged 7 commits into from Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -144,6 +144,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
27 changes: 27 additions & 0 deletions src/faction_camp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,9 @@ 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" );
"Abandon this camp" ) );
This conversation was marked as resolved.
Show resolved Hide resolved
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 +1322,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 @@ -1561,6 +1567,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