Skip to content

Commit

Permalink
fix(dialogue conditions): at_om_location handling directional OMTs
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Langsdorf <mark.langsdorf@gmail.com>
  • Loading branch information
2 people authored and scarf005 committed Mar 2, 2024
1 parent fbeb2ba commit 5b10848
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,20 +392,19 @@ void conditional_t<T>::set_at_om_location( const JsonObject &jo, const std::stri
}
const tripoint_abs_omt omt_pos = actor->global_omt_location();
const oter_id &omt_ref = overmap_buffer.ter( omt_pos );
const std::string &omt_str = omt_ref.id().c_str();

if( location == "FACTION_CAMP_ANY" ) {
std::optional<basecamp *> bcp = overmap_buffer.find_camp( omt_pos.xy() );
if( bcp ) {
return true;
}
// legacy check
const std::string &omt_str = omt_ref.id().c_str();
return omt_str.find( "faction_base_camp" ) != std::string::npos;
} else if( location == "FACTION_CAMP_START" ) {
return !recipe_group::get_recipes_by_id( "all_faction_base_types",
omt_ref.id().c_str() ).empty();
} else {
return omt_ref == oter_id( oter_no_dir( oter_id( location ) ) );
return oter_no_dir( omt_ref ) == location;
}
};
}
Expand Down
4 changes: 4 additions & 0 deletions tests/npc_talk_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ TEST_CASE( "npc_talk_location", "[npc_talk]" )
gen_response_lines( d, 2 );
CHECK( d.responses[0].text == "This is a basic test response." );
CHECK( d.responses[1].text == "This is a faction camp any test response." );
change_om_type( "evac_center_7_west" );
gen_response_lines( d, 2 );
CHECK( d.responses[0].text == "This is a basic test response." );
CHECK( d.responses[1].text == "This is a om_location_field direction variant response." );
}

TEST_CASE( "npc_talk_role", "[npc_talk]" )
Expand Down

0 comments on commit 5b10848

Please sign in to comment.