Sense of smell

A simple way to give monsters a little more character is to give them a sense of smell. In turn, the player deposits smells on the cells that he walks over. Smells decrease in strength as time passes and eventually fade away to nothing. Optionally, smells can spread to other cells.

I coded up and tested a number of different implementations of how smells were deposited and spread. But after lots of coding, testing, and tweaking, I realized that the benefits to gameplay weren't a reflection of how realistic the whole system was. So I ultimately decided to stick with something simple:

Smells are deposited each turn by the player at a given strength. All smells decrease by 1 each turn. Every X turns, right now 2, all smells check to see if they can and should spread to neighboring cells. I say should in the sense that a weaker smell shouldn't 'overwrite' a stronger one. When smells spread, they also decrease in strength by Y, right now only by one.

Changing X and Y affects how fast and how far smells will eventually spread. Smells are maintained in an STL map for fast membership checking and iterating.

Monsters then have a 'smell level' which determines how weak a smell they are able to detect. Lower values mean that they can smell even the faintest of scents. If a monster isn't doing anything and a scent hits them that they can sense, they start to follow it, looking for the neighboring cell with the highest scent value. The monster will eventually follow the trail to the player. Pretty cool. If the player rests just around the corner from a pack of monsters, his scent may reach them and they may come after him. If the PC is running from a tough monster, the monster will follow the scent for as long as it is able. If the PC is faster than the monster, the scent will eventually weaken to the point that the monster can no longer smell it. But if the monster is say ... a dog, the scent will need to completely vanish before the dog gives up the pursuit.

I think it creates the opportunity to add personality to monsters. Animals track really good, humanoids not so good, and undead not at all, since they can't smell ... something like that. It makes the player have to think about how they evade certain enemies based on their tracking abilities.

See the screenshots page for a graphical representation of scent spreading through the dungeon.