The story behind The Bug: undying Cairn Wights

Original post at Pathfinder CRPG – Wrath of the Righteous page in Facebook.

Creating computer games is a tricky business, and all good tricks include a lot of smoke, mirrors and hidden trapdoors. Sometimes, though, the smoke gets sucked into the trapdoor and the assistant’s twin walks head-first into the mirror because she can’t see anything. In the case of computer games, this usually leads to bug reports. This series of posts offers a behind the scenes look at some of the notable bugs in Pathfinder: Wrath of the Righteous.

Pathfinder tabletop system is incredibly complex. It includes a huge number of interacting rules and content based on said rules, which sometimes overrides them and creates special cases. Because of that, even a simple question like “how much damage can that character do” requires complex calculations. Of course, we make these calculations whenever the character attacks someone, but that’s not the only time when we need minimum and maximum damage values.

Every time you Inspect an enemy, you can see its damage range. To display it, we need to make the same calculations as in case of a real attack. Duplicating all code required to do this without making an attack would be a huge, bug-prone overkill, but there is a simple, smoke-and-mirrors way to do this, which we use. We create a dummy invisible character and use the usual combat code to make a fake attack against it.

Of course, this fake attack should never appear in Combat Log or do anything else visible to the player, and that’s why the code that is responsible for calculating the damage includes a special toggle that makes it calculate everything, but do nothing: it doesn’t spend any limited resources, doesn’t actually deal any damage or trigger any side-effects. But. To make an attack, we must first calculate Attack Roll, to tell if we hit or miss the target. The roll is faked, too – we always need to hit the dummy to extract the damage. Unfortunately, the code that calculated the Attack Roll was written less carefully with the respect to “fakeness”. It actually emitted signals about a successful attack to anyone listening in. And Cairn Wight has a nice little ability called Energy Drain that makes it gain temporary hit points every time it lands an attack (even without doing any damage), and the target fails a save.

As you can guess, the dummy never made its saving rolls. And so, every time you moused over a Cairn Wight it gained additional temporary hit points, making it virtually impossible to kill. The bug actually manifested itself both in RTwP and turn-based mode, but was much more noticeable in the later, because it was easier to keep your mouse cursor over Wight, and because you need to place the cursor over it to make an attack.

In the end, we taught the code that makes the fake Attack Roll to avoid signaling the whole wide world about its results, and Cairn Wights started dying again. And there was much rejoicing.

Leave a Reply

Your email address will not be published. Required fields are marked *