Skip to content

Commit

Permalink
fix set_npc_allies_global (#58082)
Browse files Browse the repository at this point in the history
  • Loading branch information
c8060da authored Jun 2, 2022
1 parent 9301c86 commit f841d7b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,17 +773,16 @@ void conditional_t<T>::set_npc_allies( const JsonObject &jo )
template<class T>
void conditional_t<T>::set_npc_allies_global( const JsonObject &jo )
{
int_or_var iov = get_int_or_var( jo, "npc_allies_global" );
int_or_var<T> iov = get_int_or_var<T>( jo, "npc_allies_global" );

condition = [iov]( const T & d ) {
const auto all_npcs = overmap_buffer.get_overmap_npcs();
const size_t count = std::count_if( all_npcs.begin(),
all_npcs.end(), []( const shared_ptr_fast<npc> &ptr ) {
// Note: it seems that the is_npc check /is/ necessary to avoid including dead friends
return ptr.get()->is_player_ally() && !ptr.get()->hallucination && ptr.get()->is_npc();
return ptr.get()->is_player_ally() && !ptr.get()->hallucination && !ptr.get()->is_dead();
} );

return count >= static_cast<size_t>( iov.evaluate( d.actor( iov.is_npc() ) ) );
return count >= static_cast<size_t>( iov.evaluate( d ) );
};
}

Expand Down

0 comments on commit f841d7b

Please sign in to comment.