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

Leash and lead tamed animals #50890

Merged
merged 4 commits into from
Aug 19, 2021

Conversation

eltank
Copy link
Contributor

@eltank eltank commented Aug 19, 2021

Summary

Features "Leash and lead tamed animals"

Purpose of change

Add the ability to attach a leash to any tamed animal, then use the leash in order to make them follow you. Fixes #10256
Make animals with PET_WONT_FOLLOW not follow the player unless being led by a leash. Fixes #50532

Note: this PR looks large, but it's mostly code refactoring from the first two commits. Actual diff-LOC is around 150.

Describe the solution

  • Add two new monster effects: "leashed" and "led_by_leash".
  • Using the examine menu, the player can add/remove a leash on a friendly animal. This uses the code that was previously written for the tie/untie action. The player is asked to choose a rope from inventory to use as a leash and gets the item back when unleashing (reusing the "tied_item" field for save compatibility).
  • Leashes may be left on pets indefinitely without hindering their movement. If the player doesn't need the rope this saves the hassle of leashing them again later.
  • Pets can still be tied in order to immobilize them but they must be leashed first. Untying them does not remove the leash, just the movement restriction.
  • When examining a leashed pet, the player can choose to lead them by the leash. The animal will then follow closely, even if they can't see the player.
  • If the animal gets too far from the player (or vice versa), the player loses their hold on the leash and the animal stops following. The leash remains on the animal. The player is notified via a message that this happened.
  • It is possible to lead multiple leashed animals at once, but if they get in each other's way one of them may get too far from the player and the above happens.
  • Works across z-levels as long as the up/down stairs are aligned (otherwise the player will be too far from the animal after using the stairs)
  • For player convenience, it is possible to select the lead action for a leashed and tied animal. This will untie it first.
  • For backwards compatibility, animals that have the "tied" effect but not the "leashed" effect (from an earlier save) will gain the "leashed" effect when they're untied

Describe alternatives you've considered

Requiring survival 1 to put a leash on. You have to tie a knot that won't strangle the animal. Not sure if necessary so didn't do it.

Animals tripping on their leash or getting their leash stuck on something. This invites more micro-management (you have to remove the leash) and adds more code.

Strength check required to move an animal via leash. Since the animal is tame, I assume they just need a gentle tug in order to follow. If in the future we allow leashing untamed animals then this would be required.

Testing

Tame a cow, verify that it doesn't follow the player (cows have PET_WONT_FOLLOW ).

image

You can leash it and make it follow you.

leash_and_lead.mp4

Lead two animals at the same time

leash_and_lead2.mp4

Dogs will follow without using a leash, but only if they can see you. When you go through a door or down some stairs they can get left behind. Leashing solves that.
To test losing hold of a leash you have to get the animal stuck on something, like an NPC (end of the video).

leash_and_lead3.mp4

Additional context

eltank added 4 commits August 18, 2021 19:09
Most of the functions don't need to be exposed, they're just
implementation details.
- introduce leashed and led_by_leash effects
- add corresponding actions to the monexamine pet menu
- consume rope on leash, return it on unleash
- rework tie action to require leashing first
@Entity-y
Copy link
Contributor

Incredible! I was just thinking about this over the past couple days, this game needs leashes for pulling animals through the woods without losing them instantly.

@Marrim
Copy link
Contributor

Marrim commented Aug 19, 2021

Does the leash length depend on whether a short rope or long rope is used?

@kevingranade kevingranade merged commit 6957926 into CleverRaven:master Aug 19, 2021
@eltank eltank deleted the leash_and_lead_pets branch August 19, 2021 06:14
@eltank
Copy link
Contributor Author

eltank commented Aug 19, 2021

Does the leash length depend on whether a short rope or long rope is used?

No, it's just arbitrarily set to 2 tiles. You lose hold of the leash when the distance gets to 3.
We could make the leash longer but then we'd have to deal with situations like: you go into a building through a window while leading a cow, the cow goes in through a nearby door and the leash magically phases through the walls.

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.

"PET_WONT_FOLLOW" is bugged Leash for pets
6 participants