-
Notifications
You must be signed in to change notification settings - Fork 276
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
feat: prevent chickens from escaping chicken coop #4333
feat: prevent chickens from escaping chicken coop #4333
Conversation
The idea is to prevent pet chickens from escaping the chicken coop when the player goes in/out of the coop by adding a specific flag both to the open chicken gate tile as well as the chickens themselves. This flag will prevent the pet chicken from considering moving to the chicken gate tile a valid move. This concept can be applied to other types of gates and animals by reusing the new flags PASTURE_GATE and PET_AVOID_PASTURE_GATE.
Autofix has formatted code style violation in this PR. I edit commits locally (e.g: git, github desktop) and want to keep autofix
I do not want the automated commit
If you don't do this, your following commits will be based on the old commit, and cause MERGE CONFLICT. |
you should add this flag to all livestock animals |
Hey @Zlorthishen, thanks for taking the time to look at this. As I mentioned in the PR description
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there might be two issues with this approach:
- current solution only works for pets
PET_AVOID_PASTURE_GATE
has to be applied for all future pets.- won't be much an perf issue, but this adds checks for each monsters.
alternatively, how about adding AUTOPASS
flag that lets only characters to pass through? this way, players can choose how to manage pets via
closed chickenwire gate
: only player can go in and outopen chickenwire gate
: both player and chickens can go in and out
@scarf005 thanks for taking the time to comment on this. I'm not sure how the Regarding this approach and what it should apply to, imho it should only apply to bird pets as they overpopulate quickly and that's the main issue farmer players in either fork have faced in the past with regards to getting in/out of the area they are kept. In addition, bird-pets are usually introduced into the main pasture area via a chickenbox or such mechanism so they don't even need to enter into the coop by themselves even then. In other words, if it were solely up to me, this flag would not get applied to cows, sheep, dogs, cats and so on; just bird* pets. That's my answer to your first two points. No clue about performance impact, I don't have any data for that. Valid question on how something like this would impact mobile devices that can run the game though as it's an extra check for each monster's plan(). All that being said, I'm also not convinced this is the best solution to solve the problem with. Ideally I'd want to designate pets -and their offspring- to pasture zones and have them magically stick to those zones like in rimworld, but that's way beyond my current know-how with how submaps/zones can get partially loaded and so on. |
Line 4010 in 6f8ef0e
Cataclysm-BN/src/avatar_action.cpp Lines 400 to 412 in 6f8ef0e
maybe we could update |
Thanks for the suggestion, I can take a look at that @scarf005 and see if I can come up with something. Atm I've context switched to a different idea that I have altogether, but I'll come back to check out this approach. |
@scarf005 I took a look at the I see what you mean about checking for a specific flag on the terrain and in that case, skip opening the door. It'd basically be the equivalent of the running check for gates. What I don't like about that approach is that you can actually displace an animal into the closed gate as you come into the pasture. In other words, moving in the chicken coop while there's a chicken on the first tile of the coop would make you swap places with it. At least I was able to swap places with my horse while 'vaulting' over the wooden gate and the horse ended up on the closed gate lol :D pic related How I prevented that in the original PR was by enforcing the can-i-move-here check on the monster side of things. All that being said, if we are not happy with the original approach, I am fine abandoning this PR so we can focus on other things, like my other PR which is tied to a broader idea I'm working on. Lemme know. |
No traction, I'm closing the PR! |
The idea is to prevent pet chickens from escaping the chicken coop when the player goes in/out of the coop by adding a specific flag both to the open chicken gate tile as well as the chickens themselves.
This flag will prevent the pet chicken from considering moving to the chicken gate tile a valid move. This concept can be applied to other types of gates and animals by reusing the new flags
PASTURE_GATE
andPET_AVOID_PASTURE_GATE
.Purpose of change
The idea behind this PR is to help chicken farmer players keep their chickens in their chicken coop areas.
Traditionally, what chicken farmers are forced to do in cata is climb through the fence into the chicken coop so as to not risk the chickens escaping while getting in/out of the coop gate.
This change makes it so that pet chickens will not consider escaping via the chicken coop gate tile, even if it's open, making it easier for the player to get in and out of the area without any of the birds escaping. This PR also makes chickens have the PET_WONT_FOLLOW flag as well.
Describe the solution
Solution works by introducing 2 new flags that work in tandem. Creatures with PET_AVOID_PASTURE_GATE flag that are also pets of the player will not consider moving through tiles that have the PASTURE_GATE flag.
This essentially makes monster::will_move_to() consider the position containing the tile with the new flag as a non valid destination for the pet monster.
Therefore when the player is going in-out of the pasture area, there is no fear of the little creatures following them. In this PR I'm also marking chickens/baby chickens as not following the player because it's annoying when they do and IRL chickens don't really follow you anyway in my experience.
However I should point out that this PR does introduce one corner-case where the experience might be clunky:
If the player tries to move from position A to position B, where
Then this will produce an error message and stop the movement. See PR #4325
This problem has already existed when players try to get in via the fence as mentioned earlier, but now it might also appear for the same reasons with the gate as well.
What this means is that if the player is trying to move into the coop and all 3 adjacent tiles to the coop gate contain chickens, then the player can't get into the coop area via the gate as the player cannot displace the chickens and swap places with them so they end up in the gate.
A visual representation of the corner-case:
G = gate, F = fence, c = chicken
If the player is standing on G and tries to move to the right into the coop area, all 3 possible positions are taken over by chickens. Then player can't move into the area as they cannot displace any of the chickens.
In this corner-case the player has to either 'push' the chicken in front of them, or mash the direction button/wait for them to move. Since PR #4332 has been merged, creatures with wont follow actually move randomly and dont follow the player so that's not much of a problem anymore but wanted to bring it up for full disclosure. I tested this behavior in a 3x3 coop with 6 friendly chickens and did not see this as an issue. However if the coop was full/almost full, at that point you'd have to either start slaughtering chickens or make it larger.
Describe alternatives you've considered
Climbing through fences to avoid this issue seems silly.
I've considered adding these new flags to more tiles/gates/monster types but figured I'd first see reactions to the mechanism itself. It's always easy to expand it to cover more animals/gates.
Testing
Easiest way to test this is to have a chicken cook with pet chickens. Coop should have chickenwire-gate for this to work. Leave gate open, see no friendly chickens escape.
Additional context
Checklist