Friday, February 24, 2012

78 – What What (In the stockpile)

You may have noticed in my last video that when dwarves dig though stone there are no usable boulders left on the floor like in the past. I'm not sure about boulders, but some stone, probably bricks should be left as a byproduct.

Next on the list is reimplementing tree cutting, so I also need multiple logs pilled up somewhere. So logs + bricks equals stockpiles.

Logs are boring so I start with bricks. But I don't have pictures, so I"ll show you a video first and then describe what you saw.

The first things I demonstrate is brick stockpiles. They can be manipulated directly in creation mode. Simply adding a brick somewhere changes that to a brick stockpile. Removing all the bricks destroys the stockpile. 

I was just going to add support for multiple brick types stockpiles, but then I realized that makes no sense. What if you need 3 native copper bricks, but they are under 300 bricks you don't care about. What is a dwarf supposed to do? Sort though 300 bricks? How? Using a temporary stockpile? What is this? The Towers of Hanoi problem? How is a dwarf even supposed to remember where the bricks are if they are not visible? So no multi-material stockpiles! Maybe for food. But not for bricks and logs.

So why are there so few maximum bricks in that stockpile. Why only 47? The short answer is that I want bricks to be put down in a logical and aesthetically pleasing manner, so all positions must be created individually and I go bored after 47 bricks. The long answer is than in the future I will have to optimize this, making sure that hidden bricks take no resources. So no use working a lot now on positioning since I'll have to redo that when I'll optimize it. I may even give it the "voxel" treatment, making sure that optimal face rendering is used.

The individual positions at which bricks are placed form a pattern. Currently only one pattern exists, but the next step is to add patterns for everything that can be reasonably created from bricks: walls, houses, bridges, towers, balconies, castles, dungeons, etc.

The final goal is to create a city of Elder Scrolls complexity, one brick and log at a time.

The final result of a pattern probably won't look that good. I will have to take that result, take its general shape, remodel it traditionally and break it into pieces to create a new pattern.

And as always, lighting sucks on those bricks. If this where a AAA title you would have pre-calculated lighting and baked in ambient occlusion for each pattern. But you are stuck with me, so have some very shinny bricks! You are welcome!

The UI only allows to add or remove a single item at a time, but in the future this will be more flexible. I also textured the bricks, quite poorly.

Next in the video we have log stockpiles. I am using the high quality logs created by BrewStew which I textured myself, again quite poorly. The problem is that the logs are so distinctive that you immediately notice that there is one one log mesh. Maybe I have to go with a more simple cylindrical log to make it less apparent that there is a finite (1 right now) number of meshes. Maybe some random scaling and rotation in the future.

Optimizing logs is harder than bricks because they do not create patterns that fully cover underlying logs. So I might have to model each pattern separately so I can hide some extra faces. Anyway, I am not wasting time optimizing things right now. Add features today, optimize on a full moon during a lycan attack.

So in conclusion things are shaping up. Creation mode has most of the basic tools implemented. Normal mode is still lacking, but one of the next updates should add tree cutting now that log stockpiles work again. Adding food and harvesting back is trivial, but I am not clear on the design for the logistics: what do you do with the harvested plant? If you have no storage do you just leave it on the ground? Then I need to model harvested plants. Do I use the solution from the old 2D engine with magical sacks that appear out of nowhere? Do I create mixed solution where if you have no storage you leave it on the ground, if you have available sacks you use them? Or maybe I don't use sacks and instead use barrels?

Anyway, things are on feature freeze right now and Snapshot 8 will be uploaded on Monday. I will do my best, but expect to see a few bugs.

After Snapshot 8 I want to do a quick experiment. My plans and ambitions for this game are leading me in a different direction from the DF one. In March I will try to take the game in a slightly different direction. Have no fear, I'll be using the same engine and mechanics. Dwarves will do the same stuff and new actions that work both in the DF model and my model will be added as scheduled, so if the March experiment fails the game overall will have taken a few steps forward.

But the DF model can be quite confusing. You have a multi level map where you interact with it one level at a time. You need to change levels a lot. You don't see what is happening one level higher. And if you do, it can obstruct your view of the current level. Implementation wise the map eats a lot of RAM and there are extremely rigid data structure requirements to do path finding in such a map.

In March I'll try a model that is not level centric, but "view" centric. Your default view is to see the entire surface of the map. Elevation is smoother and dwarves walk all around the place. The surface of the view is deformable and a lot of actions change the shape of the map. Maps are larger. I'm thinking of eventually giving you a 3 square kilometer playground and see how that goes.

This will be just an experiment to see which perspective I like better. If the new model works out I have great plans for immigrants. I said before that the number of active dwarves will be a lot lower than in DF. Dwarves will be few and very valuable. One dying will be a huge disaster with profound implications on your productivity. If you have 200 dwarves, one dying is negligible. If you have 15 dwarves, one dying is more important. Maybe the one who died is the only one you had with a given skill, so now not only did your general productivity fall, you are no longer able to do a task you previously could. I am also thinking about making dwarves have only a limited number a skills they can perform. In DF all dwarves are novice at all skills. I'm thinking of giving them about 6 skills, with a starting dwarf being fairly skilled at 1-2 of them. They can't perform skills they are not trained for before they receive tutoring. And you will be able to buy skill books if a trainer is not available, but it will take weeks for a dwarf to learn a new skill from a book.

So what do you do with low number of dwarves but a big map? Immigrants! Wait, what? Did't I say that the number of dwarves will be low? Well there are going to be two kinds of immigrants: squad mates and civilians. Squad mates will be like your normal dwarves and under you command, while civilians will mind their own business, sometimes helping you with tasks, sometime just trying to survive, eating your food and blundering about during combat like Jar Jar in the final battle from Episode One.

So you'll have a large living city full of civilians that go by their daily routine and don't take direct commands and a small number a dwarves in your squad that you control. Civilians will be able to sometime perform tasks like hauling and digging, sometimes for free, sometimes with payment. Things your highly skilled dwarves are too good for. Because they are better than you!


  1. Are you placing each brick manually in the stockpile? It is almost trivial to procedurally generate a stack of bricks. If you generate the pattern, you can also randomize it easily. I can provide proof of concept code if you want (but it won't be C++). Also, did you try using staggered layers? I.e. one brick is placed on top of two other bricks, or four other bricks, like in real life masonry. Those look more interesting. You don't have to make them pyramids either- on edges the bricks can "stick out" and create a staggered face, which also looks interesting. The lighting was fine, don't worry.

    For the logs, try randomizing the direction. Turn every other log 180 degrees, preferably randomly. Mirror a few. You've now got "4 kinds" of log from one model. For optimizing, if you can do that, you can just make the pile of logs a prism, and only draw the outer logs as separate models. It'll be visible when you look close, but nobody will and nobody will care.

    For harvesting, yes, best would be to leave the harvested plant on the ground. It is the most logical way. Obviously teh models need to be made, until then, a placeholder bag is a very reasonable compromise.

    1. I am placing them manually as in I set the coordinates manually from code. I'm not sure about letting the player create their own pattern. We'll see.

      Staggered layers will be used for most patterns like walls and stuff, but not for stockpiles. It is more efficient this way.

      The lighting is absolutely terrible!

      For my engine rotating or scaling a mesh is practically identical to creating a new mesh (except for the modeling part) and caries the same performance overhead.

      For plants I added some simple color-coded bags for now in Snapshot 8.

  2. Not sure that the squad mate/civilian distinction sounds good. I can see it is a step towards the DF style megafortresses, which everyone loves, but I think I'd assume just allow the design to incorporate larger groups of dwarves rather than this distinction of controllable vs non-controllable.

    Afterall, a lot of the work is building infrastructure for large colonies. If 15 was the expected max, what would there be to do?

    1. Well that is the design right now. Small squads and the civilians are just something to make your city feel alive. We'll see how that goes.

      But a civilian still has the same needs as a squad mate, so you'll need plenty of infrastructure to support and attract them. And since they are not part of the military and this is war, you'll be able to close your gates to them or even execute them if you wish to be more evil. And then eat them!

  3. Continuing on what I said anonymously (whoops), if the civilians would do hauling (which 80% of my DF fortress dwarves seem to do anyway) that would go a long way. I'd also love to seem them be conscriptable to the military, or perhaps you could offer to pay a salary to military dwarves and get volunteers. I think having a large military is quite enjoyable, and opens up a lot of fighting options.

    This would leave your "squad mates" (need a better name, how about "heroes"?) to be the master craftsmen and battlelords.

    Additionally, building rooms for civilians who are not really working for you would mean you could charge them rent. That would imply they'd need a salary of some sort (hauling or military wages could count). I suppose there could be "generic economic activity" but as the player is controlling what it built, it might be hard to imagine much of an economy that wasn't part of something the player had built and presumably controlled. I don't think anyone would want the civilians to be running around building their own shops and doing manufacturing and farming, etc.