Size and roguelikes

Just a quick entry this week. I’ve been coding every day this week (apart from one where Dead Space 2 interposed itself) and a ton of work has been done, including more combat mechanics, severing limbs, armor and weapons being tethered to limbs correctly, displaying all possible combat messages, creature queries displaying more injury detail, species pages on creature queries, pathfinding, and starting a new ‘class’ of enemy.

This class is for enemies that are larger than just a single square. Originally I was intending to stick with the roguelike norm – any creature, whether a Titan or a gnat, takes up just one square on the map. Increasingly, however, I thought this was a terrible idea, so I’ve decided to allow some creatures to be larger. Some creatures can be two squares (e.g. ‘Q’ is the symbol for large quadrupeds, so an elephant may be ‘QQ’), some creatures can be four squares, some nine, one creature can be a long sequence of letters (which will be unveiled far, far in the future) while another species is totally unique (and equally far off). The only one of these to make it into the first alpha will be dragons, and so I leave you with a screenshot of a dragon attempting to fry me. The fire is in its early stages and needs a lot more work; as for four-square-creature pathfinding, large creatures normally have the ability to knock aside trees, and may (depending on strength and other factors) be able to break through walls and similar.

The Case of the Penrose River

For the past little while, rivers have been the priority for world generation. I’m hoping to have rivers entirely finished by the end of this week, ideally, so that I can then move on to working on mountains in more detail. So, without further ado, let’s talk about the mechanics behind river generation; how I’ve got them tracking their way across the landscape; and the uses of rivers to the aspiring URR player:

Why have rivers at all?

Well, for a start, they will play a role in determining where cities and villages spring up. Both are naturally more likely to appear near rivers due to fresh water access. Cities, however, will greatly prefer wider, more substantial rivers (especially if near the coast; fresh water & trading potential) while villages will be much more content with smaller supplies of water.

They also, obviously, provide fresh water for both the player and the majority of other creatures in the game. Sticking to rivers will make sure you always have a supply of water – and many useful plants, trees, and similar grow nearby – but other creatures of all shapes and sizes might have to come down to feed at some point. Cyclopes might be intelligent enough to create a well, but would a Behemoth be as sensible?

Thirdly, and most obviously, it wouldn’t be a world without rivers. Mountains generate rainfall, and rainfall has to flow somewhere, after all. Regardless, following rivers will always take you in the direction of either the ocean, or a lake, and likely passing by some signs of civilization en route. There will be a visible sign of the direction of flow; I simply haven’t added this yet, since it’s currently more important to get the rivers generating correctly for now.

Click to see full size! A river cutting a valley.

How are rivers formed?

Once height and mountains have been established, the game checks for mountains on the outsides of mountain ranges, and generally those that are part of a long-chain. Then, it attempts to make it the source of a river, which will happen if there are no other rivers in the immediate 3×3 grid around it. Assuming that’s the case, then the river draws itself across the map, moving orthogonally from square to square.

Rivers move from locations high on the heightmap to low ones. When they try to go through a higher square, they either a) go around it, b) carve a valley through it, or c) turn into an underground river which empties into the ocean somewhere else. If they reach the ocean, they turn into a delta or waterfall. If they have to terminate elsewhere, they end in a lake or a larger basin, depending on the flow of the river.

Rivers can also combine. If one river finds another, they will connect, and the flow of the two source rivers will combine to lead a stronger river in the future. As mentioned above, cities and civilizations are likely to grow up around larger sections of a river than smaller ones. The flow of a river determines its width, and the size of the delta or lake it might eventually create.

What is the Penrose River?

I have spent quite a lot of the time I’ve been working on rivers making sure they can never loop. Which is to say, a river cannot turn back upon itself and join up again, and end up in a loop. As was pointed out to me on Twitter, this effectively turned the ever-flowing-downhill rivers into Penrose Stairs.

Water cannot do this any more than stairs can.

Happily, this has now been dealt with, along with all issues of flow, loops, multiple lakes, and other kinds of garbage. Now it’s just a matter of, on the ‘local’ map – ie the human-scale one the player walks around on, rather than fast-travelling on the world map – making sure that rivers work out correctly along with all the cliffs, hills, coastlines, biomes and everything else…

Coming Monday 26th: Winter Screenshot Update!

Coming Monday 2nd: Thoughts on ‘realism’ in games, and in URR.

World map and battlefields

Today, we’re going to talk about the world map of Ultima Ratio Regum. Originally, it was a mere million squares – 1000 x 1000, and I somehow expected that to hold an entire world. This was, I will admit, a tad naive. Now that I have found a way to generate, load and save only portions of the world at any one point, the world has shot up in size. It is currently 40,000 x 40,000, but this can be increased by just fiddling with a particular variable. This makes the world map over 1.5 billion squares in size, and much more fitting for an entire world.

Firstly, the map is divided explicitly into cells. The world map is 200×200 squares, and each of these – be it a mountain, a gorge, a forest, a city – can be explored on a ‘human-scale’ map of 200×200. The world map can be viewed, or moved through, and looks like the picture below. It is only a snap of a world map, and I’ll unveil a full example later.

– Moving on the World Map

You can move between squares on the world map. This is effectively fast-travelling. When you enter a new square, it will become explored, and then you can see it on your world map. When you both enter and exit a square of the world map, you will be informed whether:

a) You or someone in your group has located something in the square

b) You or your group has been attacked.

On the world map, you cannot fast travel through squares that are ocean, desert, gorges, or mountains. These must be entered directly to pass through; you must find your way across mountain passes, traverse gorges, or take enough supplies to make your way across the desert. You could also find your way across the ocean, though I’m not yet quite sure how that will function.

The larger your group, the larger the chance is that you will find something if you fast travel through that square. Trekking through with an army will locate every last nook and cranny in a square; simply fast-travelling yourself is likely to miss almost all the dungeons, towers,
forts, villages, monoliths and whatever else that square might contain. The further you move from your starting location, the less friendly the intelligent races will be (if you stray into their territory!) and the tougher the creatures will likely be, so it is wise to explore your initial area thoroughly. With each subsequent version, the each world map square will fill up with more and more – for the initial alpha, I’m still hoping to have a lot of variety in environment and features in each map grid, but this will only increase.

If you are attacked, then depending on who attacks you, what direction you are moving, and what direction your attackers are moving, you will be taken into the map and delivered into the battle. The larger your army, the more warning you will get, and therefore the longer at the start of the battle you will get to arrange your forces. If you’re on your own, you might not see the foes coming until they’re almost upon you.

– Moving across the world normally

If you move across the world normally, you come to the edge of each square and the transition into the next one along is explicit. While I considered keeping the map smooth and glossing over the transition between world map grid-squares, I wanted to make it clear where one battlefield ‘starts’ and where one ends. Additionally, if you leave a battlefield during a conflict, this will have an obvious psychological impact on your army, and will
likely cause them to rapidly scatter. It also helps you keep track of your progress without having to always refer to the world map!

Map generation isn’t totally finished – more work on volcanoes and islands are needed – but it’s getting there, and much faster than I ever expected. Weather systems will exist, but they’ll have to wait or a later update. At the moment, the map contains ordinary land, forests, mountains, gorges, and volcanoes. If anyone can think of any other geographic feature to add, throw it in the comments, and I’ll see if I think it’ll fit!

Coming Monday 7th: Some thoughts on uniques, ‘bosses’, and how exactly leveling should work. 

Coming Monday 14th: The final world map!

The Great Alpha Consultation

Welcome blog readers! This post is intended to give up-to-date info about the current state of Ultima Ratio Regum and my initial plans, and to let you – wise, well-traveled blog-readers that you are – tell me what features you’re most interested in seeing.

The alpha currently looks like this (click either to enlarge):

Currently, the initial alpha has four key focuses. They are as follows:

– Creatures.

Currently, all creatures in the game, player and AI alike, consist of a large number of body parts – heads, arms, torsos, legs, wings. The system I’m using allows any number of each body part be added to a create – say, three heads for a Hydra, or six arms for a Naga, or eight legs for a giant spider – and the game works things out based on this information, such as: how many legs does it need to walk?; how many weapons can it hold?; and similar. This relates to what counts as a kill – if a creature has one head, it only takes one broken neck or one shattered skull to slay it. More heads means a tougher foe.

By time of release, I hope to have perhaps a dozen different species (with their own subtypes, classes, etc) wandering around the overworld, and, hopefully, in dungeons. Depending on what people say, this variety could be a key focus for the early alphas. However, I am inclined to keep the number of creatures relatively small until you can recruit the intelligent ones and tame the animal ones properly…

– Combat.

Creatures will aim at whichever part of their foe’s body they think is most damaged. The player, on the other hand, has free choice of which body part to aim for, the success of which (as with creatures) is dependent on Dexterity. Body parts are not just “arms” and “legs” and the rest – each breaks down into many smaller component parts. A head, for example, can consist of all or few of: flesh, a skull, horns, eyes, ears, a neck, a jugular, and a windpipe. Damage is handled appropriately – a slashed jugular fountains blood, while total loss of eyes results in blindness. I am uncertain, thus far, how you – and other creatures – can regain lost limbs if they have time to heal themselves after a battle. Anyway – the alpha focus is on the depth of combat involving damage to flesh, damage to bone, damage to body parts, how damage to difference areas affects how you/a creature perform in combat.

You can also pin things to trees with a halberd, or knock them into a river with a battleaxe lodged in their skull, down which their corpses might subsequently float.

– AI.

Creatures will regroup, assess the battlefield, charge, flee, berserk, pick up and drop items, exchange armor, manage their ammunition, and more. A group from the same species fighting in unison will follow the orders of whichever of them is considered the ‘leader’. If not the player, the leader will be the creature they consider the most impressive – this is another potential focus for the alpha. I want to have creatures rising and falling within their own civilizations based on how impressive (or not!) their deeds are. If you are leading a group – recruiting allies has been greatly simplified for this first alpha – you are able to give commands to those under you, who will in turn give commands to their underlings. Again – if people think this sounds like an interesting focus, it’ll get more initial work. AI and army management will nevertheless be a central focus of the game in the long run.

– User Interface.

This is one I want a lot of feedback on. For any complex game – and therefore, any roguelike – a good UI to tell the player everything they need to know quickly and efficiently is vital. In Ultima Ratio Regum, you can view the condition of the body parts and armor of any creature (yourself included) that you investigate using the ‘Query’ function. You also get information about their alignment, faction, species etc, but that’s all in the very early stages. Key mappings cannot currently be changed, but I think they’re all pretty logical (‘e’ for eat, ‘w’ for wield, etc). Still – as the game becomes more complicated, I want to keep the UI as smooth and easy to use as possible.

So, those are the four major points I’m focusing on for the initial release before the end of this year. The initial question, therefore, is – do any of these strike you, reader, as being particularly worthy of initial attention? Which need trialing early? Which can wait? And is there any one of them you think looks the most important? While I hope to get all four to a reasonable standard before the end of the year, one in particular can certainly become the main goal if many people argue for it.

 

Beyond the first release, and those four major goals, there are other objectives. Again – opinions on which of these people want to see first would be great.

 

– Riding.

Currently, you cannot ride anything. Riding will both increase your effective health – since some hits will hit your steed – allow you hit higher off the ground against tall creatures, and potentially allow you to move faster, depending on how I get the speed system worked out. You will obviously be able to ride horses, but also a variety of other creatures you might tame.

– Siege weapons.

Ballistas, catapults, trebuchets galore! Load them with whatever you want; rocks for damage; burning pitch to set things on fire; or the corpses of your foe’s allies to devastate their morale.

– Taming creatures.

Just as intelligent creatures can be recruited, some animals can be tamed. The process will likely involve tracking them down, providing them with corpses or animals to hunt, aiding them, all the while making sure they don’t decide to take a bite out of you. Trying to tame the stronger wild creatures could prove interesting…

– Initial magic.

While basic spells like ‘fireball’ and ‘magic mapping’ will exist – at least, for the time being – I have planned complex systems for necromancy, geomancy, pyromancy and hydromancy. Generalized magic will come first, and the other four will come after. Only certain classes of certain creatures will be able to use magic – it will be a relatively rare, high-level endeavor. At least, beyond those basic spells.

– World generation.

World generation is currently basic. It includes ruins, mountains, land, forest and oceans, but they do not structure themselves in a particularly logical manner. In order to improve this, I think I will significantly need to rework the way maps are stored, which is proving difficult. Anyway – eventually I want both a greater variation in landscape, and a logical progression between deserts and plains, tundra and taiga, etc. Species and their cities will spawn in their appropriate areas.

– Villages.

Villages will be small, contained, and can be ruled by any number of different things – a powerful member of their own species, a member of another species, a worshiped creature who resides nearby, a demonic creature, or anything else. Some villages might contain people secretly practicing necromancy; others might harbor escaped fugitives; others might be under the thumb of a larger empire nearby; or anything else. I will likely implement villages prior to cities, but I’m not certain.

– Cities.

Cities will be few and far between – perhaps only three or four per world generation. They will be large, contain a high number of creatures from their respective species, and be an obvious hub for player activity. In a way, the number of cities can only become higher once a superior map system is resolved which allows me to store much larger worlds.

– Survival.

Whether on your own, in an army, or leading an army, you need food, water, and shelter to survive. The larger the focus, the greater the logistical requirements. Even if you’re on your own, you’ll need a fire to keep warm and ward off creatures; food and water to survive; and ammo, and… everything else an adventurer needs. This will be a big move towards realism, and towards the ‘strategy’ aspect once you get an army up and running.

– Armies.

At first, a player starting a game will be on their own. Then, you can join an existing army and fight in their campaigns. Then, if you survive and rise up the ranks, you can lead an army. This is a big one. As soon as this becomes a little more complex, the easy alpha ability to recruit allies will be removed, and you will instead be able to find a military to enlist in. Or, y’know, don’t, and go around in a band of vagabonds. Whatever takes your fancy.

And so, without further ado, here endeth the consultation. If you want to be kept updated, you can read this weekly devblog, join the Facebook group, the mailing list or follow the game’s twitter at UltimaRegum and be notified the moment the alpha appears!

Coming Monday 17th: Weapons. Lots of weapons.

Coming Monday 24th: Options for a new player, and embarking on your adventure.

AI that cares about itself

The challenge: make AI that cares about its own survival, like any real-world creature, but provides interesting gameplay and doesn’t simply flee at the slightest sign of trouble.

The solution:

As the about U.R.R. page notes, a major design goal for my game is the AI. I don’t want AI that just runs blindly into your sword-swings like in most games. Ultima Ratio Regum is instead populated by creatures that – while they have their own objectives, often involving killing the player – also care about their own self-preservation. An Orc will not charge into combat with a Titan by itself; if pressed, it will flee, and if pressed further, it might even lose its mind from terror. Hilarity ensues. Other activities – such as allies fighting over a good item, or rallying their team-mates – hopefully contribute to the realism and self-serving objectives of the AI.

To demonstrate something about the AI, I present to you this flowchart. Before you look, it is worth first noting this diagram is something of a simplification. For example, if a creature sees an item they want, they do not automatically go after it – there is instead an algorithm involving how much they want it, how far away it is, how good the item is, how close they are to an enemy they want to kill, and a few other factors, all of which come into play to decide if they stay where they are or make the detour. However, this diagram still demonstrates the connections between varying conditions – indicated by diamonds – and states, indicated by the shaded rectangles.

Flowchart of Ultima Ratio Regum AI
Click for a larger version.

Now, this diagram only applies specifically to creatures who are trying to kill you  – it makes no note of neutral creatures, monsters attempting to kill foes who aren’t the player, and allies. All of those will come later. Additionally, each ‘state’ – the rectangular boxes – will be examined in more detail in later blog entries. For now, however, let’s talk about a few of the most important points from that diagram.

– Starting states

Monsters – barring a few, rare, exceptions – can only be spawned as the black states. If they begin wandering, they just move themselves around the map. Monsters who begin waiting will remain where they are until they catch sight of an enemy. Guards will remain at their post until they either see a foe they despise so much they simply must come out and fight, or – much more likely – until they are attacked, or in some other way angered. Some monsters can spawn sleeping, in which case their behaviour until they are attacked, or hear something that wakes them, is pretty self-explanatory.

– Morale

This system merits several posts of its own. Firstly, and foremost –  it is not designed anything like morale systems in other games, which I’ve generally found to be aggravating, and often seem rather arbitrary. In Dawn of War, for instance, I recall lone groups of soldiers sometimes fighting to their deaths and sometimes instantly losing all their morale with no apparent reasoning. While I intend to keep the specifics of the morale system hidden, it is designed to emulate as closely as possible a player’s evaluation of the battle. Which is to say – if a monster thinks it has a good chance of winning, or something happens that reinforces this view, it gains morale. If it thinks it might lose, and something that might reinforce this view occurs, it will lose morale. Monsters – especially in larger battles – are getting increasingly skilled at judging the pace of a battle they’re involved in, and deciding whether or not it’s worth fighting you to the end, or fleeing to wait another day. Again, an entry for another day, but variables as diverse as the armour you wear, the damage to a monster’s body, your combat history, the states of your allies, and even stories of past fights you’ve won that your enemies spread amongst themselves play a role.

– Artifacts

Monsters, like players, love artifacts. If they see one – and are intelligent enough to recognise what it actually is – they are almost certain to drop anything they’re doing and make a dash for it. However, because many factions have a rigid command structure, stronger enemies will often bully/persuade weaker allies to gift artifacts to them. Disagreements can occur, and therefore battles between allies can even take place over artifacts, potentially deadly if neither party backs down…

As this forms one of the cores of the game, any feedback about logical/illogical paths in that flowchart – or other additions that seem reasonable – would be great. In the mean time:

Coming Friday: Introduction to U.R.R. items – from damage to decay, volume to weight, and material to melting point…

Coming Monday: Detail of the morale system, or: how to terrify an Orc into insanity.