Monday, May 23, 2016

Moving on

I finally finished the new GUI framework which took ages to complete, but now I can finally have an easier and less frustrating time creating the GUI for this project. I've also tried to make the framework as user-friendly as possible while being flexible and able to do complex GUI's.

I've also began creating the GUI for the game using the textures and concept art I received from Samuli, when it's done I can continue working on the gameplay for the game, specially the character's skills.

I'm also eager to change the chunk size to 16 * 16 * 16 from 16 * 16 * 8 as well as adding the cube unwrapping so I can reduce the vertex count.

Wednesday, April 6, 2016

Upgrading

I recently upgraded from unity 4 to 5.4 and to my surprise the game is running more smoothly specially around trees.

Why I only now upgraded to unity 5 was because I did not believe it would boost the game in anyway specially in how unity handles custom mesh data (I wish unity would take arrays as references or at least give an option so that I can give it an array with an integer to let it know of how much of the array I'm using so I don't have resize the array every time...).

I also began to reprogram the GUI for the game, because it was lacking in features and it was quite a pain to work with, why I don't use an existing GUI is because I know what I want from it and I can optimize it for that purpose and to make it work the way I want it to. You might think it's reinventing the wheel and you would be right but if people don't at least study or try to create something that has already been done they don't advance as a programmer, besides I've already done this once and I can create modding support and modding tools for it at the same time.

I've also been thinking if I should sell the GUI in the Asset Store, but I'm not sure if anybody will buy it and if it's worth all the hassle to get it into the Asset Store. I also been thinking if I should join Patreon and if I do then I'll just share it for free there...

More on the GUI, it will be fast, responsive, automatic scaling and relocation based on resolution, it will have buttons (with a delegate, mouse over, down and normal textures and a tooltip), uniform and sliced scaling, text (which is rendered from a bitmap), able to use a texture and render it in a circle with a varying central angle and to create a drop down menu with menu items hidden outside the menu even when scrolling, the GUI will be stored in an XML file and if the GUI was not saved it will be also serialized to the scene or prefab so no changes will be lost, also because it can be saved into an XML file changing the GUI while the game is running is possible and it's possible for the user to change the GUI, this of course can also be disabled, the GUI can be modified either via the scene or script.

Thursday, March 10, 2016

Information for you, sir.

So I haven't told much about my game other than it having epic spells, "living" AI and things to build from items to cities and governing of cities, what I've yet to tell you is that as you, the player, can be mostly anything in the game and I'll try to make it interesting, of course being a peasant can get quite dull after some time but you can always move on from that from a peasant to a dictator having peasants.

What I'll try to achieve in this game is a living world where the npcs can do something big which can change a city by a lot, for example an npc finds a book of undead and decides if he should start reading it or not, if the npc begins reading the said book he will probably change into a necromancer and built a cult somewhere near the city and most likely attack the place after the npc has gained enough power. This might sound big and very scripted, sure there is "scripting" involved but I'll try to make it very random on how it will proceed based on the npc's personality.

There is also a concept of good and evil but its not based on what we declare what is good or evil but
based on the religion of the village, which can change over time, a village might find cannibals saints and people who help others evil.

Speaking of religion the gods of a religion might or might not exist at all depending on how many believes in a god of specific religion, by this way it is possible to make the people of a vast land believe or fear you so much that you might gain divine powers, what you can do with these divine powers I've yet to design but one possibility is creating a new race (which should be easy as everything is random generated), it would also be possible that npcs could disguise them as you or some other god and gain popularity in areas or possibly even overthrow you as their god.

Now you might think that doing all this is impossible or a project that will last for an infinity, you might be right but that's why it's called a seemingly impossible project. All of the things above need careful planning and designing before they can be programmed and I've already began doing all the planning and designing. Most of the world will be simulated in a very high level by using time as the controlling variable, everything important like kings and queens, leaders, necromancers, people you meet, people you love, people you work with are simulated in a low level so they actually do stuff in the game, the more you are involved with an npc the finer the npc is simulated.

Of course that's not all there is to the game as you can do all sort of things from crafting to skinning beasts, you will level up your skills as you do a specific task over and over, for an example if you poke enemies with your dagger enough you will be a master poker and a master in using daggers but you also gain better skill to weapons in the same category of one-handed weapons.

That is all for now, in a moment I'll forget everything and I'll have to read all of this before I can continue working on the game again, but hopefully at some point, at some, most likely a distant year I've finished this project (Seriously though I'll be working on this game every week and most likely everything here that I mentioned might be removed or changed, who knows).

Wednesday, March 9, 2016

Rivers, streams and more optimizations

I found a way to optimize the noise function I'm using by reversing how I calculate it and without calling it for all the cubes in the same X and Z coordinate in one chunk, but just changing the Y calculation in the end of the noise function. This allowed me to create the heightmap 100 (or something like that) times faster.

Why I began poking around the noise function was because I'm trying to add water to the game but
adding rivers and streams is very hard (at least making it fast enough), so incidentally looking for a way to add rivers via heightmap I found the optimization, although it didn't help me much in adding the rivers. I need to add some sort of flood fill algorithm to the noisemap to add rivers (streams are harder) and modify the values accordingly, though this is quite hard as overflow of the water can happen easily...

I also received new GUI graphics from Samuli which I have to add to the game, but before that I have to reprogram the GUI framework so I can modify the GUI more easily and add more features to it as well, I'll also add support for players to modify the GUI.

Here's also a webm of the trees that I got working in the game, I'm a little worried on how much objects I can actually let the player see before it fries their GPU.
View post on imgur.com

Saturday, February 20, 2016

Data, so much data...

These past two weeks I've been fixing and creating the saving functionality and adding trees to the game, as I began to add trees to the game, I noticed how much data I have to store and process.

Currently I only store chunks that have been modified by anyone in the game and I'm looking at storing the noisemap, heightmap, treemap and biomemap, currently the problem is storing the treemap, it's easy to store if a certain location in a 2D plane has a tree but if I want to store multiple trees into a certain location, I have to store the height and the type of the tree, of course I could store this data in chunks like.. the chunks, but I could save quite a bit of space if I don't store the type of a tree but just the height but even then it's quite much.

I'm planning on creating a map of a size of 131072 * 131072 * 512 which is quite large (I don't plan on creating an infinite map because there is no point in that), the treemap for multiple trees in a certain spot would be a short type which is 16 bits which in turn is 16 trees upwards, this means that the treemap would be 274877906944 bits which is 34 gigabytes, sure I could compress this to make it smaller but I don't see the point because I plan to have the data ready to be used in the game and compressing and decompressing takes time (Because I plan to have multiple save slots I will compress the whole save to save space), but just as I wrote earlier I will be storing these things in chunks so the game won't eat the whole 34 gigabytes from beginning.

As I don't know how much of the world a player will actually discover I can't really estimate how much space a single game would take, so I'm just trying to plan ahead and try to minimize how much space a save will take.

The cube chunk is stored directly in bytes, int index, float x, float y, float z and then all of the 2048 cubes but only the cube type which is a short, so in total a chunk is 4112 bytes which is around 4 kilobytes.

If you're interested in what I've already done, check the older post to view the list of tasks.

Wednesday, February 3, 2016

Onwards

For now I've finished the basics of cube construction and removal so that the player's character
will move and do the certain tasks. I've also gained more GUI graphics, textures and trees from Samuli which I need to add.



Here are some of the things that I thought of that need to be either fixed or done.

- Fix the mouse raycast to work better, specially to be able to fire upwards. // Fixed and optimized.

- Fix the problem that the character floats when building or removing.

- Fix the movement of the character so it does not get stuck.

- Fix the pathfinding lag when building/removing cubes.

- Fix the issue when using actionpoints in pathfinding that the character is
not able to move to the edge of the map.

- Update the GUI with Samuli's new graphics.

- Refactor map generator and make it so that it can generate much bigger maps.

- Add a timer bar above the character when it's building or removing cube.

- Gain cubes when mining them and use cubes when building.

- Saving and loading of chunks.

- Saving chunk exists check to a file.

- Saving and loading of other map related things and characters.

- Add the trees Samuli made and so that they can be cut down.

Create tree creator.

- Add iron veins.

- Add crafting (food, potions, equipments).

- Add equipment and items weapons/armor/potions/etc.

- Add graphics for items.

- Add the rest of inventory functionality (dragging items done).

- Add better way to build or remove cubes.

- Add a 3D model for the character.

- Add magic functionality.

- Finish the combat system, so you can dodge/block/etc when an enemy is attacking.

- Add weapon skills.

- Add enemies and neutrals to roam around.

- Make npcs fight each others.

- Add loot and equipment to npcs.

- Add foraging for food.

- Add "fluid simulation"

- Add basic survival gameplay.

- Program so that the character can be seen indoors, possibly by cutting everything above the character and do a sort of reverse frustum culling to the camera so it cuts everything between the character and camera.

- Try to find a way to view stuff inside a house or cave so they don't get cut out (possibly do a some sort of fluid simulation).

- Add interraction with npcs.

- Add water and plants.

- Add caves.

- Possibly recreate the GUI system.

- Add better functionality to the cube creator.

Thursday, January 14, 2016

Work work

I've been currently working on the gameplay so I could present this project to other people and for myself so that I can see if this project is going to work or not, as well as making this an actual game rather than a tech demo.

What I've already done are rather simple things such as basic turn-based combat where the player can move a certain amount and strike the enemy if the player has enough actionpoints, the same thing is done for the AI, it moves closer to the player and attempts to kill the player, it's crude and not finished but it's still something.

Other than that I've been working on spell list and inventory, I've create an item creator from which I can in the future add items with descriptions and other things, this data is then stored in an XML file (I don't really like XML but as it is native to C# it was the quickest way) which a player can modify as well.

I only programmed the item creation so far as I have yet to figure out what I actually need to store into an item but for the moment these are the variables :

int id;
string name;
string description;
string iconSpriteName;
ItemTypes itemType;
int maxStack;
string cubeName;
int cubeIndex;

The ID is self explanatory as is name, description, icon sprite name, max stack and item type, but for the cube name it's actually the cubes ID from which I can get the cubeIndex, the reason why I use cube name as the ID is because as I started creating the cube editor I figured it was all I need, but it dawned on me, it would be easier just to use and actual integer ID like that for the item... So the cube index is gained at runtime with the help of each cube name.

What I've yet to create and finish are the inventory so that a player can pick up items, use and equip them, spells also need to be programmed as I have not yet touched them, I also need to add more tasks for the character so it can shovel/mine cubes and place cubes but this requires the inventory to function and lastly I need to add levels and other statistics for the players character which will increase as the players does something.

I don't know if that was all that I will be adding but I only really want to create the basic structure of the gameplay so I can expand it and modify it if does not work.

There are some things that worry me, like the angle of the projection from which the world is seen from because as I create a pretty big world can it be seen in all it's glory from that angle, is the player satisfied with it? Other thing that worries me is the gameplay if its fun to play but that is an universal problem with every game so I do try not to worry about it.

After I have finished or should I say satisfied with the basic gameplay I will continue on the world generation for a short while to adjust things and maybe add an optimization, the optimization is that I will unwrap every cube's textures into a single large texture so I can combine verticies together, currently all sides of a cube are rendered separately, so if I stack one cube's textures next to each other I can use them like this cube unwrap.

After that I'll move on to programming the first village, I will start by simulating the village in a very high level which would only mean generating resources and expanding the village only by calculating and then continue to a very low level at which I will simulate every characters needs and such.