Potion of Death!

It’s funny how bugs can interact with each other in unexpected ways. Case in point: The Potion of Death I accidentally created last night as I was coding item usage in the menu system.

The RPG Maker item data structure has a list of flags representing which conditions the item cures. But since most items don’t cure any condition, the program saves space in the file by simply skipping the entire list if the whole thing’s set to false. In my code to read the data structure, I accidentally had it set the entire set to true if the list was missing from the file. So an ordinary item, such as a potion, suddenly becomes a cure-all item.

But it gets worse. Characters can be afflicted with various conditions, as defined by the game writer, and one condition that’s hard-coded into the system: “dead”. If a character’s dead, it changes a bunch of the code for his behavior. (For example, he can’t be healed while dead.) In the code to set a character’s condition, I had a check for whether the condition being set was condition #1 (dead), and if it was, to set a couple other things in the hero’s data structure relating to being dead. Unfortunately, this check didn’t look to see whether the “dead” condition was being turned on or off.

You can probably see where this is going. I tested out a potion on a hero, and… he died?!? That confused the heck out of me, of course. Turns out the potion (with the “cure condition” attributes set to all true) had tried to cure the hero of being “dead”–for technical reasons, it’s more efficient to simply set the condition to false than to check whether it’s set and then only set it if it’s already true–and this set off the special code. So instead of getting healed by 50 HP, the hero died. Huzzah for Potions of Death!

2 Responses to “Potion of Death!”

  1. LOLninja says:

    “I tested out a potion on a hero, and… he died?!?”

    xD

    The funniest about it imo is that the program simply did what it was told to do.

  2. Pierre says:

    Last Action Hero said : “This is the ultimate test of the ultimate rpg builder”.

    😀