diff --git a/src/monmove.cpp b/src/monmove.cpp index e0d64eded8b4..d57eb6bbc39c 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -1252,6 +1252,12 @@ tripoint monster::scent_move() bestsmell = g->scent.get( pos() ); } + const scenttype_id player_scent = g->u.get_type_of_scent(); + // The main purpose of scent_move() is to either move toward scents or away from scents depending on the value of the fleeing flag. + // However, if the monster is a pet who is not actively fleeing and has the WONT_FOLLOW flag, we'd rather let it stumble instead of + // vaguely follow the player's scent. + const bool ignore_player_scent = !fleeing && is_pet() && has_flag( MF_PET_WONT_FOLLOW ); + tripoint next( -1, -1, posz() ); if( ( !fleeing && g->scent.get( pos() ) > smell_threshold ) || ( fleeing && bestsmell == 0 ) ) { @@ -1283,6 +1289,10 @@ tripoint monster::scent_move() right_scent = false; } + if( ignore_player_scent && type_scent == player_scent ) { + right_scent = false; + } + if( ( !fleeing && smell < bestsmell ) || ( fleeing && smell > bestsmell ) || !right_scent ) { continue; }