The new building UI

Highlight of the new building UI and resource production


Here is a screenshot of the new building UI, in this case for a production building.
I’m going to explain a bit what it tells us about this particular building.
The top part gives us general informations about the building while the bottom is specific to its role ( production ).

General infos
The building is a farm, and it currently costs 1 coin of maintenance. It has points of structure ( the building’s hp ) and solidity ( the building’s “armor” ).
On top right we have the currently available general functions : abandon the building, put it to sleep or tear it down. We see the building is currently functional, and employs 3 porcos as farmers.
On the bottom right of these general infos, we see there is one upgrade available to another farm building (details about the upgrade would pop up when putting the mouse over that button).

Then there’s the role specific UI on the bottom. Here its the UI of a production type building.
Its divided in 2 parts : production of resources and distribution of these resources.

It also shows the available annexes for this building. Annexes are sub-buildings that belong to a main building.
In the case of this farm, we see it can build “field” annexes giving additional resource production, and you can choose what type of crops you want these fields to grow.
It can also build a distribution annex , the “barter area”, allowing to distribute produced goods directly to the population.

Production and distribution
We see 2 of the farmers are busy producing while the 3rd one is busy distributing, selling some of the production directly to the population using one built distribution annex.
The building is producing 0.9 of beans and 0.6 of corn, and all the beans are distributed by that 3rd porco . The remaining production (here the corn ) will go into granaries or be sold by merchants. Production is always expressed “per cycle”. A cycle can last a variable amount of real time depending on the game settings. If you’re playing in a persistent 24/7 game its likely to be 2hours while in a ‘realtime’ game it would be something more like a minut.
The building has an efficiency of 2. That depends of the building itself but eventually will also depend of techs, connection to roads and placement.
This, combined with the actual number of porcos producing, defines the actual workforce of the building ( 3 ). This workforce is used to work all the production sources available : 8 fields of beans, 9 fields of corn, and 29 wild beans in range of the farm. The 2 farmers are 100% busy working these and while the fields are properly exploited, we can see they don’t have enough workforce to also fully exploit the wild beans. To do that we’d need more workforce, so if we wanted we could upgrade the farm to increase its efficiency or put back the 3rd porco in production (but the farmers would lose the income of direct distribution which is higher than selling to merchants ).

This farm is adding 9 to the total region wealth. Wealth produced by buildings is directly proportional to the amount of busy workforce of the building.
Total region wealth is then splitted between all the inhabitants of the regions depending on their respective incomes. A porco’s wealth defines its purchasing power and therefore the price of goods in the region (as merchants will continuously adapt to the available market), so its pretty important to increase it. Think of Wealth as some sort of objective unit of GDP.

The Hog news 22

Building destruction and destruction tools
It is now possible to filter what you want to destroy when using the destruction tool : terrain ( will clear trees and other natural things ), infrastructures ( will clear things like roads, walls built by player ) and buildings ( will trigger destruction of all buildings in the selected area ) by right-clicking on the tool. You can enable or disable each filter individually.
Also building aren’t destroyed instantly anymore. You can trigger destruction by clicking on “tear down” in the building’s menu or when using the destruction tool. The building enters a ” tearing-down” state that takes time,losing structure points progressively, and only disappears when the process is complete. When complete you recover half of its initial materials. The process can be cancelled before its complete.
Why this ? Mainly for multiplayer to avoid instant sabotage of cities where a player would erase its whole region in a second before its invaded. This doesnt mean i want to forbid players practicing this Russian strategy, but i eventually want it as a separate feature where you can set your whole city on fire. While a building properly teared down actually disapears and gives back some materials, a building violently destroyed becomes a burnt down ruin and remains on the terrain. It will still need to be teared down if you want to clear its space. Or you’ll be able to repair it at a lower cost. With this, repairing damages will be less of a hassle because coordinates and building types are preserved in these ruins, so you dont have to place again everything trying to remember how it looked. Eventually it will also be possible to trigger an auto-repair mode so damages are automatically repaired even if you’re offline.

New building : Flint collector
Stone tools now require a resource to be crafted : flints. And therefore there’s a new stone age building to produce flints (out of any gravely tiles). This building is  free as its one of the most basic buildings of the game.

Re designed fisherpig
I re designed the stone age fishing building to have a more unique visual identity.
The placement of infrastructures ( roads ect… ) has been refined and repaired. Its now designed to later support a broader range of infrastructures (ex irrigation canals, walls, gardens etc ).

I’m now redesigning the production building’s UI to make it clearer to read, and refining all their functionalities (like annex placement).

The Hog News 21

Lighting on terrains is back ingame, adapted to the new shaders. Also it now brightens exposed terrain (like slopes exposed to the “sun” ) instead of just darkening terrain in shadows.

Decorative citizens are back ingame. Unit camps ( formations ) now generate decorative units as well, matching the unit types and amounts present in these formations.

New building infos pannel
I’ve made a new building info panel (when hovering a building type button , in the build tab).
This pannel gives detailed infos about the building : materials required to build it, cost of these materials, maintenance costs,display preview, short text description of its role and other stats specific to the building type.
Exemple for houses you can see the life quality and health bonus provided by this type of house. Industrial buildings show the types of resource they can produce and what they need to do so etc…

Materials cost :
Unlike in the alpha 1 , materials now have an actual cost. It means that now, to build, not only you need to have these materials in stock but you will also need to buy them at their current price. The income goes to the porcos producing each one of these materials, making them richer. Also the price is affected by the player’s consumption : for exemple if you use lots of wood at once, its price will increase.
Here, because each required resource currently costs 1 coin , this building cost 5 coins to build.

Multi-language support
Also, finally, i’ve designed a proper system to support localisation. I will have to progressively update everything to make use of this, which will take a while.
With this system, all texts are externally stored in .txt files and indexed with a ‘key’ contained in the “index” files.
By adding new .txt files with a different language name in the filename, the game will automatically recognize these and they will appear as a new language option ingame.

By default the game will only include english and probably french (i’ll never get the time to do more), but anyone will be able to easily make new language files and share them with the community (and also correcting all my english mistakes ^^).
To do that all you’ll have to do is copy the english files, rename them with another language and translate their content.
However for now it will only be possible to support languages using western or Cyrillic alphabets, because i don’t know how to deal with fonts regarding other languages yet ( including all the possible characters of all languages would require giant fonts using too much memory ).

The Hog News 20

Progress is slowly becoming more and more visible again, as i finished refining most of the ‘core’ systems from the alpha 1 prototype.
I’ve also been away for about a week in vacation and i kept working on fixing various bugs and optimizations.

I’m busy improving systems to keep client data synced with server data in the most automatic and centralized way as possible, so a single system can deal with ‘everything’, making debugging easier and improving stability.
In a more concrete summary, i have restored and refined these functionalities from the alpha 1 :
– automatic building ‘AI’ spawning ( buildings beeing automatically placed and spawned by server instead of player, for things like slums and resource storages )
– cities displayed in worldmap, sync of world regions with server
– colonizing regions.
– basic region UI , also added a minimap at last!

The Hog News 19

In the last 2 weeks i’ve been pushing for big optimizations.

First of all, i spent about a week on pathfinding ( pathfinding is the system used to allow things like units to move in a map and find their ways ).
The previous system was too slow to find paths on complex region grids.
I’ve first learned about an algorithm called ” Jump search algorithm ” that is incredibly faster than the basic one is was using, especially to find paths on grids with lots of open spaces.
Considering there was little complete doc or tutorials about this except the actual original academic paper , it took me a while to really understand it as it was written in a quite opaque way ( at least to me ).
But there was a downside, as this algorithm only works for grids that have 2 values: empty tiles and blocked tiles.
This is not the case in Ymir where i need each tile to have different costs. As an exemple, roads are tiles that “cost” less than regular terrain so that if there is a road available, the units will tend to walk through these instead of regular terrain, as a unit will always try to find the path with lowest cost.
So i then had to actually modify this JPS algorithm to work with this type of grids and values. Its not perfect but its now incredibly more fast than my previous system and it should now be enough for the release standard i’m aiming, andenough to allow the more complex battles with walls.

This is to give you an idea ( and as its pretty much the only visual thing i have to show ).
Below is one of the exercises i made to test the pathfinding.
The left one is the pathfinding result and the right one represents the terrain where lowest costs are light green and highest one is purple.
Starting from left blue point, the objective is to reach the other blue point on the right.

The light green line would be a road. In the middle you have a vertical river with shallows in dark green in the north and a bridge in the south. On the left is a vertical cliff that the road crosses where its less sharp, and some buildings. On the right, there’s a ‘fort’ with walls in purple and a few buildings in it. The road goes through gates that are weaker than the plain walls. There’s a second wall south, and it has a weak point in green.

On the left you have the resulting path : the troop would reach the road going left, then follow it, cross the river south , follow the road to the gate and then go to the wall’s weak point. They then breach it and attack the left gate to enter the fort and reach the objective.
If there was no weak point , the would choose to cross the river north through the shallows and attack the northern gate. If there was no bridge and no shallows, they would have to cross the river itself.
No matter what , the path cannot fail and will always find a solution that will define the best available strategy, even if it means crossing river with small rafts, climbing cliffs with ladders or breaching walls.
However it can still be improved as its doing mistakes here : its doing 2 weird diagonal movements instead of going straight after the wall weak point, and it should stop following the road and go directly to that weak point instead of going up to the gate on the right and then back.

The time to generate a procedural region has been divided by 2 ( From about 8 sec to 4 sec ).
Its still not enough though for the release standard : because this has to be done by the server during the game whenever a player goes to a new region for the first time, it has to be really efficient so it doesnt make the server “hang” as it’s constantly busy doing all the other things of the game. So it has to happen while allowing the server to keep doing all its other tasks. The problem is not really the total amount of time it takes to make the region, but how its splitted : the server does it little by little so it can keep doing other things instead of just doing only this for seconds. So each little step has to be really short in itself, and that can be quite complicated to do. This is what’s been improved as well , though it might not be enough and will require more work.

Using shaders i’ve made 2 big optimizations to  improve framerate in regions. Animated grass and trees is now done by shaders, and the static grass drawn on top of the terrain cubes as well. Bottom line, the result is that regions have had their FPS greatly increased and also their loading time reduced. Its now satisfying enough for the release standard  ( at least empty regions ).