Skip to content

Commit

Permalink
fix disappearing NPCs
Browse files Browse the repository at this point in the history
See PR CleverRaven#39753 (fix disappearing travelling NPCs) and issue CleverRaven#39712

(cherry picked from commit 2999f7a)
  • Loading branch information
dpwb authored and tung committed Jun 26, 2020
1 parent 2fb2346 commit 0e9aff6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 25 deletions.
28 changes: 17 additions & 11 deletions src/faction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,13 +547,9 @@ int npc::faction_display( const catacurses::window &fac_w, const int width ) con
nc_color see_color;
bool u_has_radio = g->u.has_item_with_flag( "TWO_WAY_RADIO", true );
bool guy_has_radio = has_item_with_flag( "TWO_WAY_RADIO", true );
// TODO: NPCS on mission contactable same as travelling
if( has_companion_mission() && mission != NPC_MISSION_TRAVELLING ) {
can_see = _( "Not interactable while on a mission" );
see_color = c_light_red;
// is the NPC even in the same area as the player?
} else if( rl_dist( player_abspos, global_omt_location() ) > 3 ||
( rl_dist( g->u.pos(), pos() ) > SEEX * 2 || !g->u.sees( pos() ) ) ) {
// is the NPC even in the same area as the player?
if( rl_dist( player_abspos, global_omt_location() ) > 3 ||
( rl_dist( g->u.pos(), pos() ) > SEEX * 2 || !g->u.sees( pos() ) ) ) {
if( u_has_radio && guy_has_radio ) {
// TODO: better range calculation than just elevation.
int max_range = 200;
Expand Down Expand Up @@ -598,6 +594,11 @@ int npc::faction_display( const catacurses::window &fac_w, const int width ) con
can_see = _( "Within interaction range" );
see_color = c_light_green;
}
// TODO: NPCS on mission contactable same as traveling
if( has_companion_mission() ) {
can_see = _( "Press enter to recall from their mission." );
see_color = c_light_red;
}
mvwprintz( fac_w, point( width, ++y ), see_color, "%s", can_see );
nc_color status_col = col;
std::string current_status = _( "Status: " );
Expand Down Expand Up @@ -864,10 +865,15 @@ void faction_manager::display() const
selection--;
}
} else if( action == "CONFIRM" ) {
if( tab == tab_mode::TAB_FOLLOWERS && guy && ( interactable || radio_interactable ) ) {
guy->talk_to_u( false, radio_interactable );
} else if( tab == tab_mode::TAB_MYFACTION && camp ) {
camp->query_new_name();
if( guy->has_companion_mission() ) {
guy->reset_companion_mission();
popup( _( "%s returns from their mission" ), guy->disp_name() );
} else {
if( tab == tab_mode::TAB_FOLLOWERS && guy && ( interactable || radio_interactable ) ) {
guy->talk_to_u( false, radio_interactable );
} else if( tab == tab_mode::TAB_MYFACTION && camp ) {
camp->query_new_name();
}
}
} else if( action == "QUIT" ) {
break;
Expand Down
2 changes: 1 addition & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ void game::load_npcs()
if( temp->is_active() ) {
continue;
}
if( ( temp->has_companion_mission() ) && ( temp->mission != NPC_MISSION_TRAVELLING ) ) {
if( temp->has_companion_mission() ) {
continue;
}

Expand Down
16 changes: 3 additions & 13 deletions src/npctalk_funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ void talk_function::goto_location( npc &p )
add_msg( m_info, _( "That is not a valid destination for %s." ), p.disp_name() );
return;
}
p.set_companion_mission( p.global_omt_location(), "TRAVELLER", "travelling", destination );
p.set_mission( NPC_MISSION_TRAVELLING );
p.chatbin.first_topic = "TALK_FRIEND_GUARD";
p.guard_pos = npc::no_goal_point;
Expand All @@ -352,12 +351,6 @@ void talk_function::assign_guard( npc &p )
if( p.has_player_activity() ) {
p.revert_after_activity();
}

if( p.is_travelling() ) {
if( p.has_companion_mission() ) {
p.reset_companion_mission();
}
}
p.set_attitude( NPCATT_NULL );
p.set_mission( NPC_MISSION_GUARD_ALLY );
p.chatbin.first_topic = "TALK_FRIEND_GUARD";
Expand Down Expand Up @@ -385,12 +378,6 @@ void talk_function::assign_camp( npc &p )
if( p.has_player_activity() ) {
p.revert_after_activity();
}

if( p.is_travelling() ) {
if( p.has_companion_mission() ) {
p.reset_companion_mission();
}
}
p.chatbin.first_topic = "TALK_FRIEND_GUARD";
p.set_omt_destination();
temp_camp->job_assignment_ui();
Expand All @@ -408,6 +395,9 @@ void talk_function::stop_guard( npc &p )
add_msg( _( "%s begins to follow you." ), p.name );
p.set_mission( NPC_MISSION_NULL );
p.set_job( static_cast<npc_job>( 0 ) );
if( p.has_companion_mission() ) {
p.reset_companion_mission();
}
p.chatbin.first_topic = "TALK_FRIEND";
p.goal = npc::no_goal_point;
p.guard_pos = npc::no_goal_point;
Expand Down

0 comments on commit 0e9aff6

Please sign in to comment.