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

fix: pets with MF_PET_WONT_FOLLOW flag don't follow player #4332

Merged
merged 1 commit into from
Mar 10, 2024
Merged
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
10 changes: 10 additions & 0 deletions src/monmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand Down Expand Up @@ -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;
}
Expand Down
Loading