The benefits of invincibility

Today’s blog entry is a pair of screenshots, which show you a ton of what I’ve been working on this past week of nothing-but-coding. This is when I looked at myself in the middle of combat with two enemies (both off-screen to the left), and what kind of information shows up when you do. Until next week, I leave you with some violence I have only survived because the player character is currently (for testing reasons) invincible. Basically, this screenshot should showcase the query function – listing creatures and objects on a square – what querying a creature looks like, and a few recent changes to the UI. There’s also been a ton of work in creating libraries of weapons/materials, the mechanics of wielding weapons/wearing armor and lots of other stuff, but I’ll talk about that next week. I know it needs a bit of fine-tuning, but basically, things are really coming along now. Until next week!

And also a less exciting technical one dealing with equipping weapons, inventory management, etc:

The many properties of a U.R.R. item

This is partly a follow-up to the some of the discussion in the comments page of the previous entry. Still, if you’ve read that (or haven’t, and can’t be bothered), this post is about items in U.R.R, and the many, many ways in which they interact. Alas, since a list turned out to be a much better way to talk about items there is no flowchart this time, but our normal flowchart programming is sure to resume soon enough.

First, it’s worth noting not all items have all the same properties. Potions do not have a “material” property because all potion bottles are made of glass. Scrolls, likewise, because all are made from paper (and highly flammable paper at that – take note!). Similarly, weapons have more properties than armour, which in turn has more properties than alchemical substances, and so on and so forth. Because weapons a) have the most properties, b) are a vital part of what you & your allies go into battle with, and c) are almost fully programmed, this entry is going to focus on weapon properties. However, a lot carry over to other item types too.

Volume – all items have a volume. This determines how many can fit into a single square of the map; how many you can fit into containers; and, on a basic level, simply how large it is, and therefore how likely it is to hit someone if thrown, for instance. No longer are roguelike boxes of endless depth; you can only fit so many bodies in a container before you just can’t close the damned lid.

Weight – all items have a weight. This influences how far you can throw them, how clear a trajectory they take (momentum!), how much you and other creatures can hold at any one time, how likely ice is to crack if you put it down on it, etc. Some items are simply too heavy – no matter how strong you become, you can never carry a full Titan corpse. A Titan, head, however, is a rather more manageable weight (and volume, for that matter).

Melting Point – applies to almost all items, but non-metallic items have this functioning as a “burning point” rather than a melting point. This ties in to the previous entry, therefore – if you charge into battle with any fire-breathing creature wielding your wooden club high above your health and covered in wooden armour, you will shortly find your club destroyed, and everything you’re wearing on fire. Which will, of course, burn you until you take it off. On the other hand, a full set of tempered steel will stand up rather better. I am considering putting in a freezing equivalent whereby items become brittle, can shatter, etc – thoughts in the comments on this if you have any!

Material – this determines how it behaves in certain environments. Metal rusts in water; wood rots in water; etc. Closely tied to melting point.

Damage – metallic swords, for example, can be intact, notched, damaged or badly damaged. The damage an item takes from use reduces how effective it is combat, and its value. As with most games, you can repair these things yourself given enough skill – and a campfire, appropriate smithing tools, time undisturbed by foes, raw materials, etc – or simply pay some random civilian to do it for you. That’s what they’re there for!

Decay – closely tied to material. Rusting, rotting, etc. Once again, reduces effectiveness, but not as severely as damage. Can also slightly change the effect of a weapon – an intact longsword is better at slashing, while a badly rusted one is much less powerful, but might cause nastier wounds. This is never a worthwhile trade-off, but keeps weapons semi-useful even when twisted, blackened wrecks.

Enchantment, blessing, quality, alignment – determine, respectively, damage added on to every attack (e.g. +3); a variety of effects (the undead hate blessed weapons; cursed weapons can be tricky to get rid of; etc); the multiplier to the price it fetches at market; and what alignment of foe it is particularly effective against, if any.

This page is subject to change before the alpha release, but if you ask the game to show you the detail of a weapon, a larger window will appear and show you:

Tempered steel longswords are the peak of the class of ‘sword-like’ weapons…

This also, of course, shows another feature I haven’t even mentioned until now – weapons have a history, which keeps track of particularly noteworthy creatures you killed, and how you killed them. Perhaps, if you kill enough uniques with one weapon, the rest of the world will come to regard that blade as an artifact…

Anyway – weapon histories being a whole series of posts in themselves – the white text denotes the best possible outcome in that category. In this case, an unrusted sword. Light grey denotes the second best – the “particularly sharp” modifier is below the sharpest that bladed weapons can be. Runic information will be displayed in the appropriate colour, while the histories are displayed in descending order of fame (and, therefore, strength of creature slain) and likewise descending colour.

So there’s a pretty comprehensive summary of weapon properties, at least. All items can, of course, be thrown in to fires or carried with you across lakes if you want to find out what happens. More will be said on this in time – particularly on modelling fire, and cellular automata – but until next time: don’t fight dragons with wooden armour.

Coming Friday: Detail of the morale system, or: how to terrify an Orc into insanity (Part 1).

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


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.