Skip to content

Commit

Permalink
Bug fix and npc los
Browse files Browse the repository at this point in the history
  • Loading branch information
joveeater committed Jul 28, 2022
1 parent 7f440e2 commit 217756b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8158,7 +8158,7 @@ void map::do_vehicle_caching( int z )
for( vehicle *v : ch.vehicle_list ) {
for( const vpart_reference &vp : v->get_all_parts() ) {
const tripoint &part_pos = v->global_part_pos3( vp.part() );
if( !inbounds( part_pos.xy() ) ) {
if( !inbounds( part_pos.xy() ) || vp.part().removed ) {
continue;
}
vehicle_caching_internal( get_cache( part_pos.z ), vp, v );
Expand Down
10 changes: 9 additions & 1 deletion src/npcmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,25 @@ bool compare_sound_alert( const dangerous_sound &sound_a, const dangerous_sound
static bool clear_shot_reach( const tripoint &from, const tripoint &to, bool check_ally = true )
{
std::vector<tripoint> path = line_to( from, to );
tripoint target_point = path.back();
path.pop_back();
if( path.empty() ) {
return true;
}
tripoint &last_point = path[0];
for( const tripoint &p : path ) {
Creature *inter = g->critter_at( p );
if( check_ally && inter != nullptr ) {
return false;
} else if( get_map().impassable( p ) ) {
return false;
} else if( get_map().obstructed_by_vehicle_rotation( last_point, p ) ) {
return false;
}
last_point = p;
}

return true;
return !get_map().obstructed_by_vehicle_rotation( last_point, target_point );
}

tripoint npc::good_escape_direction( bool include_pos )
Expand Down

0 comments on commit 217756b

Please sign in to comment.