Monster movement
In NetHack, there are various rules that define monster movement. Multiple monster attribute flags and other traits inform the game where and how an individual monster of a given type will move on each of its turns, including if they can even move at all, where they are able to move, and what they prioritize when moving, among other factors.
A user has suggested improving this page or section as follows:
"Expand and properly detail aspects of monster movement, including variants."
Movement and monster behavior
A monster will naturally move differently depending on their behavior towards the hero, i.e. whether they are peaceful, hostile or tame. Peaceful monsters will generally move around somewhat randomly, while hostile monsters will try to pursue the hero or seek out items, and tame monsters will stick closer to the hero in most cases unless there is an item or treat that they want.
Displacing monsters
- For the property that displaces the user's image, see displacement (property).
Tame and peaceful monsters can be displaced if the hero attempts to move into their square, causing them to switch places:[1] this occurs with a 6⁄7 chance if the monster is not a long worm with at least one tail segment, the hero is not wielding a bloodthirsty weapon (i.e., Stormbringer) and is neither punished nor inside a shop, and neither party is occupying a wall or other square that the other cannot enter without phasing.[2] Aligned clerics, shopkeepers, guards, the Oracle, and quest leaders cannot ever be displaced this way. Failing to displace any other monster may cause them to become scared for up to six turns.[3] If the hero attempts to displace a peeaceful or tame monster that currently cannot move, there is a 1⁄6 chance of the hero switching places with them regardless.[4]
A hero will attack a peaceful or tame monster instead of displacing them if they are confused, stunned, hallucinating, with no warning occurring.[5] Safe-moving the hero into a tame or peaceful monster via m while the hero is not wielding Stormbringer will simply print a message and use up the hero's turn, rather than attempting to displace the monster. Wielding Stormbringer will ignore safe-moving and attack any monster that the hero moves into, regardless of whether or not they are hostile (including during travel).[6]
Fighting monsters
A hero that moves into a hostile monster will automatically attempt to attack them[1]—see the linked article at the top of the section for more information.
Confusion and stunning
Monsters that are confused and/or stunned monsters will move more erratically: they will ignore whether or not they are adjacent to the hero when deciding to move or attack, and non-hostile monsters may also fail to avoid squares that the hero can push a boulder in Sokoban towards or ones that the hero has kicked towards recently.[7][8][9] Tame monsters will attack the hero by accident if they are confused.
Stalkers, bats and birds, and lights will choose a random square to move to on 1⁄3 of their turns, causing them to move as though they are confused even when they are currently not.[10]
Sessile monsters
A sessile monster has a movement speed of zero and thus never moves of its own volition: they can still be teleported or otherwise warped, and it is possible for a hero to displace one that is peaceful or tame.[2][4]
Movement types
Monster attributes that determine the specific ways in which a monster moves are listed below, and flags that have their own article are linked accordingly.
Flying
Some monsters are capable of flight, which allows them to move above pits, holes, and terrain such as pools or lava.
Swimming
Some monsters are swimmers that can move through and/or on top of pools and moats of water.
Amorphous
Some monsters are amorphous, which allows them to flow under closed doors.
Phasing
Some monsters have phasing, which enables them to walk through walls, boulders and other solid areas that are normally impassable for monsters.
Clinging
Some monsters can cling to the ceiling, which allows them to "walk" over the terrain underneath them.
Follower
A follower or "stalking" monster that is not fleeing or in the middle of another action will follow the hero to another floor if they are adjacent to that hero, regardless of if they are actually hostile.[11] Pets exhibit this behavior by default, and will still follow the hero even if scared—conversely, there are some cases where a non-tame monster will not follow the hero even if they are not fleeing or rendered immobile.
Wandering
A wandering monster that is both hostile and adjacent to a hero will ignore that they are adjacent to the hero 1⁄4 of the time when deciding whether to move or attack.[12] A wandering monster is denoted with the M2_WANDER flag.[13][14]
Stalkers, lights and bat or bird monsters other than the vampire bat are all wandering monsters, which combines with their "confused" behavior to create especially erratic movement.[10]
Collecting items
- For the command to grab items as the hero, see pick up.
- For the command used to merge stacks of similar items together, see adjust.
A monster will sometimes path towards objects that they come across if they are flagged to collect items or have a weapon attack, and will generally focus on picking up weapons, food and armor to carry if have the inventory space to do so.[15] Monsters that collect items are denoted with the M2_COLLECT flag.[16][17]
Gold lover
A gold lover is a monster that likes gold pieces, and will pick up any they come across while moving—these monsters are denoted with the M2_GREEDY flag.[18][19] Some hostile monsters will actively path towards gold while seeking out the hero, while peaceful monsters will occasionally pick up gold that they walk over (which is most easily seen in treasure zoos).
Gem lover
Some monsters like gems and similar items, and will pick up any they come across similarly to gold lovers—hostile ones will path towards gems and other stones as they search for the hero. These monsters can be informally referred to as "gem lovers" and are denoted with the M2_JEWELS flag.[20][21]
Magic lovers
Some monsters like to pick up magical items in particular, and hostile ones will seek them out while moving around. Monsters that like magic are denoted with the M2_MAGIC flag[22][23]—many monsters that can cast spells also like magical items.
Cannot pick up items
Some monsters are incapable of picking up items at all, in most cases due to lacking either any ability (or anatomy) to grab items or any desire to do so. These monsters are denoted with the M1_NOTAKE flag.[24][25]
Covetous
Covetous monsters desire one or more important items, and are capable of teleporting long distances across levels.
The quest nemeses, Vlad the Impaler and the Wizard of Yendor are all covetous monsters.
Displacers
Some monsters are capable of forcing other monsters out of their way while moving around the dungeon, switching places with them the same way a hero can with non-hostile monsters—these displacing monsters are denoted with the M3_DISPLACES flag.[26][27]
The only monsters capable of displacing other monsters are the Riders–Death, Pestilence, and Famine–and the displacer beast, which also has the displacement property.
Strategy around monster movement
Learning how monsters move is critical to dealing with hostile monsters in combat situations, as well as managing pets.
History
In NetHack 3.6.7 and previous versions, including some variants based on those versions, monster movement follows different rules:
- The hero is only capable of displacing pets: a hero that is not wielding Stormbringer and moves normally into a peaceful monster other than a pet will be given a 'yes/no' message prompt to confirm if they want to attack.[28]
- Monsters will not avoid squares that the hero kicks in the direction of.
- In Sokoban, monsters can generate and move in the hallways where the level's pits or holes are, frequently resulting in them obstructing boulder movement.
Variants
NetHack variants created prior to NetHack 5.0.0 will often have implemented displacement of peaceful monsters for the hero, due to the amount of convenience afforded by the feature compared to vanilla releases of the time. Many variants will also introduce more forms of monster movement and/or alter existing methods in order to provide more variance in tactics.
GruntHack
GruntHack implements displacement of peaceful monsters for the hero, and changes the movement behavior of several monsters:
- Stalkers, lights, and bat or bird monsters other than the vampire bat are treated as being permanently stunned, rather than just moving similarly to how a confused monster would.
- Hostile monsters may actively path towards the hero's pet.
SporkHack
SporkHack implements displacement of peaceful monsters for the hero.
dNetHack
dNetHack implements displacement of peaceful monsters for the hero, alongside many changes to a monster's movement capabilities compared to NetHack 3.4.3:
- Monsters can perform sneak attacks.
- Pets can be commanded to move in specific manners, and can be made to attack other monsters aggressively or restrain themselves.
SpliceHack
SpliceHack makes monsters more capable of tactical movement, such as flanking or hanging back to support other monsters.
EvilHack
EvilHack implements displacement of peaceful monsters for the hero, alongside many changes to a monster's movement capabilities compared to the NetHack 3.6 series:
- Monsters can jump in the hero's direction.
- Some monsters are skittish and will try to actively avoid the hero unless they are cornered.
- Hostile monsters that are large enough can flatten smaller-enough monsters instead of displacing them in order to get to the hero.
- Covetous warping takes a monster shorter distances towards their current objective.
- Pets can be commanded to move in specific manners.
Hack'EM
Hack'EM implements displacement of peaceful monsters for the hero, and carries over many forms of movement added in EvilHack and SpliceHack.
References
- ↑ 1.0 1.1 src/uhitm.c in NetHack 5.0.0, line 462-L511: checks for switching places versus attacking in do_attack()
- ↑ 2.0 2.1 src/uhitm.c in NetHack 5.0.0, line 474-L478: conditions for switching places
- ↑ src/uhitm.c in NetHack 5.0.0, line 496-L502: scaring a monster that the hero fails to displace
- ↑ 4.0 4.1 src/uhitm.c in NetHack 5.0.0, line 503-L507: attempting to move past an immobile monster
- ↑ src/uhitm.c in NetHack 5.0.0, line 308-L309
- ↑ src/uhitm.c in NetHack 5.0.0, line 310-L314
- ↑ src/monmove.c in NetHack 5.0.0, line 882
- ↑ src/monmove.c in NetHack 5.0.0, line 1301
- ↑ src/monmove.c in NetHack 5.0.0, line 1317
- ↑ 10.0 10.1 src/monmove.c in NetHack 5.0.0, line 1870-L1872
- ↑ src/mondata.c in NetHack 5.0.0, line 1209-L1226
- ↑ src/monmove.c in NetHack 5.0.0, line 886
- ↑ include/monflag.h in NetHack 5.0.0, line 145
- ↑ include/mondata.h in NetHack 5.0.0, line 115
- ↑ src/monmove.c in NetHack 5.0.0, line 1017-L1019
- ↑ include/monflag.h in NetHack 5.0.0, line 152
- ↑ include/mondata.h in NetHack 5.0.0, line 145
- ↑ include/monflag.h in NetHack 5.0.0, line 150
- ↑ include/mondata.h in NetHack 5.0.0, line 143
- ↑ include/monflag.h in NetHack 5.0.0, line 151
- ↑ include/mondata.h in NetHack 5.0.0, line 144
- ↑ include/monflag.h in NetHack 5.0.0, line 156
- ↑ include/mondata.h in NetHack 5.0.0, line 146
- ↑ include/monflag.h in NetHack 5.0.0, line 96
- ↑ include/mondata.h in NetHack 5.0.0, line 54
- ↑ include/monflag.h in NetHack 5.0.0, line 175
- ↑ include/mondata.h in NetHack 5.0.0, line 156
- ↑ src/uhitm.c in NetHack 3.6.7, line 344: is_safepet() check