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

fix disappearing NPCs #39753

Merged
merged 1 commit into from Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
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 traveling
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 @@ -892,10 +893,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 @@ -955,7 +955,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 @@ -342,7 +342,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(), "TRAVELER", "traveling", destination );
p.set_mission( NPC_MISSION_TRAVELLING );
p.chatbin.first_topic = "TALK_FRIEND_GUARD";
p.guard_pos = npc::no_goal_point;
Expand All @@ -360,12 +359,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 @@ -395,12 +388,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();
}
Expand All @@ -416,6 +403,9 @@ void talk_function::stop_guard( npc &p )
p.set_attitude( NPCATT_FOLLOW );
add_msg( _( "%s begins to follow you." ), p.name );
p.set_mission( NPC_MISSION_NULL );
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