Combat

From NetHackWiki
Revision as of 07:13, 12 September 2024 by Umbire the Phantom (talk | contribs) (todo, upcoming, etc.)
Jump to navigation Jump to search

Combat in NetHack consists of an exchange of attacks between the combatants, whether in melee or via ranged attack. Combat can occur either between the hero and another monster or between two monsters.

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

"Double over to make sure that basics and critical features are covered before dealing with variants."

Description

The hero and monsters can attack using the following methods:

The hero

These combat mechanics are specific to the hero.

  • For unarmed melee combat, some of the roles available to the hero have access to the bare hands skill, while others make use of martial arts.
  • The hero is capable of twoweapon combat using shift + X, which allows them to wield a weapon in each hand and attack in melee with them twice per action.
  • The hero's spellcasting uses their energy reserve and requires that they learn spells from spellbooks.
  • A hero polymorphed into the form of a monster will use all of that monster's applicable attacks when fighting in melee - this can be dangerous when fighting monsters with passive abilities! See the section below for more details on monster attacks.

Monsters

Monster combat functions in a significantly different manner from standard combat for the hero. Monsters are capable of moving and attacking in the same turn, and almost all monsters have a sequence of one or more attacks available to them, in addition to the use of items - the strength of these attacks is dependent on their hit dice. Monsters attacking a target will perform all available and applicable attacks in their sequence once during each combat action.

The following mechanics are also applied to attacking monsters:

  • If a monster is at a distance from their target, they will only use ranged attacks, including breath weapons and items such as thrown weapons.
  • If a monster is adjacent to their target, they will only use melee-applicable attacks, though they can also use items such as wands that can perform ranged attacks. This also applies to the hero in the form of an appropriate monster.
  • Passive attacks have a chance to trigger automatically when a monster is hit in melee, and will "counter-attack" whoever hits them; this also applies to a hero in the form of that monster. Some passive attacks may occur even if the attack that triggers them kills the monster in question.
  • Similarly, there are passive attack-like abilities that trigger when certain weapons and items make contact with a monster; these also apply to the hero when in the form of such monsters, and similarly will occur in some cases where the attack killed the monster.
  • For monsters, spellcasting functions differently from that of the hero - only monsters with spellcasting in their attack sequence will actively cast spells as part of that sequence, and they use a different list of monster spells only available to them; they also do not have a set energy pool, with the success of each spellcasting attempt determined by chance.

Effects of combat

Various effects of combat, such as the ability of a combatant to hit another, the odds of a combatant hitting successfully or else being hit, and the amount of damage combatants take from being hit, depend on several factors.

  • Speed determines how many rounds of combat a hero or monster gets each turn.
  • To-hit chances and damage are calculated using several variables, such as skill level and whether or not an item is designed to be used as a weapon in a certain way (i.e. in melee, thrown, shot, fired, etc.) - each weapon has their own hit dice and to-hit bonuses or penalties.
    • Items that are not designed to function as weapons can still deal a base amount of damage when used as one, which is generally calculated based on their weight unless otherwise specified; wielding or throwing specific items, e.g. potions or the corpse or egg of a cockatrice or chickatrice, can also have certain additional effects in addition to damage.
    • Exceptions to the above rule are the cream pie and expensive camera: both are coded to not deal damage at all if a hero or monster is hit by one.[1][2]
  • Armor class determines how likely a target combatant is to be hit, as well as how much damage they take upon being hit.

Hero-monster combat

For the hero, combat is performed through one of several methods:

  • Attempting to move onto a monster's square normally will attempt to attack them.
    • The hero automatically attacks if the monster they move into is hostile, while doing so a peaceful monster will cause a "yes/no" prompt to come up asking the player if they really want to attack.[3] Pets will not be attacked this way, and the hero will attempt to displace them instead.
    • A hero that is stunned or confused will attack any monster if confused movement or stunned movement would take them into that monster's square, with no prompt occurring.
    • While wielding the artifact Stormbringer, the bloodthirsty weapon will cause the hero to attack any monster they move into, ignoring prompts.
  • Using the force-fight command by pressing shift + F will force the next movement input to be interpreted as a melee attack, ignoring any prompts for monsters in the direction of the input given.
  • The hero can kick at other monsters by using Ctrl + D and selecting an applicable direction.
  • The hero can throw specific weapons or other objects via t or fire quivered items via f; they can quiver items to throw manually via shift + Q, or else select them from a prompt if they press f with nothing quivered. Throwing items at monsters does not bring up any prompts, and will anger peaceful monsters regardless of whether or not they hit them, with some notable exceptions:
    • Throwing certain types of food at domestic animals will either pacify them or tame them.
    • Throwing gold at a hostile shopkeeper or Yendorian Army fighter has a chance to pacify them - see their articles for more details.
    • Throwing the quest artifact of the hero's role to the quest leader will cause them to catch it and return it, which does not anger them.
  • The hero can read certain scrolls with r for offensive purposes.
  • The hero can cast applicable spells that they know using the shift + Z command.
  • The hero can zap directional wands at monsters with z if they have hands to do so.

For monsters, they will only target the hero if they are hostile or under the effects of conflict, and attack under the following conditions:

  • Monsters that have weapon attacks can throw or shoot at the hero if they are in range and the monster has an applicable projectile (including appropriate launchers if necessary). Otherwise, if they are not adjacent to the hero, the monster will attempt to move closer to them, and attack if that movement places them adjacent to the hero; they will also attack if they are already adjacent to the hero at the start of their turn.
  • Monsters with breath weapons or spitting attacks will only use them if the hero is in range and not adjacent to that monster.
  • Monsters carrying cream pies will throw them at the hero.
  • Like the hero, monsters can wield the corpse of a cockatrice or chickatrice to swing at the hero if they have gloves or stoning resistance, and can also throw cockatrice eggs at the hero as well.
  • Monsters that have hands and are carrying certain wands may zap them offensively at the hero.
  • Monsters that have potions with detrimental effects can use them offensively by throwing them at the hero.
  • Monsters using ranged attacks against the hero will not account for any other monsters in the attack path.
  • If the hero is invisible or has displacement, the monster will attempt to move towards and/or attack the square where they believe the hero to be. Once they find the hero, they will not miss attacks this way until the hero moves again.
  • A hostile monster that is scared and not under the effects of conflict will flee from the hero and avoid attacking them in melee if possible - they will still use any ranged attacks they have at their disposal, and if the monster cannot move away from the hero, they may also use melee attacks.

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

The hero can now displace peaceful monsters with some exceptions, and this functions the same as with pets.

Per commit 82f0b1e8, fleeing hostile monsters are much more likely to attack in a panic if they cannot move away from the hero.

}}

Combat between monsters

Monsters attack each other under the following circumstances:

  • Pets will target other non-tame monsters that are in range of their attacks, whether or not those monsters are hostile to the hero.
  • Monsters that are not pets will not actively attack each other, unless they are under the effects of conflict or specific conditions are fulfilled:
    • Covetous monsters will attempt to attack any monsters that have their desired items in order to steal them, e.g. the Wizard of Yendor will attack any monster that has the Amulet of Yendor, such as the high priest of Moloch.
    • Purple worms are specially-coded to actively attack any shriekers that they encounter.
    • Monsters attempting to attack an invisible or displaced hero may target a square where another monster is standing.
    • As mentioned previously, monsters using ranged attacks against the hero will not account for any other monsters standing in the attack path.
  • A monster attacked by another monster under any circumstance has a chance of retaliating against them.

Strategy

Managing combat is naturally a vital component of survival for any hero in NetHack: this includes using traps and other elements of the dungeon to your advantage, as well as employing tactics such as hit and run, and even just knowing when to engage in combat to begin with - discretion is the better part of valor. Understanding a monster's attack sequences and how monsters in general fight is also important when dealing with a hostile monster or keeping a monster as a pet.

Pacifism and combat

Main article: Pacifist

Though the pacifist conduct is reliant on the hero not killing any monsters, a pacifist hero will still need to be experienced with combat scenarios regardless: hostile monsters will attack them regardless of whether or not they fight back, and they must also keep track of pet(s) and manage their health and combat abilities since they handle fighting on their behalf.

Remember that the pacifist conduct only concerns itself with killing monsters outright rather than attacking them at all, though many pacifists will often be weaponless as well in order to significantly reduce the odds of killing a monster. Pacifists can still use offensive tactics against monsters in order to make them easier for pets to kill, such as putting monsters to sleep so they are less likely to pursue you or retaliate against your pets.

History

In NetHack 3.4.3 and previous versions, including variants based on those versions, the speed system uses a flat and consistent movement rate for the hero and monsters. As a result, combat works much differently in those versions of NetHack than they do in NetHack 3.6.0 and any version since (including applicable variants).

Variants

Variants of NetHack frequently introduce changes to combat mechanics, with the base that a variant works from dependent on their version.

References

  1. src/uhitm.c in NetHack 3.6.7, line 892: attacking with a wielded camera
  2. src/uhitm.c in NetHack 3.6.7, line 998: attacking with a thrown or wielded cream pie
  3. src/uhitm.c in NetHack 3.6.7, line 212