Tales of the Rampant Coyote

Adventures in Indie Gaming!

Frayed Knights – Bug of the Week

Posted by Rampant Coyote on September 22, 2011

Well, my big “release candidate” build has some bugs in it, apparently.  So in addition to finishing the manual, I’m working on a few more bugs than I expected, and we’ve had some amusing ones. The latest one to get fixed is the “nude bug” where characters can’t wear any clothing. Armor is fine, but plain ol’ clothing isn’t working.

This particular bug, caught by Cowgod in the previous build, is one of my favorites. I wish to preface this by saying that Frayed Knights: The Skull of S’makh-Daon does not have an invisibility spell:

Cool, huh?

As I was digging into this one trying to figure out what the heck was going on, I stumbled into a logic / gameplay problem that reminded me of the early days of playing Magic: The Gathering.  The key was in the scrolling text window.  What it looks like is that the tomb skeleton casts a bless on himself, and then goes invisible.

One of the side-effects of the Blessing spell is that your health increases by a small amount.  Health is based on physical stats, Blessing gives your physical stats a small kick, therefore health is increased from Blessing. I should note that the game tracks damage, rather than “current health,” though it displays this as current health. Your current health is your maximum health minus your damage. If damage > max health, you die. This was a problem at one point when a spell like Blessing wears off – I had to make sure creatures died properly when spells wore off if it left them with less health than their current damage.

Then we get into some logic issues of what happens if you “stack” like spells. If you already have a spell of one kind on you (duration-based), and get hit with another spell of the same type, the game only “keeps” the one with the longest duration.  In this case, the skeleton already had a Blessing that was about to wear off.

Do you see what happened now?

Internally, the game saw the new incoming Blessing spell, compared it to the old one, and decided to supersede the old Blessing effect with the new one. Fine. So it removed the old Blessing effect. But in that split-second between deleting the old Blessing and adding the new one,  the monster fell to zero health – death! That triggered some death code. But it was then immediately “healed” by the incoming spell, which caused the follow-up code – which checks to see if the monster is dead – not to fire.

So the monster was only mostly dead. Which is still partly alive.

Well, okay, it’s a skeleton, so it’s undead, but you see what I mean.

And you see what I mean about how coding up an RPG can be a bit more challenging than many other genres?  I wouldn’t think twice about something like that in a pen-and-paper RPG. But it can get a little trickier when all that exception-based gameplay makes its way into code.

Many thanks to Cowgod for his testing efforts, and especially for his recording of a bunch of issues like this. I don’t know if I would have figured it out without the video!


Filed Under: Frayed Knights - Comments: 4 Comments to Read



  • Ruber Eaglenest said,

    Why skeletons have blood?- says my daughter…

    Yes I know, all skeletons have blood since Quake 3 Arena, but it could be a good idea to have that splash of black color.

  • Rampant Coyote said,

    Since I have to prep another version between now & release anyway, I may look into that. It’d probably be a pretty simple enhancement. Probably.

  • Felix Pleșoianu said,

    Hah! I’ve encountered a similar bug in Buzz Grid, whereas I thought lives couldn’t possibly ever get negative, as there’s no multithreading to create race conditions. Turns out, there was a way after all. That cured me forever and ever from using == when I mean <=. Defensive programming FTW! :D

  • adorna said,

    Actually, thats sort of awsome .. Complex game mechanics have a way to turn into simulations with really unexpected turns it seems :) if the monster wouldn’t completely disappear but turn into some sort of ghost/undead you’d have a working explanaition for death and ghosts all adhering to your own game rules ..
    only it doesn’t make much sense with undead monsters to begin with…

top