Spelunky is © 2008, 2009 Derek Yu and Mossmouth, LLC, and is used under the [Spelunky User License v1.1b](https://spelunky.ai/LICENSE.txt). spelunky.ai is an unofficial fan project, not affiliated with or endorsed by Mossmouth. The game and its assets may not be sold.

Music by George Buzinkai and Jonathan Perry; sound effects made in SFXR. From Spelunky Classic 1.1, © 2008, 2009 Derek Yu and Mossmouth, LLC.

# Black Markets on graveyard levels

From the spelunky.ai wiki: <https://spelunky.ai/wiki/black-market-graveyard>.

Black Markets on graveyard levels is a quirk of Spelunky Classic in which one Black Market in ten is a graveyard, and the game never says so.

| Quirk                                       |                                                                                                                                                                                                                                                                                                                                                                                     |
| ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [How we know](https://spelunky.ai/wiki#how) | Read in the game's code and seen in the original game running                                                                                                                                                                                                                                                                                                                       |
| Where                                       | [`scripts/scrInitLevel.gml:145-148`](https://spelunky.ai/wiki/source/scripts/scrInitLevel#L145-L148)                                                                                                                                                                                                                                                                                |
| Pinned by                                   | [`fidelity/replays/jungle-seed-9-market-graveyard.txt`](https://github.com/851-labs/spelunky/blob/187c08df2d359683ed808ed14322c0bfcfaa3d7a/fidelity/replays/jungle-seed-9-market-graveyard.txt)                                                                                                                                                                                     |
| Row                                         | [docs/quirks.md §1, Bugs and leftovers in the 1.1 source](https://github.com/851-labs/spelunky/blob/187c08df2d359683ed808ed14322c0bfcfaa3d7a/docs/quirks.md#1-bugs-and-leftovers-in-the-11-source): [“A Black Market can be a graveyard level, and never says so.”](https://github.com/851-labs/spelunky/blob/187c08df2d359683ed808ed14322c0bfcfaa3d7a/docs/quirks.md?plain=1#L190) |

The [Black Market](https://spelunky.ai/wiki/black-market) is a Jungle level, and every Jungle level rolls for being a
[graveyard](https://spelunky.ai/wiki/restless-dead). The market's is rolled too, once its rooms are laid out, so one market in ten is a
graveyard, with its graves and its dead. But the market's welcome is the level's message, and the graveyard's
comes second only on a dark level, which the market never is, so the game never says so.

## What happens

The player drops from the Black Market's entrance onto a grave below its shops. The market rolled the graveyard,
with eight graves and three Zombies, and the game welcomes him to the Black Market. THE DEAD ARE RESTLESS! never
comes[^1].

**Clip: A Black Market on a graveyard level.** A Black Market that rolled the graveyard: the player drops onto a grave below its shops. The game welcomes him to the Black Market, and the graveyard's own message never comes. ([video](https://spelunky.ai/wiki/media/clips/quirks/market-graveyard/clip.mp4))

## Why

`scrInitLevel` lays out the level's rooms, the market's included, and then rolls the graveyard for any Jungle level:

```gml scripts/scrInitLevel.gml:145-148
scrLevelGen();

global.cemetary = false;
if (global.levelType == 1 and rand(1,global.probCemetary) == 1) global.cemetary = true;
```

[`scripts/scrInitLevel.gml:145-148`](https://spelunky.ai/wiki/source/scripts/scrInitLevel#L145-L148), from `spelunky.gmk`, Spelunky Classic 1.1's source, © 2008, 2009 Derek Yu and Mossmouth, LLC ([Spelunky User License v1.1b](https://spelunky.ai/LICENSE.txt)).

Nothing there skips the market, and `scrEntityGen`'s Jungle branch, which the market runs, makes a graveyard of
it: graves on its earth, with their treasure[^2],
[Zombies](https://spelunky.ai/wiki/zombie) and [Vampires](https://spelunky.ai/wiki/vampire) in place of the Jungle's monsters, without the market's rule that
keeps Mantraps off its shops' floors[^3], and
[Dead Fish](https://spelunky.ai/wiki/dead-fish) in place of Piranhas[^4].

The level's first message, from `oPlayer1`'s alarm 0, takes the market before the graveyard[^5]. The second, from alarm 1, shows the graveyard's only on a dark
level:

```gml objects/oPlayer1/alarm_1.gml:11-17
else if (global.cemetary and global.darkLevel)
{
    global.message = "THE DEAD ARE RESTLESS!";
    global.message2 = "";
    global.messageTimer = 200;
    if (global.lake) alarm[4] = 210;
}
```

[`objects/oPlayer1/alarm_1.gml:11-17`](https://spelunky.ai/wiki/source/objects/oPlayer1/alarm_1#L11-L17), from `spelunky.gmk`, Spelunky Classic 1.1's source, © 2008, 2009 Derek Yu and Mossmouth, LLC ([Spelunky User License v1.1b](https://spelunky.ai/LICENSE.txt)).

`scrInitLevel` clears `global.darkLevel` on the market, `if (global.blackMarket) global.darkLevel = false;`[^6], so the graveyard's message never shows there[^7].

## Reproducing it

Take the Black Market's hidden door on level 5, 6 or 7, until a market comes with graves on its earth; one in ten
does. It welcomes the player as any market does, and says nothing more. The replay, with seed 9, reaches the
market on level 6 as a graveyard, with eight graves and three Zombies: "WELCOME TO THE BLACK MARKET!" shows, and
"THE DEAD ARE RESTLESS!" never does. The player drops from the entrance onto the edge of a grave, which is solid[^8].

## In the port

The spelunky.ai port reproduces it exactly: it's in docs/quirks.md's list of the 1.1 source's bugs[^7], and the oracle's fingerprint of the replay pins the graves, the Zombies and the messages. No
option turns it off.

## FAQ

### Can the Black Market be a graveyard level?

Yes, one time in ten. The roll for a [graveyard level](https://spelunky.ai/wiki/restless-dead) is made for every Jungle level, the market's too, so a graveyard market has graves on its earth and Zombies and Vampires where the Jungle's monsters would be.

### Why doesn't the Black Market say THE DEAD ARE RESTLESS?

The market's welcome takes the level's first message. The graveyard's message would come second only on a dark level, and the Black Market is never dark.

### Can a graveyard market's grave hold the Shotgun?

Yes. Its graves are made as on any graveyard level, so one can be the Ash grave, with a free [Shotgun](https://spelunky.ai/wiki/shotgun) in it.

## See also

- **Related:** [Black Market](https://spelunky.ai/wiki/black-market), [Graveyard level](https://spelunky.ai/wiki/restless-dead), [The Jungle](https://spelunky.ai/wiki/jungle)

## References

[^1]: Clip [quirks/market-graveyard](https://spelunky.ai/wiki/black-market-graveyard#clip-quirks-market-graveyard)

[^2]: [`scripts/scrEntityGen.gml:176-205`](https://spelunky.ai/wiki/source/scripts/scrEntityGen#L176-L205)

[^3]: [`scripts/scrEntityGen.gml:280-288`](https://spelunky.ai/wiki/source/scripts/scrEntityGen#L280-L288)

[^4]: [`scripts/scrEntityGen.gml:332`](https://spelunky.ai/wiki/source/scripts/scrEntityGen#L332)

[^5]: [`objects/oPlayer1/alarm_0.gml:14-33`](https://spelunky.ai/wiki/source/objects/oPlayer1/alarm_0#L14-L33)

[^6]: [`scripts/scrInitLevel.gml:176`](https://spelunky.ai/wiki/source/scripts/scrInitLevel#L176)

[^7]: [“A Black Market can be a graveyard level, and never says so.”](https://github.com/851-labs/spelunky/blob/187c08df2d359683ed808ed14322c0bfcfaa3d7a/docs/quirks.md?plain=1#L190), [docs/quirks.md §1](https://github.com/851-labs/spelunky/blob/187c08df2d359683ed808ed14322c0bfcfaa3d7a/docs/quirks.md#1-bugs-and-leftovers-in-the-11-source)

[^8]: Replay [`fidelity/replays/jungle-seed-9-market-graveyard.txt`](https://github.com/851-labs/spelunky/blob/187c08df2d359683ed808ed14322c0bfcfaa3d7a/fidelity/replays/jungle-seed-9-market-graveyard.txt), which the clip [A Black Market on a graveyard level](https://spelunky.ai/wiki/black-market-graveyard#clip-quirks-market-graveyard) plays

### Source code

- [`scripts/scrInitLevel.gml`](https://spelunky.ai/wiki/source/scripts/scrInitLevel)
- [`scripts/scrEntityGen.gml`](https://spelunky.ai/wiki/source/scripts/scrEntityGen)
- [`objects/oPlayer1/alarm_0.gml`](https://spelunky.ai/wiki/source/objects/oPlayer1/alarm_0)
- [`objects/oPlayer1/alarm_1.gml`](https://spelunky.ai/wiki/source/objects/oPlayer1/alarm_1)
