Sunday, September 15, 2013

Work Orders and Terrain

Graphics in Cultura is designed around the idea that what an artist draws is what they get to see in the game. That way, there's no strange distortions (other than effects) and so on, allowing artists to simply draw. As part of that, the terrain on the ground used to be rotated quads but no longer! They are now the same as everything else. In addition, the terrain drawing has been randomised using a single hard-coded seed. What this means is that if I have three different grass textures I could rotate through to draw a particular square, it will choose one at random but because the seed is hardcoded, it always chooses the same one so it looks consistent as you scroll around or reload the game.

Using some test tiles, you can see that they are pesudo-randomly chosen and it is always the same every time you load up the game or scroll here.

Work orders have also been finished off, minus UI styling. They list out the existing work orders and allow you to modify them.

If you create one, it will then list it out. This allows you to select it and change it.

The rest is taken care of automatically in the game. Workers will shift what they need to do. By design, if they are already working on an item, they will complete that before adjusting to the new marching orders. That's fine to me so that I don't have to deal with partially finished goods.

Sunday, September 1, 2013

Item Crafting and More!

Features Completed

It's been a while since I posted the last feature complete type of post mainly because the item crafting feature involved a lot of moving pieces. But it's done! The goal after this is expanding it out (I wanted to be able to select a unit and then have an item crafting button at the bottom in a limited action panel) and also to build more infrastructure to support it (I've decided that I'll just go with xml data loading during initialization).

So what was done?

  • Industry Management Screen
  • Work Orders
  • Automated Animal Hunting
  • Automated Node Harvesting
  • Automated Item Crafting

The industry management screen loads up a test-version of the goods tree. On the left hand side are the raw resources and they lead to ANY secondary item that can be produced from them. Later I'll sort the goods alphabetically in their subcategories so everything can be found easily. The point of having each resource lead to any secondary item that can be produced from it is to be able to easily find secondary items (for instance, if an item requires both metal and wood then it will occur twice in the tree extending off from wood and also from metal).

Once you click on one of the goods in the tree, you can then select the options below to change the industry management. Only work orders are fully implemented. So if you select work orders you go to the work order screen.

Here you select how many you want, what materials to use (the options are: must use, use if available, don't use). This screen will also show existing work orders to allow you to change their settings. On next update, the labourers completing the work order will update their settings accordingly. So, there's a delay of building the current item for any labourer completing the work order (for instance, if you cancel the work order, the labourers will still finish what they are working on at the moment).

About item crafting, these are the following game decisions surrounding it:

  • Item crafting must occur in a building
  • The AI will select a building which the person owns or the government has assigned a government building to him (will choose the best building)
  • Material selection occurs each time the unit starts building the next item, in case material settings and availability has changed
  • Each building can only have ONE type of industry improvement (forcing you to build additional houses to improve the industry rate for more labourers)
  • After crafting an item, the carry limit is not checked, the unit will simply be carrying it and queues a drop-off

What doesn't get good screenshots but took a lot of work was the actual implementation of the work orders. There are three different situations: you gave a work order for hunting animals up to a limit, you gave a work order for collecting raw resources or you gave a work order to craft some materials. In the case of hunting animals, the AI finds an animal in the land region of a unit and then has the unit queue up a hunt animal action. The limit is in the amount of meat to harvest (not number of animals). I may, in the future, add in the ability to select an animal limit rather than a meat limit. For a raw resource, the unit finds a resource node of the correct type and material type (but the player can always select yes to all material types). So if you create a work order for wood and said "Y" to pine, then a unit will only try to chop pine wood up to the quantity. Finally, item crafting has a unit attempt to collect resources necessary to produce the good and then go to a building to craft it.

Here is some "flour" (I think my cavemen are making crack but if I don't debug then I can feign ignorance)

Next feature will be surrounding stuff to improve item crafting before I move onto the other buttons in the industry management