Can I trick the treasure rooms in Brogue?

Levels in Brogue often have a treasure room protected by a key somewhere else on the same level. There are usually 4 or 5 bits of treasure on altars in the room protected by cages. When you pick up an item from one altar, the rest of the cages close and you cannot pick a different item until you drop the current item back onto the altar where you picked it up. Of course, some of these rooms have multiple items that would help me greatly!

Is there a way to trick the room into opening all the cages or getting multiple items? I've tried dropping a different item onto an empty altar but that didn't work.


Solution 1:

It's not possible.

Looking at the source code, we can see that treasure rooms ("libraries" as they're called internally - you can only check out one item at a time) are implemented using ALTAR_CAGE_OPEN features with the MF_GENERATE_ITEM and ITEM_IS_KEY flags - so, at level generation, each altar generates an item on it that is configured to be a key. (This is in Globals.c, although you'll have to read Rogue.h and Architect.c as well, and possibly drink heavily, to fit it all together.)

So, from this, we know that at generation time, the item on each altar is assigned as its key. Can we fake the key? Unfortunately, no. The key check is implemented in keyMatchesLocation() in Items.c, and reveals that each key is defined by three properties: the keyZ coordinate, the keyX and keyY coordinates, and the machine number.

A key only works when its keyZ matches the current level. keyZ is set (in Architect.c) to the current depth when the key is created, so a key will never work when taken off its home level. Assuming the keyZ matches, a key will work if either of the other two properties match: the keyX and keyY match the current location, or the machine at the current location has an ID that matches the key's machine ID. (The machine ID is generated at map generation time and is unique across the entire game.)

While it is in principle possible for multiple "keys" to exist for the same altar - you just need two key items with the same keyZ and machine ID - there's nothing in game that would cause this to happen. Similarly, there's no way to wedge a cage open (it has the DFF_EVACUATE_CREATURES_FIRST flag, so anything in the way gets pushed off it as it closes). It is possible that some sort of area effect that pushes items could be used to knock multiple items off their altars simultaneously, but Brogue has no such effects.

So, no, short of editing your save file to create a fake key item, it can't be done.

Solution 2:

There is one class of item you can "trick," though. Wands count as "returned" even if they're empty of charges. So you can use a wand of empowerment on an ally and then return it for a different item.