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

Make friendly monsters follow you unless under attack #50864

Merged
merged 1 commit into from
Aug 18, 2021

Conversation

eltank
Copy link
Contributor

@eltank eltank commented Aug 18, 2021

Summary

Bugfixes "Make friendly monsters follow you unless under attack"

Purpose of change

Currently tamed animals will not follow you if they can see other untamed animals. I believe this is due to code in monster::plan() intended to target (and probably attack) potential threats. However, when there are neutral animals around that just shifts the target away from the PC (who they would otherwise follow).

Describe the solution

Change the relevant code to only target hostile monsters.

Describe alternatives you've considered

Testing

Spawn some dog food and 2 dogs. Feed one dog and move away. The friendly dog won't follow you without this change as long as it can see the other dog. After making this change it does follow you.

Additional context

Before: friendly dog not following because it sees the other dog.

image

After: friendly dog following.

image

@actual-nh actual-nh added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Monsters Monsters both friendly and unfriendly. labels Aug 18, 2021
@eltank
Copy link
Contributor Author

eltank commented Aug 18, 2021

It was suggested during code review that I could also fix #50532 with a couple more lines of code.
After further discussion, I'm not going to do it in this PR since a proper fix requires adding a way to lead animals that won't follow you on their own (via leashing). That needs a separate PR.

@eltank eltank force-pushed the friendly_mon_follow branch from 5a2d5fa to 78a69fd Compare August 18, 2021 06:42
@eltank
Copy link
Contributor Author

eltank commented Aug 18, 2021

I also spawned a zombie to see what the friendly dog would do. It stopped following me, but did not attack the zombie.
This seems to be broken already (i.e. the friendly dog won't fight back against the zombie with or without my change). I even tried blowing on the dog whistle (which made the dog docile, then back to non-docile), but that didn't help.

Note that non-friendly dogs do fight back, after taking enough damage (though at that point they'll attack anything). It's friendly dogs that are broken.

@LyleSY
Copy link
Contributor

LyleSY commented Aug 18, 2021

I don't understand the code, but on a surface level this looks like the right way to fix this issue. Leashing is in the game, it requires a short rope. That was the intended way to move animals like cows way back when cows were added

@kevingranade kevingranade merged commit 7608106 into CleverRaven:master Aug 18, 2021
@eltank
Copy link
Contributor Author

eltank commented Aug 19, 2021

Leashing is in the game, it requires a short rope. That was the intended way to move animals like cows way back when cows were added

@LyleSY: what makes you say that leashing is in the game? It would be great it that were true, but I can't find it either in the UI or in monexamine.cpp. So I'm working on adding it to the game. Was it perhaps added some time ago and later removed? Finding an older implementation could save me some work.

image

All I could find was an old suggestion (#10256) which was closed as stale.

Edit: The leashing PR is ready: #50890. I suppose whether or not leashing was in the game before is no longer relevant.

@eltank eltank deleted the friendly_mon_follow branch August 19, 2021 00:03
@LyleSY
Copy link
Contributor

LyleSY commented Aug 20, 2021

Ah, I was remembering talking to @AlecWhite about this (ugh) four years ago https://www.reddit.com/r/cataclysmdda/comments/6shimz/so_cows_now_have_new_functionality/ Alec had a PR to do it but it looks like it was never merged. Sorry for the confusion, good stuff!

@dreaddymck
Copy link

dreaddymck commented Aug 23, 2021

Would it be possible to add logic preventing tamed animals from entering moving vehicles, maybe follow a few spaces away instead?

I am running the latest experimental and with the "crazy cat lady" session I have going on her pets swarm when it is safe and she is close, that swarm becomes a hazard when driving.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Monsters Monsters both friendly and unfriendly.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants