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

Conversation

ekaratzas
Copy link
Contributor

@ekaratzas ekaratzas commented Mar 10, 2024

THe root-cause for pets always following player regardless of MF_PET_WONT_FOLLOW flag was found in move_scent() which caused non fleeing creatures to gravitate towards the scent of the player, ignoring the wont-follow flag.

Purpose of change

Fixes #4331

This is a fix for the bug where pets with WONT_FOLLOW flag actually end up following the player anyway.

Describe the solution

The rootcause lied in move_scent() which makes non fleeing pets follow the scent of the player, thus ignoring the WONT_FOLLOW flag. The fix works by making monsters ignore the player's scent if the monsters:

  • are not fleeing
  • are pets
  • have the PET_WONT_FOLLOW flag

Other than that specific corner-case, smell-based mechanics remain unaffected for monsters.

Describe alternatives you've considered

I don't think this is fixed in cdda as far as I cant tell so no fix to copy from there. I initially had a more blunt fix that simply returned from move_scent() in case it was a pet with the wont-follow flag but I think the current, more targeted, approach is far better and way less likely to introduce regressions.

Testing

Spawn cow. Befriend cow. Move a couple of tiles away. Keep spamming '.' to pass turns and notice that the cow doesn't follow you. Move a couple of tiles away and try again and so on. Assuming no threats in the near area, the cow should just stumble randomly every few turns and not follow the player.

Additional context

Checklist

THe root-cause for pets always following player regardless of
MF_PET_WONT_FOLLOW flag was found in move_scent() which caused non
fleeing creatures to gravitate towards the scent of the player, ignoring
the wont-follow flag.
@github-actions github-actions bot added the src changes related to source code. label Mar 10, 2024
@scarf005 scarf005 changed the title fix: pets with MF_PET_WONT_FOLLOW flag don't follow player fix: pets with MF_PET_WONT_FOLLOW flag don't follow player Mar 10, 2024
Copy link
Member

@scarf005 scarf005 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2024-03-10_17-22-32.mp4

@scarf005 scarf005 merged commit 6f8ef0e into cataclysmbnteam:main Mar 10, 2024
13 checks passed
@ekaratzas ekaratzas deleted the fix-pet-wont-follow branch March 10, 2024 23:25
@Unrepentant-Atheist
Copy link

Does MF mean what I think it does?

@chaosvolt
Copy link
Member

Monster Flag :>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MF_PET_WONT_FOLLOW doesn't work as expected
4 participants