-
-
Notifications
You must be signed in to change notification settings - Fork 631
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
Implement aging + breeding #2696
Conversation
/cc @SafwatHalaby |
Minor remark: At https://github.com/Gargaj/cuberite/blob/breeding/src/World.cpp#L3485
|
Probably true, although in the grand scheme of things it doesn't change much if it spawns as an adult, it just counts the aging timer down and then doesn't do anything. |
True as of now. But the value may be used in the future in ways we can't anticipate. Suppose some Lua API wants to query how long it'd take for a mob to grow up. Currently it would return a false answer for adult mobs. |
It's a bit of a mess because "age" seems to have two uses: http://minecraft.gamepedia.com/Chunk_format/Breedable |
GetFollowedItems(FollowedItems); | ||
if (FollowedItems.Size() > 0) | ||
{ | ||
cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), static_cast<float>(m_SightDistance)); |
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.
This code means that the player holding the bait must be the nearest player, is this the case in Vanilla? This is a minor issue though, and can be resolved after this merge.
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.
That's not my code, I just worked around it.
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.
What about a DoWithClosestPlayers(Position, Callback)?
It would sort the players based on how far they are away from the position. The closest player first, and the furthest as last. When the callback returns true it stops.
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.
Shouldn't there be an equiavilant with a max-distance cap? You don't want to sort all the players in the world every tick for every mob.
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.
This code is just ripe for a rewrite. We don't want to be finding the closes player all the time, instead, we should store the followed player and only update it from time to time. The variable name is super-confusing, too, since we use a_
prefix for function args. And of course we want to react to non-closest players, too, if applicable.
|
|
You need to send the entity status "love mode" every n ms (got to figure out n) to near players if you want them to see the hearts for 30s. Only the client of the player that give the wheat predicts the "love mode" itself. Not sure if you already do that ? (trying these stuff with 2 clients is generally useful to make sure it's not just the client predicting stuff) Edit: actually, I tried it with the vanilla server and it doesn't do that (the 2nd vanilla client can only see the first heart (for 1 sec)) |
@Gargaj You are correct about point 1. |
Shouldn't the partner be nullified when |
There's no such state. If the mob has a partner, |
Consider a case where you isolate the two partners just after they lock in to each other. Shouldn't they give up at some point? |
Right now it doesn't actually matter that they can't reach each other. :) |
I just tested this, two chickens had bred through a 2-block thick wall. Once they lock in, their physical position doesn't matter any more, a baby will be born. I never knew that. |
-Tested with Vanilla- |
There are so many jokes to be made about that. |
Lol. |
Implement aging + breeding
Vanilla does care about mob reaching each other. Apparently ~2 blocks is the maximum distance in which the mobs can still breed. Seperating them with a 3-block wall prevents breeding and makes them give up after a while. |
cPassiveMonster * m_LovePartner; | ||
int m_LoveTimer; | ||
int m_LoveCooldown; | ||
int m_MatingTimer; |
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.
These should have been documented - what they do, how they interact with each other etc.
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.
Question: If you said above 2 blocks distance they dont breed, do they go into post-breed cooldown or can you re-feed them? |
I will test that as soon as I can. But I think this is the least urgent of the AI issues. |
Sure, but also reasonably easy to fix :) |
I think they should be in love mode for a few more seconds, -- right now it's rather short, but I'm so glad this is being tackled! Maybe it was just by chance but I noticed that sheep do not inherit their fur/wool color yet, and that we don't get domesticated cats when ocelots breed. Thanks for all of this!! :) |
Looks like there's currently no way to pass down information from parents. Might even just be a good idea to pass the parents to the baby's constructor and have each baby mob do their own thing with the information. For instance, a baby sheep will find the wool color of the parents and use that to determine their wool color. |
On a technical side, I don't know how this works at all. But I'm glad you're figuring it out. Thank you very much :). |
The only reason I haven't added the wool color cos I haven't figured out how the colors blend when they're different color. Otherwise it's just some additional conditions right after the baby spawn. |
Notes:
cMonster
just yet because it would introduce a whole new set of problems.Another important note: There's a change in the 1.8 protocol implementation when it comes to communicating age: @rom1504 and I did a bit of snooping in the less-documented parts of the protocol (http://wiki.vg/Entities#Ageable) and found out that the only way to make the love-mode hearts disappear is to set the Age to x>0. This introduces 3 distinct states for Age: x<0 when baby, x==0 when adult and ready for mating, x>0 when exhausted from mating.