That'd be great. Though herd behaviour is probably better placed in mobkit itself.runs wrote: I will implement if interested.
There seem to be only a few (three) rules regarding this behaviour: flocking (Wikipedia).runs wrote: But Minecraft has not, only parent-child. I do not know how to implement. How to make the relationship herd?
The amount of individuals in each herd has to be low to avoid performance problems with server and clients. Perhaps 6-8, sometimes up to 12 individuals per herd might be a reasonable amount. I don't know if that's enough for herd behaviour emerging.
Each member of a herd has to know which herd it belongs to (stored in static data). With such a low number of individuals, the entities could all be stored in a lua table so that access to the other entities in the herd can be fast without requiring a lot of memory. The positions of these entities may already allow executing two of the rules (avoid crowding neighbours and steer towards average position of neighbours). The third - steer towards average heading of neighbours - might be a bit more complex. But at least that can happen in 2d as pathfinding happens in 2d as well. All those calculations of a new heading are only necessary when the animal decides to move somewhere randomly. Sheep and the like ought to feel a lot happier in a herd and have far less reason to roam around seeking others of their kind than if they where lone animals; that might save some ressources as well.
Other effects such as keep distance to a predator (higher priority) and find grass to eat could also have an effect. But that's something for mobkit I think.
Perhaps "stay close to your shepherd" and the shepherd beeing an NPC might also be very intresting. Lone sheep or sheep without owner are a bit worriesome.