Saturday 15 August 2015

The Dynamic Dungeon

This week I have been plotting out a series of ideas for how to add interactivity to the dungeon. Often the dungeon can feel flat and lifeless, an empty husk used simply as a container for enemies to wait to be slaughtered. I wish to dismiss this feeling and make the dungeon seem just as dynamic as its denizens. So to do that the player needs to feel that the dungeon itself can be interacted with, and the dungeon needs to change in meaningful ways in reaction. A few methods are outlined below:
  • Destructible Walls - Many roguelikes include the ability to dig through walls, allowing the player to tailor the dungeons layout to their needs. However this provides complications with many pieces of content where the entrance/exit are well defined, and the ability to enter at any point breaks it. This tends to be countered by 'undiggable' wall types.
  • Traps - A staple of roguelikes, traps activate some affect when triggered, often by being stepped onto. The most common traps are single tile direct damage traps, though more complicated setups are sometimes used. These can often feel cheap, as their short range nature require tricks to get the player to step onto them, like making them invisible.
  • Puzzles - An interconnected series of things that interact in some way, the a solution that provides some form of reward. An excellent method for adding interactivity to the dungeon. The issue being that generating a good, interesting puzzle can be very hard.
As interesting as these would be to add it was not what I started with. So the first task I completed towards dungeon interactivity is a thing I like to call 'Fields'.
Fields are a single tile area of some substance, that interact with other Fields (and the entities within them) in some fashion. For example a Fire that can be put out by pouring water onto it, turning the water into steam. These fields can be placed in the level by various methods, from an entities death (a spore releasing a cloud of poison gas on death), to a dungeon feature (smashing a fountain releasing a constant stream of water).

Like everything else in my game the fields are data driven, having a series of data points that define their properties. They are as follows:
  • Field name - This is the name of the field, used for checking if a neighbouring field is the same as this one
  • Tags - A list of tags that define the properties of the field, using for the interaction map (Examples are Hot, Cold, Gas, Poison, Explosive).
  • Stacks - A value representing the strength of the field.
  • Layer - The field 'layer' it exists on. Currently I have Ground and Air.
  • Duration Style - This defines its lifespan. I currently use Permanent, Fade (slowly reduces the stacks until the field disappears) and Collide (disappears on first collision with an entity).
  • Spread Style - This defines how the field spreads. I use Flow (flows out down the 'stacks' gradient), Adjacent (spreads to nearby tiles with stuff in them), Wander (randomly wanders around) and None (doesnt spread)
  • Field Interactions - A map of field name or tag to an interaction event. Currently supported interactions are Spawn (spawn a field of the specified type) or Propogate (applies some effect to every field tile joined to the src tile).
  • OnTurn - A list of effects to apply every turn. Examples are Damage and Healing. 

An example of spreading fire:











Water putting out fire and turning into steam:











Lightning hitting water and propogating through it:

Friday 7 August 2015

Interactivity Through Sound

For those interested in other devs writing on sound design you can read the fantastic set of articles by the developer of Cogmind here: Sound in Roguelikes, Sound Design, Ambient Sound

This week saw the introduction of sound into Chronicles of Aether.

Sound is immensly important in games as it provides one of the two main ways the computer can interact with our senses (the other being sight). With such a large portion of the players experience of a game relying on this it is a shame it tends to get neglected by developers so often.

In Chronicles of Aether sound is seperated into 3 main categories.
  1. Music. Each level has a background song that plays, picked to evoke an emotion that reflects the design of the level. For example a foreboding eerie track for a crypt, or a happy jaunty tune for a bright forest.
  2. Ambient sounds. Sounds that play due to some logic (such as repeat infinitely, or once every 10-20 seconds etc). These are used to give a further depth to the atmosphere building for the level. Examples are groans and echoing splashes for a dungeon, Birds and insects for a forest.
  3. Effect Sounds. These are sounds that play in reaction to some action an entity in the world has made. An example being the sound of a sword strike or a fireball explosion.
After implementing these sounds I had entities exclaiming when they saw an enemy, groaning when they were wounded, and a cacophany of other sounds as they bashed each other to death. Sitting back I looked at this scene a realised it felt contrived, all this noise that meant nothing to anyone but the player.
Then I had an idea. Why don't I add meaning to the sounds, something that the entities can act on? With this in mind I added a piece of data to each of the dynamic sounds. Entities close enough to hear the sound would have that data inserted into their ai, to process as they will. Suddenly the world came alive. Sounds of fighting would draw in nearby entities to investigate, enemies would shout out the location of the player, informing their allies of the players position and calling them forward. Wounded creatures could inform their healer allies that they needed assistance. And every piece of this interaction was perceivable to the player, as they could hear the creatures talk to one another.

Now I'll get quickly into how this is implemented:

  • Background and ambient sounds have no in game meaning other than to create atmosphere, and therefore the code playing them is very simple.
  • Sound effects have a few different configuration settings:
  • Max Volume. This is the maximum (before attenuation) volume.
  • Max Range. This is the range where attenuation will have brought the volume to zero.
  • Attentuation Offset. The range value to start attenuating from. Anything below this plays at max volume.
  • Data. The data to impart to the entities who hear it.  

Whenever a sound is played it gets all the entities within a sphere around the source defined by the maximum range. Then for each entity it tries to path towards it using AStar. If it can find a path with less steps than the maximum range that entity 'hears' the sound and gets the data.
It does the same for the player, to calculate the volume for the sound to be played at.

Saturday 1 August 2015

Abilities

Abilities in Chronicles of Aether form the core of what makes combat interesting. There need to be techniques to suit all combat styles, from the up close and personal face tanking barbarian to the glass cannon long range spellcaster, there should always be abilities that prove interesting to use.

So with this goal in mind abilities are built up from a pool of constituent parts, defined in some data files. The available parts are are follows:

  1. A Targetting style. I currently have Self, Enemy, Ally, Tile or Direction.
  2. A Movement style. I currently have Smite (takes no travel time to hit, ignores everything until it hits its target), Bolt (has a travel time, collides with first non-passable thing) and Ray (hits everything in a ray up to the first non-passable thing).
  3. An aoe style. Currently supports Cone and Circle.
  4. Some effects (applied to each affected tile). Currently supported are Damage, Healing, Status, Teleport (this is used for all effects that move an entity).
Some examples:
Fireball
  • Targetting: Direction
  • Movement: Bolt
  • AOE: circular
  • Effect: Damage (maybe even a status effect if you want to add some burning too)
Jump Attack
  • Targetting: Enemy
  • Movement: Smite
  • Effect: Damage, Teleport (with a flag saying it should play a leap animation rather than a teleport one)
Heal
  • Targetting: Self, Ally
  • Movement: Smite
  • Effect: Heal
Shown below are some examples of usable abilities currently in the game: