Monday, 1 December 2008

Designing a Magic System - Part Fifteen (On Hacks)

(You'll probably want to read parts one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen and fourteen first).

The school spell lists as I designed them in part fourteen are intended to be a mix of banding tradition as well as an attempt to find new ways of making magic in Unangband interesting. I've been inspired here, as much elsewhere, by the design work in Sangband and elsewhere by Leon Marrick and although aided by many, this particular series of articles is dedicated to him and the insight and inspiration he has given me and many others.

Angband is a game of resources: and each magic school has a different way of handling the resources of light, food, escape, healing, mana (spell points) and item identification which help define them. Wizards have no reliable source of food at all, and no high level healing, but can readily concentrate mana to recover it and have the most flexible range of escape spells, and both the ability to light rooms as well as to use light as an attack, and to replace their fuel based light source with a magical spell which can be indefinitely powered provided that sufficient mana is available (and that the wizard is not plunged into darkness by letting this spell run out - spells require light to be read from their respective spellbooks). The Unangband Wizard has the ability to take advantage of magical items such as wands and staffs: both with a spell (gauge magic) which readily identifies the number of charges that the item has, and a recharge magic spell to replenish these charges as they are used.

I attempted to balance the flexibility and power of the wizard escape spells by limiting them significantly for the other magical schools. Druids can only teleport to and from water or natural areas (defined as being adjacent to plants), masters only to and from darkness, thaumaturgists require a nearby source of fire, and sorcerors can only teleport temporarily, returning to the location that they teleported from after a moderate amount of time passes. This was done to allow other escape spells, such as temporary hasting, and spells which shape and change nearby terrain, such as wizard lock and warp wood, to be preferred by these classes in various ways. However, the escape spells are much less flexible, perhaps too inflexible, to be reliably used, and since escape is of critical importance to magic using classes it may mean that the wizard ends up being the preferred class choice for Unangband players.

Druids are encouraged to manipulate their surroundings and many druid spells have been made synergistic with each other: while they can only teleport near nature, they can create trees to bring nature to them in the first place, and then these trees can be used to tangleroot opponents or recover health using the tree of life spell; similarly the mana pool spell draws mana from nearby sources of water. Once opponents are entangled, it becomes much easier to affect them with slow building natural attack spells which are their forte (a yet to be implemented forte at the moment unfortunately), and the ground can be further prepared by shaping the rock by turning it to mud. Food for a druid is trivially satiated with a single spell, light is randomly scattered around them as opposed to lighting up whole rooms (which encourages more preparation to 'fill the gaps'), and item identification through a useful but obscure system of runes which hint at a particular items function.

Masters summon monsters, and while the friendly monster AI is powerful and flexible enough for monstrous combat between the master's allies and enemies, I need to give the master more granular control for when they summon multiple differing types of monsters. To encourage the master to have more investment in their minions, I've added a Find Familiar spell, which summons a unique creature that the Master can tailor over the course of their career - but if this creature dies, it is lost forever.

One thing I've enjoyed doing with various master spells is monster design: in particular the Animate Dead spell requires I come up with undead versions of various body parts and creature types. I'll say more about hacks shortly, but I've implemented this as a blend of hacks of various kinds, instead of a 'purer' convert a monster to undead function. The sorceror's Animate Object has been similarly entertaining.

Masters relish darkness instead of light, attacking with it in various ways, teleporting to and from it, and consequently have a temporary infravision spell which allows them to detect warm blooded monsters in the darkness - I should also add a Night Sight spell which provides further visual acuity at a higher level. High level healing is acquired by draining the life from living enemies (or allies), which simultaneously feeds the Master, and mana can be acquired by sacrificing hit points in return - since Masters need mana to pay off summoning debt, it could be overpowered letting this be more readily recovered. Item identification provides a general hint as to whether an item is beneficial, and what approximate effect it has.

Sorcerors are a mix of traps, charm spells, mental attacks and shape-changing: charms being more effective than the master's abilities in summoning, and shape-changing very much a work in progress. I've probably gone overboard in terms of making shape shifting unfriendly for the player to use as it forces them to discard equipment in various inventory slots. I suspect I'll move back to the Oangband/Sangband style solution of making shape-shifting just affect player attributes. Sorcerors are almost as flexible as wizards in the ways they can escape, perhaps more so, but lack a pure 'get away and stay away' single turn spell. They are superior to other classes in their item identification magics, and instead a source of sustenance, they can readily slow their metabolism to prolong the effects of food they have consumed. Sorcerors lack any ready source of light, healing or mana however, so will be forced to scrounge for other methods of illuminating the dungeon and recovering from wounds and spellcasting.

Finally thaumaturgists are attack, attack, attack, with a mainline in randomly assigned elemental types (to be implemented) and a sideline in acid and fire magics. They can usefully renew their torch flame to allow unlimited light and step into flames to teleport and escape but otherwise lack any utility spells.

After spending fifteen parts discussing various design decisions to try to come up with a consistent and systematic method, I've yet to find a solution. In particular, my answers are variations on two themes. The first is a refutation of the argument I made in part one, that 'As a game designer, [...] flavour is all important, but ultimately distracting'. Designing classes is almost all about flavour and style: do these abilities fit a consistent theme, do they complement each other, and so on? We can take on principles of good design, and the importance of the language and grammar of design will be increasingly a requirement as our games continue to increase in complexity. But ultimately, we want to present the player with interesting choices, a set of hills or valleys in the possibility space of the game, and to avoid overwhelming the player with too much choice, we have to highlight certain highs and lows, while ignoring others.

The second theme is the importance of exceptions. As a programmer, your intuition is ultimately to try to re-use your code where ever possible. But as a game designer, of the magic systems, you want to ensure that each ability uses at least some unique code path. That is, each ability in your game must in some way be a hack. It can be a small hack (fire burns, cold freezes) or a large hack (the recent implementation of a Find Familiar spell required a complete monster progression system to be interesting), but it should ensure that each ability is different, and therefore affects the game play in some unique way. Extend the ability idea as far as you can (cold freezes water, allowing you to cross rivers and block swimming monsters from attacking you) and then push yourself a little to see where it takes you. Don't obsess with trying to make the code clean and regular: it's the abilities that the player has that keep them empowered and playing, and suspension of disbelief should trump any reduction in code complexity.

Normally I finish these design articles with a set of principles, but here I only have practise. It has taken me close to 7 months to list these practises and there are many more devils in the detail that only a close inspection of the code and asking me questions will do justice to (and please, ask me on the blog rather than via email so that the questions and answers are shared for all). I'm not throwing my hands up in the air: but this type of design requires iteration and playing, and decisions, and your decisions will not be the same as mine.

(You'll want to continue reading the follow article series Designing a Magic System Redux, where I address issues, such as status effects, magic items and summoning which I haven't discussed so far).

10 comments:

crux said...

As a player, I'm in strong agreement on the importance of flavor. I think it has two points of major importance: the first is that, since we are talking about a roguelike, things like the names of spells, the descriptions we read about them (not to mention every other entity in the game) are pretty much all we have between us and the fact that what we actually just did was cause three #s to turn red for a second, and drop some other creatures' hitpoint values. Creating a cohesive, vibrant paradigm for these spells to take place in—and expressing that entertainingly, with flavor text, with multiple and exciting ways to say 'the goblin yelps as his eyebrows are singed!' etc., is one of the absolutely most crucial ways to keep a player grounded in the game.

The other important role it serves is actually to provide intelligibility for the player; I know that some folks keep spreadsheets with the modifiers of every class and race, but I think most people are like me—they use the description of a race, or of a school of magic in this case, as a guide for their playing style. And it's much easier to remember—ok, this guy is all about tricks and illusions, this school is pyrotechnic—than to simply memorize the fact that Class A has 3 long range offensive spells, 1 utility spell, et cetera.

Brog said...

I agree about hacks. My general rule is that "if adding something does not require writing any code, it's not worth adding". I end up with fewer different things that way, but all of them will actually be different, not minor variations on the same.

VRBones said...

I would see game design principles emanating from an analysis of the world with these magic schools in place. For example: If I'm a young aspiring magic user living in this new world, what would make me choose one path or another? Are there far more Wizards than Thaumaturgists? Are druids reclusive and in no need of recruits? Are Masters frowned upon in general public?

I would think that good game design emphasizes that people of a certain mindset are happy in their chosen school and see the positives outweighing the negatives (or the positives in other schools) otherwise they wouldn't be in that school in the first place. The existence of multiple schools means that there are multiple mindsets that people may have that lead them to supporting a certain school (Agressive Thaumaturgists, Dominating Masters, Analytic Wizards etc.)

It's adopting the right mindset when presented with a challenge that makes the school stand true.
What does a Thaumaturgist think when he's running out of food? Would he fry up the next monster he finds or trek back to town? Other Thaumaturgists would have gone through this same question and found a method that works best for them (their mindset). Maybe they have spent time developing a quick-fry spell rather than bothering with the huge effort (for them) of heading back to town. Wizards may see that spending the effort in developing travel spells allows shopping to be easier.


"But as a game designer, of the magic systems, you want to ensure that each ability uses at least some unique code path."
Not sure I agree totally with this concept. It would need a different reason for being there, but why a seperate code path? Eg. If you have a fire bolt and healing bolt that have the same method of payload delivery, but different payloads, why not have a CastBolt(direction, payload) function?

Maybe it's just the terminology. I see a "hack" as a modification that is temporary and I know it could be merged in at a more appropriate place if given enough time to do a complete rewrite. I don't see a hack as a once-off piece of code that is in the right place and necessary for proper execution. Like the druid needing trees and the Master needing darkness for teleportation; I can see these requirements being implemented as a hack by doing a sanity check after the selection, or embedding it properly by allowing attributes to be passed to the ChooseTeleportLocation() function that make it aware of all different types of eligible locations.

Maybe it's an implementation vs design argument? Maybe you need to see all the possibilities of a source+area type system before coming up with an interesting design concept, that then drives the development of a new type of system?

Nick said...

I agree with VRBones about hacks. Unifying everything into nice clean looking code will typically suck all the life out of it. Roguelikes aim to imitate life arguably more than any other genre, and life is messy.

On another note, this article has crystallised for me why I don't play Un very much. It's not because it's not a good variant - it clearly is - but rather because it is too rich for me. I like to play my *bands at a fairly fast (real life) pace, and Un demands more attention to detail than I'm willing to give it. This is simply personal taste - other people will feel the opposite. I have similar feelings about Sangband - I simply don't have the patience to play it well.

Which brings me to your comments about Leon. FAangband still has an enormous influence from him - in fact, I tend to feel a pang every time I change something that he clearly put a lot of thought into. The sheer clarity of purpose that has gone into all his *band endeavours is a joy to behold.

VRBones said...

"On another note, this article has crystallised for me why I don't play Un very much. It's not because it's not a good variant - it clearly is - but rather because it is too rich for me. I like to play my *bands at a fairly fast (real life) pace, and Un demands more attention to detail than I'm willing to give it."

I'm definitely in the other camp. I love UnAngband for it's depth. I used to spend the majority of my time on *bands with my finger permenantly over the '.'. Now there's less incentive to run to the next interesting thing because there's simply more interesting things in each room (and not all of them monsters). Going back to other *bands highlighted this point even further.

In fact I want more:
I want grubby rooms.
I want to walk in on ogres having lunch.
I want monsters with varying hitpoints and a backstory.
I want each level to feel like it's alive and functioning, not waiting for me to wade through it.
Give me all the ephemera you can!

I want random quests that are logical.
I want to talk to the townsfolk about their day.
I want to feel like clearing a dungeon has made a difference to the world.

Is that too much to ask? Probably, but I'm certainly going to applaud any moves toward that goal.

Nick said...

"I'm definitely in the other camp. I love UnAngband for it's depth."

Yep, there's a *band for everyone - well, everyone who has thrown away the crutch of 'realistic' graphics, anyway.

Andrew Doull said...

"What does a Thaumaturgist think when he's running out of food?"

Of course - I completely forgot about dungeon chicken as a food source... how could I? :0

Paul said...
This comment has been removed by the author.
Paul said...

The monster progression system could be reused to create communities of a single monster of varying strength. Ice freezing water and stopping water monsters fits well into a system of transforming terrain, and could be the basis of transforming a water elemental into an ice elemental. My point is that you do need to add hacks to get a new feature, but that in a rougelike game, you should also be trying to hook up any new feature with as many other as possible to get more power from the combinatorics that make rougelikes great.

Also, these articles have been great! Thanks for writing them.

RedFoxOne said...

I realise I'm coming a little late to these articles but as a first time roguelike game designer & developer I've found these articles very interesting and inspirational to the point that I'm taking (some of) your ideas and bending them into the design for my magic system.

Thank you for a really interesting journey.