Skip to content

Commit

Permalink
Use whole-level floor opacity to streamline inter-faction agression c…
Browse files Browse the repository at this point in the history
…hecks
  • Loading branch information
kevingranade committed Sep 13, 2020
1 parent 76fff20 commit d6baa73
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/monmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ void monster::plan()
}
}

map &here = get_map();
std::bitset<OVERMAP_LAYERS> seen_levels = here.get_inter_level_visibility( pos().z );
fleeing = fleeing || ( mood == MATT_FLEE );
if( friendly == 0 ) {
for( const auto &fac_list : factions ) {
Expand All @@ -441,8 +443,10 @@ void monster::plan()
continue;
}

// TODO: Limit this to levels the monster can see.
for( auto &fac : fac_list.second ) {
if( !seen_levels.test( fac.first + OVERMAP_DEPTH ) ) {
continue;
}
for( const weak_ptr_fast<monster> &weak : fac.second ) {
const shared_ptr_fast<monster> shared = weak.lock();
if( !shared ) {
Expand Down Expand Up @@ -484,6 +488,9 @@ void monster::plan()
swarms = swarms && target == nullptr; // Only swarm if we have no target
if( group_morale || swarms ) {
for( auto &fac : myfaction_iter->second ) {
if( !seen_levels.test( fac.first + OVERMAP_DEPTH ) ) {
continue;
}
for( const weak_ptr_fast<monster> &weak : fac.second ) {
const shared_ptr_fast<monster> shared = weak.lock();
if( !shared ) {
Expand All @@ -510,7 +517,6 @@ void monster::plan()
}
}

map &here = get_map();
// Operating monster keep you safe while they operate, how nice....
if( type->has_special_attack( "OPERATE" ) ) {
if( has_effect( effect_operating ) ) {
Expand Down

0 comments on commit d6baa73

Please sign in to comment.