Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPC AI logic and test issues #27438

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/npcmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2440,10 +2440,11 @@ bool npc::wield_better_weapon()
bool npc::scan_new_items()
{
add_msg( m_debug, "%s scanning new items", name.c_str() );
if( !wield_better_weapon() ) {
if( wield_better_weapon() ) {
return true;
} else {
// Stop "having new items" when you no longer do anything with them
has_new_items = false;
return true;
}

return false;
Expand Down
5 changes: 5 additions & 0 deletions tests/npc_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ static void check_npc_movement( const tripoint &origin )
switch( setup[y][x] ) {
case 'W':
case 'M':
CAPTURE( setup[y][x] );
tripoint p = origin + point( x, y );
npc *guy = g->critter_at<npc>( p );
CHECK( guy != nullptr );
Expand Down Expand Up @@ -352,6 +353,10 @@ TEST_CASE( "npc-movement" )
guy->normalize();
guy->randomize();
guy->spawn_at_precise( {g->get_levx(), g->get_levy()}, p );
// Set the shopkeep mission; this means that
// the NPC deems themselves to be guarding and stops them
// wandering off in search of distant ammo caches, etc.
guy->mission = NPC_MISSION_SHOPKEEP;
overmap_buffer.insert_npc( guy );
g->load_npcs();
guy->set_attitude( ( type == 'M' || type == 'C' ) ? NPCATT_NULL : NPCATT_FOLLOW );
Expand Down