Difference between revisions of "Monster creation"

From NetHackWiki
Jump to navigation Jump to search
m (link to demigod and clarify what it means)
Line 1: Line 1:
{{todo|How does the game decide whether or not to create a monster '''in the first place'''? And where to place it?}}
+
{{todo|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.}}
  
The '''normal mechanism of monster creation''', responsible for the vast majority of [[monster]]s in [[NetHack]], is used when the game wants to create an unspecified opponent of adequate difficulty for the player.
+
'''Monster creation''' is 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.
  
Monster Generation occurs when (1) the level is created and (2) at the end of each turn.
+
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]].
* For level 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
 
* At the end of each turn, the possibility of creating a monster depends on the following: {{refsrc|allmain.c|121}}
 
** If the [[demigod]] flag is set (killed the Wizard or performed the Invocation), monster generation happens with probability 1/25 (4%).
 
** Otherwise, if the player is in Gehenmon, monster generation happens with probability 1/50 (2%).
 
** Otherwise, monster generation happens with probability 1/70.
 
  
When this occurs, each eligible monster has a probability equal to its effective [[monster frequency]] divided by the sum of the monster frequencies of every eligible monster. This may be thought of as generating a list of all such monsters with each appearing as many times as its frequency, and then choosing at random hence. A monster is eligible if it:
+
==Normal monster selection==
 +
When a monster is generated, ''NetHack'' first determines which of the monsters in its database is eligible. [[Unique monster]]s and any monster marked with the flag <code>G_NOGEN</code> cannot be randomly generated;{{refsrc|makemon.c|1152}} [[genocide]]d and [[extinct]] monsters are excluded as well.
  
* Is no greater in [[difficulty]] than the average of the level's difficulty and the player level {{refsrc|makemon.c|1226}}
+
From there, a monster is generally eligible if:
* Is no lower in difficulty than one-sixth that of the current level's difficulty{{refsrc|makemon.c|1246}}
+
 
* Is neither [[unique monster|unique]] nor marked as '''not randomly generated''' (G_NOGEN) {{refsrc|makemon.c|1152}}
+
* Its difficulty is less than or equal to the average of the level's difficulty and the player level.{{refsrc|makemon.c|1226}}
* Is not [[genocide]]d or [[extinct]]
+
* Its difficulty is at least one-sixth of the current level's difficulty.{{refsrc|makemon.c|1246}}
* If you are on the [[rogue level]]:
+
* It meets all other conditions that are dictated by flags in their data, which are compared against the branch or special level in question - see [[#Special rules|"Special rules"]] below.
** Is represented by an upper case letter
+
 
* If you are in [[Gehennom]]:
+
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.
** Is not [[Lawful]]
+
 
** Is not marked as '''not generated in Gehennom''' (G_NOHELL) (e.g. [[winter wolf]])
+
==Level creation==
* If you are not in Gehennom:
+
The following steps are used to place monsters around the level upon its initial creation.
** Is not marked as '''only generated in Gehennom''' (G_HELL) (e.g. [[hell hound]])
+
 
* If you are on the [[Plane of Water]]:
+
* In normal room-and-corridor levels, there is a 33% chance of generating a monster (or group) per room.
** Is a [[swimmer]]{{refsrc|makemon.c|69}}
+
* In mazes, there is a 33% chance of generating 7-11 monsters + 0-2 [[minotaur]]s.
* If you are on the [[Plane of Fire]]:
+
 
** Has [[fire resistance]]{{refsrc|makemon.c|71}}
+
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.
* If you are on the [[Plane of Air]]:
+
 
** Is [[flying]], [[whirly]], [[floating]], [[amorphous]] or [[non-corporeal]]{{refsrc|makemon.c|73}}
+
==Random generation==
** Is not a [[trapper or lurker above]]
+
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:{{refsrc|allmain.c|121}}
 +
 
 +
* If the [[demigod]] flag is set - done by either killing the [[Wizard of Yendor]] at least once or performing the [[Invocation]] - there is a {{frac|25}} chance of at least one monster being generated.
 +
* If the demigod flag is not set, but the player is in [[Gehenmon]], monster generation will occur with a {{frac|50}} chane each turn.
 +
* Otherwise, normal monster generation takes place with a {{frac|70}} chance each turn.
 +
 
 +
The following items or spells that create monsters are subject to this rule:
 +
 
 +
* [[Spellbook of create monster]]
 +
* [[Wand of create monster]]
 +
* [[Scroll of create monster]]
 +
* [[Bag of tricks]]
 +
 
 +
===Special rules===
 +
Random generation for non-standard levels also follow certain rules for determining eligibility that are dependent on the branch and level in question:
 +
 
 +
* If you are on the [[Rogue level]], then monsters represented by glyphs with lower-case letters (e.g., {{mcsl|a}}, {{mcsl|b}}, {{mcsl|c}}) are excluded from eligibility.
 +
* If you are in [[Gehennom]], [[lawful]] monsters and those marked with the flag <code>G_NOHELL</code> (e.g., [[winter wolf]]) are excluded; conversely, monsters with the flag <code>G_HELL</code>) (e.g., [[hell hound]]s) are made eligible to be randomly generated ''only'' in Gehennom, and ineligible elsewhere.{{refsrc|src/makemon.c|1473|version=NetHack 3.6.6}}
 +
* On the [[Elemental Planes]]:
 +
** If you are on the [[Plane of Water]], only [[swimmer]]s are eligible for random generation.{{refsrc|makemon.c|69}}
 +
** If you are on the [[Plane of Fire]], only monsters with [[fire resistance]] are eligible.{{refsrc|makemon.c|71}}
 +
** If you are on the [[Plane of Air]], only monsters that are capable of [[flying]] or [[floating]], and are [[whirly]], [[amorphous]], or [[non-corporeal]] are eligible. The [[trapper or lurker above]] [[monster class]] is explicitly excluded, as both monsters rely on matching the surroundings of the dungeon walls, floor and ceiling to hide.{{refsrc|makemon.c|73}}
  
 
==See Also==
 
==See Also==
Line 38: Line 53:
 
*[[summon insects]]
 
*[[summon insects]]
 
*[[polymorph]]
 
*[[polymorph]]
*[[spellbook of create monster]]
 
*[[wand of create monster]]
 
*[[scroll of create monster]]
 
 
*[[special room]]s
 
*[[special room]]s
*[[special level]]
+
*[[Special level]]
  
 
==References==
 
==References==
 
+
<references/>
  
 
[[Category:Monster mechanics]]
 
[[Category:Monster mechanics]]
{{nethack-343}}
+
{{nethack-366}}

Revision as of 04:22, 3 May 2021

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 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;[1] genocided and extinct monsters are excluded as well.

From there, a monster is generally eligible if:

  • Its difficulty is less than or equal to the average of the level's difficulty and the player level.[2]
  • Its difficulty is at least one-sixth of the current level's difficulty.[3]
  • It meets all other conditions that are dictated by flags in their data, which are compared against the branch or special level in question - see "Special rules" below.

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.

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.

Random generation

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:[4]

  • 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 Gehenmon, monster generation will occur with a 150 chane 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:

Special rules

Random generation for non-standard levels also follow certain rules for determining eligibility that are dependent on the branch and level in question:

See Also

References