Skip to content

Commit

Permalink
Update npcmove.cpp
Browse files Browse the repository at this point in the history
Co-authored-by: David Seguin <davidseguin@live.ca>
  • Loading branch information
2 people authored and scarf005 committed Feb 14, 2024
1 parent 038f44b commit c90932a
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/npcmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4260,24 +4260,25 @@ void npc::set_omt_destination()

std::string dest_type;
for( const auto &fulfill : needs ) {
// look for the closest occurence of any of that locations terrain types
std::vector<oter_type_id> loc_list = get_location_for( fulfill )->get_all_terrains();
std::shuffle( loc_list.begin(), loc_list.end(), rng_get_engine() );
omt_find_params find_params;
std::vector<std::pair<std::string, ot_match_type>> temp_types;
for( const oter_type_id &elem : loc_list ) {
std::pair<std::string, ot_match_type> temp_pair;
temp_pair.first = elem.id().str();
temp_pair.second = ot_match_type::type;
temp_types.push_back( temp_pair );
}
find_params.search_range = 75;
find_params.min_distance = 0;
find_params.must_see = false;
find_params.cant_see = false;
find_params.types = temp_types;
find_params.existing_only = false;
goal = overmap_buffer.find_closest( surface_omt_loc, find_params );
auto cache_iter = goal_cache.find( fulfill );
if( cache_iter != goal_cache.end() && cache_iter->second.omt_loc == surface_omt_loc ) {
goal = cache_iter->second.goal;
} else {
// look for the closest occurrence of any of that locations terrain types
omt_find_params find_params;
for( const oter_type_id &elem : get_location_for( fulfill )->get_all_terrains() ) {
std::pair<std::string, ot_match_type> temp_pair;
temp_pair.first = elem.id().str();
temp_pair.second = ot_match_type::type;
find_params.types.push_back( temp_pair );
}
find_params.search_range = 75;
find_params.existing_only = false;
goal = overmap_buffer.find_closest( surface_omt_loc, find_params );
npc_need_goal_cache &cache = goal_cache[fulfill];
cache.goal = goal;
cache.omt_loc = surface_omt_loc;
}
omt_path.clear();
if( goal != overmap::invalid_tripoint ) {
omt_path = overmap_buffer.get_travel_path( surface_omt_loc, goal, overmap_path_params::for_npc() );
Expand Down

0 comments on commit c90932a

Please sign in to comment.