Bag of holding

From NetHackWiki
Jump to navigation Jump to search
(
Name bag of holding
Appearance bag
Base price 100 zm
Weight 15
Material cloth
Monster use May be used by monsters as misc items.

A bag of holding is a type of tool that appears in NetHack. It is a magical container that is made of cloth, and is one of the most coveted items for general storage.

Generation

Bags of holding make up 150 (2%) of all tools that are randomly generated on the ground, in general shops or as death drops, and hardware stores can also stock bags of holding. Bags of holding that are normally generated (i.e. outside of bones levels and trap "bones") are always created as uncursed and may contain a random item[1][2]—this item will never be another bag of holding, a bag of tricks or a wand of cancellation.[3]

The prize at the end of Sokoban may be a bag of holding, depending on the layout of the final level: Sokoban Level 4a has a 34 chance of the prize being a bag of holding, while Sokoban Level 4b has a 14 chance of the prize being a bag of holding.[4][5] The prize will always be in one of the three closets behind the treasure zoo, with a cursed scroll of scare monster and an Elbereth engraving on the same square.[6][7][8][9]

Description

Like other containers, a bag of holding can be applied or looted by a hero to store and remove items as with other containers.[10] As a magical bag, it will also protect its contents from being broken if it is kicked, thrown or dropped from a great enough height (e.g. while levitating). Tipping a bag of holding can deposit all of its contents on the floor or transfer them to another container, whether in the hero's inventory or on their current square. As a cloth container, a bag of holding will gradually rot away if buried underground, and its organic contents will be not subjected to rotting until the bag is fully rotted away first.

A bag of holding that is submerged in water will become wet, with vulnerable contents subjected to water damage unless the bag is greased: the grease has a 12 chance of wearing off each time it prevents damage to the bag or its contents.[11]

Monsters that are hostile, intelligent, have hands, and collect items can pick up a bag of holding and will sometimes rummage through them for items that interest them. A gelatinous cube that picks up and eats a bag of holding will engulf the former bag's contents and add them to its inventory, and will then spend subsequent turns on digesting any organic items in that inventory (other than bone or dragon hide) unless a hero or monster that it can attack is close enough to it[12][13]—a hero polymorphed into a gelatinous cube can manually eat a bag of holding using e, but only if the chosen sack is empty.[14]

Weight-shifting

A bag of holding additionally alters the weight of its contents dependent on the beatitude of the bag, with the normal weight represented by cwgt in the table below:[15]

BUC total weight
blessed 15+(cwgt4+1)
uncursed 15+(cwgt2+1)
cursed 15+(cwgt×2)

In effect, a blessed bag of holding reduces the weight of its contents to 14, an uncursed bag reduces the weight of its contents to 12, and a cursed bag doubles the weight of its contents, which is then added to the bag's own base weight of 15 aum. A bag of holding's total weight is recalculated when either that bag's beatitude is changed, or when objects are transferred to or from that bag.[16][17][18][19][20]

In addition to doubling the weight of its contents, a cursed bag of holding may also make some of its contents vanish:[21] every time a hero loots, applies or tips the bag, there is a separate 113 chance per stack that each item inside disappears and is permanently lost, and items belonging to a shop that are lost this way will incur debt for the hero.[22][23][24]

Explosion

A magical explosion will occur if certain items are put in a bag of holding, dealing 6d6 damage to the hero while destroying both the bag and that item along with all the contents of the bag and any other bags placed into it.[25][26] These items will cause a bag of holding to explode if placed inside it:

The following information pertains to an upcoming version (NetHack 3.7.0). If this version is now released, please verify that the information below is still accurate, then update the page to incorporate it.

Per commit 71754910, exploding bags of holding scatter their contents rather than destroying them outright: fragile items are destroyed, and if the explosion is caused by a bag of tricks, it is still lost along with the bag itself, while if it is caused by another bag of holding, that bag explodes as well per commit 9cdcf7b2.

Per commit 6fd51c29, 113 of an exploded bag's contents are lost (not counting fragile items that are destroyed after), and per commit ce1f4788, monsters hit by scattered items are angered.

Nesting bags

A bag that is placed inside another bag is considered "nested": if a nested bag containing an item that would make a bag of holding explode is placed inside a bag of holding, then there is a decreased chance that the latter bag of holding will explode. The chance of an explosion occurring then depends on the amount of nesting:[29]

Number of sacks Odds of explosion Success probability
0 1/1 0
1 2/2 0
2 3/4 0.25
3 4/8 0.5
4 5/16 0.6875
5 6/32 0.8125
6 7/64 0.890625
7 8/128 0.9375
8 9/128 0.9296875
n, where n>6 (n+1)/128

If a bag of holding is nested this way and the nested bags do not explode, the effect of the two bags will be cumulative as expected: if both are blessed, any items in the innermost bag will have their weight reduced to about 1/16. Per the table above, nesting bags of holding with more than 7 sacks in between makes the chance of an explosion more likely for each sack after the seventh.

Strategy

Bags of holding are useful for carrying large numbers of items, and are widely considered an essential part of an ascension kit. Though bags of holding will protect their contents from breaking, it will not prevent them from getting wet—to protect against this, you can apply grease to the bag or place it in a non-cursed oilskin sack to protect it from water damage, and a player wishing for a bag of holding should always specify a greased one.

Bags of holding can be informally identified by first curse-testing them (to avoid any item loss from a potential cursed bag of holding), then placing items into the bag once it is determined to not be cursed: if the hero is encumbered and places items in an unidentified bag of holding, or blesses an unidentified bag of holding that has items inside, the weight reduction may be enough to reduce their level of encumbrance.[20] For this reason, a player's heaviest non-worn items should usually be placed in a suspected bag of holding first once the bag is properly curse-tested.

Item management

Due to the risks of losing your most valuable items if your bag is cursed or else explodes, many players also carry a plain sack to store other items. The sack can be used to hold items that are rare or hazardous to a bag of holding—many players name this bag something like "Cancel" or "Don't ever put this in BoH!" and keep wands of cancellation and other precious items such as artifacts or a wand of wishing inside as a safety measure.

You can also store a bag of holding in a sack to prevent it from being affected by the curse items monster spell and increasing its weight, which in turn is likely to render the hero encumbered or worse depending on the amount of contents stored. As a trade off, it will require two turns to take that bag out and transfer items to or from it.

Handling cursed bags

If you find a bones pile with a bag of holding, it will probably be cursed and too heavy to lift. If you can still pick it up, then it can be uncursed by dipping it in a potion of holy water, reading a scroll of remove curse, or casting the remove curse spell. Otherwise, the best solution for a cursed bag of holding you cannot lift is to zap it with a wand of cancellation—the beam will only affect the bag and simply sets its beatitude to uncursed. Be sure to move any desired wands, tools and other enchanted or charged items out of the way beforehand.

If cancellation is not available, a solution is to try and lift the bag and then #tip it: this will still make items vanish, but at least you can get everything else out without being limited by your inventory.

You can also allow a gelatinous cube to eat the bag if one is present: the cube will only eat the container itself, leaving the contents (including organic items) in its inventory, which will land safely on the ground when you kill the cube. Just make sure you can secure all the items before they are damaged - and only do this if you have no need for the bag itself.

Avoiding bag explosions

Placing a bag of holding or bag of tricks inside your bag of holding can be avoided by being extremely careful in watching what letters you type when placing items into that bag. Wands of cancellation are tricky to identify, making them more risky that either type of bag (since the former can be type-named upon informally identifying it, while the latter can be auto-identified by applying or looting it). To be safe, do not put any unidentified wands inside the bag, unless you have engrave-tested them and confirmed that they do not make engravings disappear—this rules out cancellation, along with teleportation and make invisible.

It is usually best to avoid carrying more than one bag of holding or any bag of tricks when they are not in use, except perhaps while transporting them to a convenient stash location (since they cannot cause accidental explosions if they are not on your person). Many players prefer to leave wands of cancellation at their stash as well, but these can be useful against monsters, so one must balance the increased risk in combat with the risk of making a potentially game-ending mistake.

Handling nested bags of holding

As mentioned above, it is risky but possible to first put items that would ordinarily cause a bag of holding to explode into sacks or oilskin sacks, and then place them inside the bag of holding, without causing an explosion. The table in the linked section covers the number of sacks that is most reasonable to use for this purpose: in general, two nested bags of holding at most are useful, since the payload is limited by your ability to lift the innermost bag rather than by the outermost bag's weight, and you risk an explosion each time you re-insert the innermost nested bag in the outer bag. If you wish, you may choose to continue to nest the bags of holding further; the chance of success with certain configurations of sacks between the bags of holding is given below:

Number of bags of holding Sack spacing Success probability
2 7 0.9375
3 7,7 0.769042...
4 7,7,7 0.512570...
5 7,7,7,7 0.256222...
6 7,6,6,6,7 0.0935839...
7 7,6,5,5,6,7 0.0236287...
...
43 3,2,2, ... ,2 very small

For example, if you use 7 sacks between each of three bags of holding like this (H for bag of holding, s for sack): HsssssssHsssssssH (denoted as "7,7" in the table above), the chance of successful nesting would be 1-(8/128) for the first nesting, and then (1-(8/128)) * (1-(16/128)) for the second nesting; each of the two 'inner' bags of holding put into the outermost bag must pass its own independent roll for the nesting to succeed[25][26]—this gives the example scenario roughly a 23.1% chance that something will explode.

Some players either consider the 6.25% chance of explosion from nesting to be an acceptable risk, or assume from a test in wizard mode that it is safe. If you are confident you can withstand the explosion, you can risk it before you leave the main dungeon to increase your score or bring specific items to the demigod bar.[30]

History

The bag of holding first appears in NetHack 3.0.0. It first appears as one of the Sokoban prizes with the introduction of the branch in NetHack 3.3.0: from this version to NetHack 3.4.3, including some variants based on those versions, Sokoban Level 4a always has a bag of holding as the prize, while Sokoban Level 4b always has an amulet of reflection.

The current level-based probabilities for the Sokoban prize being a bag of holding are introduced in NetHack 5.0.0 via commit 6c479f23.

In versions up to NetHack 3.6.7, including some variants based on those versions, a bag of holding that is destroyed in a magical explosion will destroy all items involved in the process, i.e. the bag of holding, the item or the container holding that item which caused it to explode, and the contents of both that bag and any containers within the initial bag or the container being inserted into it.[25][26] NetHack 5.0.0 establishes the current behavior for exploding bags of holding via commit 71754910, commit 9cdcf7b2, commit 6fd51c29, and commit ce1f4788.

Origin

The bag of holding is an iconic item from Dungeons & Dragons, and has appeared in numerous other modern fantasy works since then, sometimes under different names—magical bags with increased capacity also occur in other contexts within folktales, mythology and works of fantasy. In its original form in Dungeons & Dragons, the bag of holding is described as "opening into a nondimensional space", meaning that items inside not do not encumber the player at all, although unlike in NetHack the bag has a limited capacity and is much more fragile: it can be destroyed by being pierced with a sharp object (from within or outside), or by attempting to fill it beyond its maximum capacity.

Messages

An <object> has vanished!
You applied or #looted a cursed bag of holding, causing a known item(s) to disappear.[31]
You see <object> disappear!
As above, with an unidentified item(s) disappearing.[32]
As you put <object> inside, you are blasted by a magical explosion!
You caused a bag of holding to explode by placing a charged bag of tricks, charged wand of cancellation or another bag of holding inside, destroying both objects and their contents.[33]

Variants

SLASH'EM

In SLASH'EM, upgrading a sack or oilskin sack can produce a bag of holding. The Wallet of Perseus is an unaligned artifact bag of holding that has enhanced weight reduction.

Due to the ability to upgrade, the amulet of reflection is generally the more valuable Sokoban prize: there is still a 12 chance of each reward, even with the new levels introduced in the variant.

SLASH'EM has a 'showweight' option that explicitly displays the amount of weight the hero is carrying - informally identifying bags of holding is trivial with this option turned on. The Wallet of Perseus also enables informal identification of a bag of holding via the 'naming artifacts' trick.

NetHack brass

In NetHack brass, Sokoban offers a choice between 3 items, with one being a bag of holding.

GruntHack

In GruntHack, causing a bag of holding to explode does not destroy the contents of the bag, but scatters them and the hero throughout the dungeon via level teleport.

Sokoban in GruntHack also offers a choice between 3 prizes, with one being a guaranteed bag of holding.

SporkHack

In SporkHack, an exploding bag of holding scatters its contents nearby, rather than destroying them outright—this will still destroy the inserted object, and fragile objects such as potions and mirrors are broken as if they were thrown.

UnNetHack

In UnNetHack, exploding bags of holding react the same as in SporkHack, scattering most of its contents and destroying fragile items.

Sokoban in UnNetHack offers a choice between 3 prizes, with one being a guaranteed bag of holding.

AceHack

In AceHack, inserting a bag of tricks or a wand of cancellation inside a bag of holding will drain them of their charges rather than destroying any items inside. A hero can still destroy bags of holding by nesting them, but will receive a confirmation prompt when doing so. This also applies to NetHack 4, a 'successor' variant to AceHack.

NetHack Fourk

In NetHack Fourk, Sokoban now has set rewards for each of the possible maps that can appear as its final floor. Open at the Top, which is essentially a clone of Sokoban level 4a, always has a bag of holding as its prize.

xNetHack

In xNetHack, an exploding bag of holding behaves as in SporkHack and some other variants: 113 of the contents are destroyed along with the bag and inserted item, and the rest are scattered, destroying fragile items.

EvilHack

In EvilHack, an exploding bag of holding functions as in SporkHack and some other variants: 113 of the contents are destroyed along with the bag and inserted item, and the rest are scattered, destroying fragile items.

Sokoban in EvilHack offers 3 different type of prize item, and its prize tool has a 12 chance of being a bag of holding.

The Bag of the Hesperides is an artifact bag of holding similar to the Wallet of Perseus that repels water like an oilskin sack, confers protection when carried, and is made of intrinsically-fireproof dragonhide—it can only be obtained within the last floor of the Ice Queen's Realm, where it is placed inside a crystal chest within the pegasus cage.

Hack'EM

In Hack'EM, bags of holding behave as in EvilHack. The Wallet of Perseus is also given most of the same physical traits as the Bag of the Hesperides from EvilHack.

Encyclopedia entry

"Now, this third handkerchief," Mein Herr proceeded, "has also four edges, which you can trace continuously round and round: all you need do is to join its four edges to the four edges of the opening. The Purse is then complete, and its outer surface--"
"I see!" Lady Muriel eagerly interrupted. "Its outer surface will be continuous with its inner surface! But it will take time. I'll sew it up after tea." She laid aside the bag, and resumed her cup of tea. "But why do you call it Fortunatus's Purse, Mein Herr?"
The dear old man beamed upon her, with a jolly smile, looking more exactly like the Professor than ever. "Don't you see, my child--I should say Miladi? Whatever is inside that Purse, is outside it; and whatever is outside it, is inside it. So you have all the wealth of the world in that leetle Purse!"

[ Sylvie and Bruno Concluded, by Lewis Carroll ]

References

  1. src/mkobj.c in NetHack 5.0.0, line 330-L332: starting sacks are always empty, though this is not a concern for bags of holding in practice
  2. src/mkobj.c in NetHack 5.0.0, line 1020-L1022
  3. src/mkobj.c in NetHack 5.0.0, line 371-L379
  4. dat/soko1-1.lua in NetHack 5.0.0, line 102-L105
  5. dat/soko1-2.lua in NetHack 5.0.0, line 104-L107
  6. dat/soko1-1.lua in NetHack 5.0.0, line 29-L32
  7. dat/soko1-1.lua in NetHack 5.0.0, line 110-L111
  8. dat/soko1-2.lua in NetHack 5.0.0, line 29-L32
  9. dat/soko1-2.lua in NetHack 5.0.0, line 112-L113
  10. src/apply.c in NetHack 5.0.0, line 4275-L4278
  11. src/trap.c in NetHack 5.0.0, line 4736-L4743
  12. src/mon.c in NetHack 5.0.0, line 1400-L1401: eating a container in m_consume_obj() calls meatbox()
  13. src/mon.c in NetHack 5.0.0, line 1352-L1382: meatbox() function; engulf_contents is set if a cube is the one eating the container
  14. src/eat.c in NetHack 5.0.0, line 114-L118
  15. src/mkobj.c in NetHack 5.0.0, line 1936-L1955: calculations for bag of holding's total weight in weight()
  16. src/mkobj.c in NetHack 5.0.0, line 1757-L1758
  17. src/mkobj.c in NetHack 5.0.0, line 1776-L1777
  18. src/mkobj.c in NetHack 5.0.0, line 1805-L1806
  19. src/mkobj.c in NetHack 5.0.0, line 1831-L1832
  20. 20.0 20.1 src/pickup.c in NetHack 5.0.0, line 1538-L1566: delta_cwt() function
  21. src/pickup.c in NetHack 5.0.0, line 2536-L2554: boh_loss() function
  22. src/pickup.c in NetHack 5.0.0, line 2509-L2513: is_boh_item_gone() function
  23. src/pickup.c in NetHack 5.0.0, line 2801-L2822: messages and debts for item loss
  24. src/pickup.c in NetHack 5.0.0, line 3764-L3773: item loss from tipping a cursed bag of holding
  25. 25.0 25.1 25.2 src/pickup.c in NetHack 3.6.7, line 2080-L2102: mbag_explodes() function
  26. 26.0 26.1 26.2 src/pickup.c in NetHack 3.6.7, line 2229-L2260: handling for destroyed bag of holding
  27. 27.0 27.1 src/pickup.c in NetHack 3.6.7, line 2086-L2088
  28. include/obj.h in NetHack 3.6.7, line 264: Is_mbag define
  29. 29.0 29.1 29.2 src/pickup.c in NetHack 3.6.7, line 2091-L2099: The comment above this line details the resulting odds of a nested offending object causing an explosion
  30. RGRN: "YAFAP - Scrappity - Arc - Gno - Neu - Survivor (Long)"
  31. src/pickup.c in NetHack 3.6.7, line 2374
  32. src/pickup.c in NetHack 3.6.7, line 2376
  33. src/pickup.c in NetHack 3.6.7, line 2231