Difference between revisions of "Monster creation"

From NetHackWiki
Jump to navigation Jump to search
m (Where this mechanism is used)
m (Where this mechanism is used: fix some refs)
Line 61: Line 61:
 
|-
 
|-
 
|[[Summon insects]]
 
|[[Summon insects]]
|{{mcsl|a}}{{mcsl|S}}{{refsrc|src/mcastu.c|584}}
+
|{{mcsl|a}}{{mcsl|S}}{{refsrc|src/mcastu.c|584|nethack=3.6.6}}
 
|Snakes are generated only if all insects are gone.
 
|Snakes are generated only if all insects are gone.
 
|-
 
|-
Line 77: Line 77:
 
|-
 
|-
 
|[[Swamp]] creation
 
|[[Swamp]] creation
|{{mcsl|F}}{{refsrc|src/542|nethack=3.6.6}}
+
|{{mcsl|F}}{{refsrc|src/mkroom|542|nethack=3.6.6}}
 
|
 
|
 
|-
 
|-
Line 89: Line 89:
 
|-
 
|-
 
|Random monster generation in the [[Quest]]
 
|Random monster generation in the [[Quest]]
|specified Quest monster classes {{refsrc|src/questpgr.c|nethack=3.6.6}}
+
|specified Quest monster classes {{refsrc|src/questpgr.c|655|nethack=3.6.6}}
 
|See [[Quest#Quest leaders and nemeses]] for monster classes.
 
|See [[Quest#Quest leaders and nemeses]] for monster classes.
 
|-
 
|-

Revision as of 19:01, 3 July 2022

A user has suggested improving this page or section as follows:

"Could use more details on the placement of generated monsters, the timing seems to be mostly covered. Could also stand to flesh out what levels employ special rules and link to the dedicated pages, as well as what governs other forms of monster creation."

Monster creation is the process by which NetHack determines when, where and how a particular monster is generated - whether it is randomly placing an unspecified creature somewhere on the floor, or else populating a freshly created level as soon as the player enters.

Normal monster generation takes place during level creation and at the end of each turn. Monster creation code is also invoked when the player or another monster makes use of an item that generates a monster, such as a scroll of create monster or a bag of tricks.

Normal monster selection

When a monster is generated, NetHack first determines which of the monsters in its database is eligible. Unique monsters and any monster marked with the flag G_NOGEN cannot be randomly generated; genocided and extinct monsters are excluded as well.[1]

From there, a monster is generally eligible if:[2]

  • Its difficulty is less than or equal to the average of the level's difficulty and the player level.
  • Its difficulty is at least one-sixth of the current level's difficulty.
  • If you are on the Rogue level, then monsters represented by glyphs with lower-case letters (e.g., a, b, c) are excluded from eligibility.
  • If you are in Gehennom, lawful monsters and those marked with the flag G_NOHELL (e.g., winter wolf) are excluded; conversely, monsters with the flag G_HELL) (e.g., hell hounds) are made eligible to be randomly generated only in Gehennom, and ineligible elsewhere.[3][4]
  • On the Elemental Planes:[5]

Each monster remaining on this list that meets the above conditions, has a probability to be generated equal to its effective monster frequency divided by the sum of the monster frequencies of every eligible monster. This can be visualized as a hat full of labeled slips of paper, with each one bearing the name of a monster - each creature's monster frequency determines how many slips of paper in the hat have its name, and the game then selects a name out of the hat at random.

Where this mechanism is used

At the end of each turn, or if an item that generates a monster is used, the possibility of creating a monster depends on the following:[6]

  • If the demigod flag is set - done by either killing the Wizard of Yendor at least once or performing the Invocation - there is a 125 chance of at least one monster being generated.
  • If the demigod flag is not set, but the player is in Gehennom, monster generation will occur with a 150 chance each turn.
  • Otherwise, normal monster generation takes place with a 170 chance each turn.

The following items or spells that create monsters are subject to this rule:

Selection by monster class

A user has suggested improving this page or section as follows:

"Document mkclass() mechanics"

Where a class of monster is specified, such as during the creation of certain levels (including the Gnomish Mines) or random generation in the Quest, a different monster generation algorithm is used, and monsters may be generated with probabilities different from the normal mechanism.[7]

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

mkclass() no longer generates master- and arch-liches outside of Gehennom.

Where this mechanism is used

Condition Monster classes Notes
Ringing a cursed bell n[8] 14 chance; not generated with inventory; if any nymph is genocided or extinct, none of them are generated.
Digging a grave ZM[9] 15 chance each of Z or M.
Demon summoning by demons; summon nasties in Gehennom (110 chance); chaotic or unaligned minion generation &[10][11] Same alignment as summoner, or any alignment if summoner is unaligned.
Summon insects aS[12] Snakes are generated only if all insects are gone.
15 of the time when attempting to generate a trapped secret door when level difficulty is at least 9 m[13] The mimic is generated instead of a secret door.
Inaccessible closet corpse @[14] It's a corpse, not a living monster.
Graveyard room creation; cursed charged Bell of Opening or cursed Book of the Dead &VZ[15] Other monsters may also be selected by a non-mkclass() mechanism.
Swamp creation F[16]
Throne room creation DHTCoGk[17] Bugbear and hobgoblin may also be selected.
Shop creation m[18]
Random monster generation in the Quest specified Quest monster classes [19] See Quest#Quest leaders and nemeses for monster classes.
Special level creation specified monster classes[20]

Special levels with monster class selection

A user has suggested improving this page or section as follows:

"{{{1}}}"

Level creation

The following steps are used to place monsters around the level upon its initial creation.

  • In normal room-and-corridor levels, there is a 33% chance of generating a monster (or group) per room.
  • In mazes, there is a 33% chance of generating 7-11 monsters + 0-2 minotaurs.

Other levels and branches follow various special rules for initial monster placement that are generally unique to each area and detailed on their respective articles.

See Also

References