Minecolonies & ChildrensteemCreated with Sketch.

in #utopian-io6 years ago

Hi everyone, been a while since I last posted going to try posting more frequently!
I've done some more work on the minecraft mod Minecolonies and added children to the mod.

2019-02-25_21 45 12

The first step was creating the visual children, without there wouldnt be any. As I am more a technical than a creative guy I went with rendering the existing citizens smaller instead of creating new models for them myself. It took a bit of trying around till I found that Minecraft already has support for child entities, which made the small-size display as simple as this:
image

This flag has to be saved at various places, in the Data structure of minecolonies. For the children we got the following classes:

  • CitizenData which contains any meta information about the citizens.
  • CitizenDataView the client-side representation of the CitizenData
  • EntityCitizen the actual citizen entity, which is client and serverside.

Creating children

Now lets create the children! Minecolonies has so called "Citizen Huts", in which the inhabitants of the colony are living.
2019-02-25_22 29 18

Those huts are now trying to spawn children periodically if a male and a female citizen are living there and the colony is not maxed out. To check whether the parents are present the citizen hut simply remembers them upon moving in:
image

To create a new citizen we first need a new CitizenData entry for them, since it holds all the metadata:
image

Children will learn from their parents through averaging their attributes, with some randomness factor as natural abilities:
image

After creating the necessary data for our new child citizen we can spawn it and notify the players in the colony about it.
image

In recap colony children mechanic is now following these rules:

  • Mom / dad entities are required and chosen randomly in a citizen hut.
  • Children inherit stats from their parents, with average +-2.
  • Children get assigned to a free housing slot in the colony to be raised there. If the house has an adult living there the child takes its last name and gets raised by it.

Children Behaviour and AI

Finally the children need some activities so we're adding a childAI to them. For AI's we're using a state machine, which I'll explain more about in a future post. For our AI we're defining states and transitions to use:
image
image

To make the colony look more lively the children got two movement activities:

  • They randomly follow other entities, even critters, around, as children are naturally very curious!
  • They randomly visit existing buildings in the colony, watching grownups at work.

For following other entities we're checking entities around the child every 150 game ticks. The check happens in a simple box radius around the child entity, and is not executed too often to not affect performance much.
image
Once we found a target we're storing a weak reference to it, a weak reference is so the game is allowed to unload the entity when it wants to. After finding a target the child's pathing is set to follow the target around. Visiting other building works in a similar fashion, we randomly choose a building in the colony and task the child to walk there.
2019-02-25_22 57 26

I hope you liked this little write-up, looking forward to write some more on further updates to minecolonies.

Repository:

https://github.com/ldtteam/minecolonies

Pull Request for further details:

https://github.com/ldtteam/minecolonies/pull/3331

Sort:  
  • Great post with pictures, code samples and explanations.
  • What? there was no kids before this? Wow this is big!
  • There is a also a lot of code about Hire, you can now hire people? Why not talk about that in your post? See: WindowTownHallHireCitizen.java

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

you're right the PR contains another feature, which I did not add as I thought the post would become too long. The 2. Feature is the ability to "Send Recruitment Packages" with resources out into the void and find a new citizen this way. This lets players get a new Adult citizen quickly at the cost of resources, for those interested it looks like this:

Thank you for your review, @helo! Keep up the good work!

I love having the kids running around, fills the colony with much more live =D

Hi @someaddons!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @someaddons!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Congratulations @someaddons! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You received more than 100 upvotes. Your next target is to reach 250 upvotes.

Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word STOP

Support SteemitBoard's project! Vote for its witness and get one more award!

Hey buddy are you a Developer?

Posted using Partiko Messaging

Congratulations @someaddons! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.21
TRX 0.27
JST 0.040
BTC 102419.62
ETH 3707.14
USDT 1.00
SBD 3.24