Difference between revisions of "Spellcasting"

From NetHackWiki
Jump to navigation Jump to search
m (Calculating spell success rate: Special spell - for your role)
(History: it's a wonder this feature lasted at all for as long as it did)
 
(28 intermediate revisions by 8 users not shown)
Line 2: Line 2:
 
{{for|monsters' spellcasting mechanics|monster spells}}
 
{{for|monsters' spellcasting mechanics|monster spells}}
  
'''Spellcasting''' is the act of casting a [[spell]], using the '''{{kbd|Z}}''' command. Casting a spell drains your innate magical [[power]], rather than using an external source of magic such as a [[scroll]] or [[wand]].
+
In ''[[NetHack]]'', '''spellcasting''' is the act of casting a [[spell]], done by using the '''{{kbd|Z}}''' command. Casting a spell uses [[you]]r innate magical [[power]] as a source, rather than using an external source of magic such as a [[scroll]] or [[wand]].
  
[[Healer]]s, [[monk]]s, [[priest]]s and [[wizard]]s are [[role]]s which begin the game with knowledge of one or more spells and are often able to cast them; other classes must find at least one [[spellbook]] and [[read]] it first.
+
[[Healer]]s, [[Monk]]s, [[Priest]]s and [[Wizard]]s begin the game with knowledge of one or more spells, whose corresponding spellbooks appear in their initial [[inventory]]; other [[role]]s must find at least one [[spellbook]] and successfully [[read]] it first.
  
When you are prompted to select a spell to cast, a menu will appear of the spells you know, accompanied by their chance of [[#Calculating_spell_success_rate|failure]]. The {{kbd|+}} key brings up this same menu and allows you to rearrange the spells so you can place them on more convenient letters.
+
==Basics==
 +
You must know at least one spell in order to cast; when casting a spell, a menu of known spells and their chance of failure is displayed. You can also view your list of known spells by pressing {{kbd|+}}, and pressing {{kbd|+}} again allows you to rearrange the spells so you can place them on more convenient letters.
  
A spell's chance of failure is affected by either [[intelligence]] or [[wisdom]], [[experience level]], [[skill]] level, your role's innate magical affinity, and what [[armor]] you are wearing: [[metal]] armor in particular can impact chances of success, as well as the type of [[shield]] if applicable. Failure rates can be reduced by wearing a [[robe]], and additionally reduced further if the spell is an [[emergency spell]] or your role's [[special spell]].
+
A spell's chance of failure is affected by your spellcasting [[attribute]] (either [[intelligence]] or [[wisdom]]), [[experience level]], [[skill]] level, your role's innate magical affinity, and what [[armor]] you are wearing: [[metal]] armor in particular can impact chances of success, as well as any worn shield and their material if applicable. Failure rates can be reduced by wearing a [[robe]], and can be additionally reduced further if the spell is an [[emergency spell]] or your role's [[special spell]]. For details, see the article section on how to [[#Calculating spell success rate|calculate spell failure chance]].
  
When you attempt to cast a spell, the game rolls for success or failure. If you fail, you will receive the message "You fail to cast the spell correctly." Otherwise, the spell takes effect.
+
When you attempt to cast a spell, the game rolls for success or failure against this rate, with a message coming up if you failed to cast the spell; otherwise, the spell immediately takes effect, prompting for a direction if necessary. [[Training]] skills in spell schools is done by successfully casting spells in that school, and raises the percentage by an amount equal to the spell's level; the spell itself does not have to directly affect anything.
  
In addition to costing energy, spellcasting also costs [[nutrition]], which can be reduced or eliminated by [[hungerless casting]]. Casting {{spell of|detect food}} never costs nutrition.
+
Casting spells requires a certain amount of [[energy]] and [[nutrition]] proportionate to the spell's level; failing to cast a spell correctly uses up only a portion of that energy, and the {{spell of|detect food}} spell does not drain nutrition when cast.{{refsrc|src/spell.c|982|version=NetHack 3.6.0|comment=Failing to correctly cast a spell wastes only half of casting cost.}}{{refsrc|src/spell.c|929|version=NetHack 3.6.0|comment=[[Detect food]] has no casting hunger cost.}} Wizards have access to [[hungerless casting]] that can reduce or even eliminate nutrition costs, based on their intelligence score.  
  
Each successful cast of a spell [[training|trains]] its associated spell skill by an amount equal to its level, regardless of whether the spell affected anything.
+
You cannot cast a spell if you lack the required energy, and in certain circumstances your energy or nutrition can be drained enough that an otherwise successful spell will end up failing; see [[#Spellcasting costs|spellcasting costs]] for further information. There are also other circumstances and requirements that can affect spellcasting:
  
Technically, using [[teleport at will]] is also considered to be a cast of a spell, and follows many but not all of the same rules as casting {{spell of|teleport away}} (it bypasses the percentage failure rate calculation, for instance).
+
* You cannot cast spells if you are [[stunned]].{{refsrc|src/spell.c|644|nethack=3.6.6}}
 +
* Your [[strength]] must be at least 4 to cast a spell, unless you are trying to cast {{spell of|restore ability}}.
 +
* You cannot be [[overtaxed]] or overloaded in terms of encumbrance.
 +
* You must also be capable of physically vocalizing the spell to cast it{{refsrc|src/spell.c|644|nethack=3.6.6}} – [[strangulation]] and polyforms that are headless, only make animal sounds or are otherwise incapable of speaking (e.g., [[grid bug]], [[jabberwock]], [[mimic]], [[jaguar]]) will stop you from casting spells.
 +
* You must also have at least one free hand to direct the energy – this means you cannot cast if there are [[cursed]] weapons or [[shield]]s in both hands.
 +
** This only applies if you are in a form that has hands; polyforms that lack hands do not prevent you from casting.
 +
* If [[confused]], you can attempt to cast spells, but they will always fail with the same effects as random spell failure.
  
== Prerequisites for casting a spell ==
+
While using [[teleport at will]] is also considered to be a cast of a spell, and follows many of the same rules as casting {{spell of|teleport away}}, there are a few notable differences - teleport at will ignores failure rates, for instance.
If any of the following conditions are true, you will not be able to cast any spells at all:
 
# You don't know any spells.
 
# You are [[stunned]].{{refsrc|src/spell.c|644|nethack=3.6.6}}
 
# You are incapable of chanting the spell.{{refsrc|src/spell.c|644|nethack=3.6.6}} This can be due to any of:
 
## You are getting [[strangulation|strangled]].
 
## You are polymorphed into a silent or headless form.
 
## You are polymorphed into something that is only capable of "buzzing" ([[killer bee]], [[queen bee]], [[grid bug]], [[xan]]) or "burbling" ([[wumpus]], [[jabberwock]]).
 
# Both of your hands have [[cursed]] gear stuck to them (either through wielding a cursed two-handed weapon or through wearing a cursed shield and wielding a cursed one-handed weapon). For some reason, being polymorphed into a form without hands does not prevent you from casting spells.
 
# You have forgotten the spell you chose to cast (see below).
 
# You are [[weak]] and very close to fainting, and you are trying to cast something other than {{spell of|detect food}}.
 
# Your [[Strength]] is below 4, and you are trying to cast something other than {{spell of|restore ability}}.
 
# You are [[Overtaxed]] or worse.
 
# You don't have enough [[energy]] to cast the spell you picked.
 
# You are [[confused]]. (This is the last thing checked, and if it is the only reason you are unable to cast, you lose half of the spell's normal energy cost).{{refsrc|src/spell.c|1018|nethack=3.6.2}}
 
  
== Forgotten spells ==
+
==Spellcasting costs==
 +
Each spell costs an amount of energy equal to 5 times the spell's level in order to cast;{{refsrc|src/spell.c|908|version=NetHack 3.6.0|comment=Spell cost.}} if you are carrying the [[Amulet of Yendor]], it drains an amount of energy between 1 point and 2 times the usual cost as you attempt to cast.{{refsrc|src/spell.c|952|version=NetHack 3.6.1|comment=Amulet of Yendor's penalty on spell cost.}}. If you do not have the required energy to cast the spell, nothing happens; if the Amulet drains enough energy to prevent the spell being cast, this uses up a move.{{refsrc|src/spell.c|956|version=NetHack 3.6.1|comment=Attempting to cast a remembered spell without enough energy uses a move if Amulet drain occurred.}} If you have the energy for a spell and fail to cast it correctly, only half of that spell's energy cost (rounded down) is used up.
  
Spell knowledge only lasts for 20,000 turns after reading a spellbook. Once this time is up the spell is forgotten, and is marked with an asterisk <tt>*</tt> in the casting menu. Spellbooks may be re-read once the timeout is at or below 1,000 turns. This will reset the timeout to 20,000 turns.{{refsrc|src/spell.c|379|version=NetHack 3.6.0|comment=Refreshing or learning a spell.}} Attempting to read a spellbook before the timeout is low enough will produce the message "You know <spell> quite well already". This will not use up a reading of the spellbook, and if read while owned by a shopkeeper, will not result in a [[usage fee|use fee]]{{refsrc|src/spell.c|376|version=NetHack 3.6.0|comment=Reading book of keenly known spell.}}.
+
In addition, casting any spell other than detect food uses an amount of nutrition equal to two times the energy cost; this is usually 10 times the spell's level, before factoring in reduced-hunger casting for Wizards (hungerless casting ignores this entirely). A failed cast of a spell costs as much as a successful one, and carrying the Amulet has no impact on nutrition costs. Being weak and very close to fainting from [[hunger]] can prevent you from properly casting any spell other than detect food; fainting will outright prevent casting of those other spells, regardless of whether or not you have hungerless casting.
  
Attempting to cast a forgotten spell will not check any of the usual casting prerequisites except stunning, and will consume neither nutrition nor power. It will instead make you [[confusion|confused]], [[stun]]ned, or both. The duration of confusion and stunning is dependent on the level of the forgotten spell, but the choice of effects is not.
+
As an example, casting a level 3 spell normally requires 15 energy and 30 nutrition; if you fail to cast it, only 7 energy is used. When carrying the Amulet of Yendor, there is an energy penalty of 1 to 30 points, so the total energy cost varies from 16 to 45. The nutrition cost will always be 30 regardless of the circumstance.
  
The exact effect of casting a forgotten spell is as follows:{{reffunc|src/spell.c|spell_backfire|version=NetHack 3.6.0|comment=Casting a forgotten spell.}}
+
==Forgotten spells==
 +
Spell knowledge lasts for 20,000 turns after learning the spell from a spellbook; a spell is forgotten once this duration expires, and forgotten spells are marked with an asterisk <tt>*</tt> in the casting menu. Re-reading a spellbook for a spell with a timeout at or below 1,000 turns will refresh knowledge of that spell and reset the timeout to 20,000 turns;{{refsrc|src/spell.c|379|version=NetHack 3.6.0|comment=Refreshing or learning a spell.}} attempting to read a spellbook before the timeout is low enough will not use up a reading of the spellbook (meaning it will not result in a [[usage fee]] with unpaid spellbooks in a [[shop]]).{{refsrc|src/spell.c|376|version=NetHack 3.6.0|comment=Reading book of keenly known spell.}}
 +
 
 +
Attempting to cast a forgotten spell will leave you confused and/or stunned, with the duration dependent on the level of the forgotten spell; this does not consume any nutrition or power. The exact effects of casting a forgotten spell are as follows:{{reffunc|src/spell.c|spell_backfire|version=NetHack 3.6.0|comment=Casting a forgotten spell.}}
  
 
{| class="prettytable"
 
{| class="prettytable"
Line 64: Line 61:
 
|}
 
|}
  
Forgotten spells are a common way to deliberately become [[confused]], to invoke the alternative effects of certain [[scroll]]s.
+
Forgotten spells are a common way to deliberately become confused and invoke the alternative effects of certain [[scroll]]s.
 
 
== Spellcasting cost ==
 
 
 
Casting a spell costs [[energy]] points, equal to 5 times the spell's level {{refsrc|src/spell.c|908|version=NetHack 3.6.0|comment=Spell cost.}}.  If you are carrying the [[Amulet of Yendor]], it drains an amount of energy between 1 point and 2 times the usual cost as you attempt to cast (“''You feel the amulet draining your energy away.''”) {{refsrc|src/spell.c|952|version=NetHack 3.6.1|comment=Amulet of Yendor's penalty on spell cost.}}. If you do not have the required energy after this (“''You don't have enough energy to cast that spell.''”), nothing happens; this only uses a move if the Amulet drained energy{{refsrc|src/spell.c|956|version=NetHack 3.6.1|comment=Attempting to cast a remembered spell without enough energy uses a move if Amulet drain occurred.}}.  If the attempt fails (“''You fail to cast the spell correctly.''”), only half of that energy is used up, rounded down {{refsrc|src/spell.c|982|version=NetHack 3.6.0|comment=Failing to correctly cast a spell wastes only half of casting cost.}}.
 
 
 
Casting any spell other than {{spell of|detect food}}{{refsrc|src/spell.c|929|version=NetHack 3.6.0|comment=[[Detect food]] has no casting hunger cost.}} uses [[nutrition]] equal to two times the energy cost (including the Amulet penalty), which means that it is usually 10 times the spell's level. If you are a [[wizard]] with sufficiently high [[intelligence]], you might be able to take advantage of [[reduced-hunger casting|hungerless or reduced-hunger casting]]. A failed cast costs just as much nutrition as a successful one. If you are [[Hunger|fainting]], you cannot cast any spells other than detect food, whether or not you have hungerless casting.
 
 
 
As an example, casting a level 3 spell normally requires 15 energy and 30 nutrition.  If you fail to cast it, only 7 energy is used, but you still lose 30 nutrition.  When carrying the Amulet of Yendor, there is an energy penalty of 1 to 30 points, so the total energy cost varies from 16 to 45, but the nutrition cost is still 30.
 
 
 
== Calculating spell success rate ==
 
When '''[[spellcasting]]''' the '''Fail''' column appears in the menu which occurs when using the {{kbd|Z}} [[commands|command]].
 
 
 
To calculate [[spell]] '''failure''' you can use the tool referenced in the External Links section below.
 
  
The algorithm is as follows. An increasing total penalty is worse for spellcasting, and is limited to a maximum of 20. You first need to add together the penalties listed below:
+
==Calculating spell success rate==
 +
The spell failure rate given in the spellcasting menu is calculated using the listed algorithm below, and the values in the table below this list, with higher numbers signifying harsher penalties (limited to a maximum of 20):
  
*   The "Base" value from the table below, depending on the character's class.
+
* Start with the "base" value associated with your role.
*   If an "emergency" spell, the "Emergency" field.  Spells considered emergency spells are all [[healing spells]] except for {{spell of|stone to flesh}}, and {{spell of|remove curse}}. {{refsrc|src/spell.c|1618|version=NetHack 3.6.0|comment=List of emergency spells.}}
+
* Each role also has an "Emergency" modifier for [[emergency spell]]s - specifically, {{spell of|remove curse}} and all [[healing spells]] except for {{spell of|stone to flesh}} - that is applied when casting such a spell.{{refsrc|src/spell.c|1618|version=NetHack 3.6.0|comment=List of emergency spells.}}
*   If wearing any [[shield]], the amount in the "Shield" field.
+
* If you are wearing any [[shield]], add the amount in the "shield" field. Though these amounts are small, note that wearing any shield other than a [[small shield]] also incurs a severe penalty later in the success chance calculation.
*   If wearing [[metallic]] [[armor|body armor]], the amount in the "Suit" field.
+
* If you are wearing [[metallic]] [[armor|body armor]], add the amount in the "Suit" field.
*   If also wearing a [[robe]], only add half the amount (rounded down). {{refsrc|src/spell.c|1601|version=NetHack 3.6.0|comment=[[Robe]] worn over metallic armor halves the spellcasting penalty of the armor.}}
+
** If you are also wearing a [[robe]], only add half the amount (rounded down).{{refsrc|src/spell.c|1601|version=NetHack 3.6.0|comment=[[Robe]] worn over metallic armor halves the spellcasting penalty of the armor.}}
*   If wearing a robe without metallic armor, '''subtract''' the amount in the "Suit" field. {{refsrc|src/spell.c|1603|version=NetHack 3.6.0|comment=Robe worn without metallic body armor increases spellcasting chance.}}
+
** If you are wearing a robe ''without'' metallic armor, then ''subtract'' the amount in the "Suit" field. {{refsrc|src/spell.c|1603|version=NetHack 3.6.0|comment=Robe worn without metallic body armor increases spellcasting chance.}}
*   If wearing a metallic [[helmet]] other than the [[helm of brilliance]], add 4. (Metal helmets interfere with the mind.) {{refsrc|src/spell.c|95|version=NetHack 3.6.0|comment=Metal helmets interfere with the mind.}} {{refsrc|src/spell.c|1608|version=NetHack 3.6.0|comment=[[Helm of brilliance]] imposes no spellcasting penalty.}}
+
* If you are wearing a metallic [[helmet]] other than the [[helm of brilliance]], add 4.{{refsrc|src/spell.c|95|version=NetHack 3.6.0|comment=Metal helmets interfere with the mind.}}{{refsrc|src/spell.c|1608|version=NetHack 3.6.0|comment=[[Helm of brilliance]] imposes no spellcasting penalty.}}
*   Metallic [[gloves]] add 6 (casting channels through the hands). {{refsrc|src/spell.c|96|version=NetHack 3.6.0|comment=Casting channels through the hands.}}
+
* If you are wearing metallic [[gloves]], add 6.{{refsrc|src/spell.c|96|version=NetHack 3.6.0|comment=Casting channels through the hands.}}
*   Metallic [[boots]] add 2 (all metal interferes to some degree). {{refsrc|src/spell.c|97|version=NetHack 3.6.0|comment=All metal interferes to some degree.}}
+
* If you are wearing metallic [[boots]], then add 2.{{refsrc|src/spell.c|97|version=NetHack 3.6.0|comment=All metal interferes to some degree.}}
 
+
* If you are casting the corresponding special spell for your role (also listed in the table), ''subtract'' 4.
*   If casting the corresponding special spell for your role (see table), subtract 4.
 
  
 
{| class="prettytable striped"
 
{| class="prettytable striped"
Line 108: Line 92:
 
| 10
 
| 10
 
| [[Intelligence|Int]]
 
| [[Intelligence|Int]]
| [[Magic mapping]]
+
| {{spell of|Magic mapping}}
 
|-
 
|-
 
| [[Barbarian]]
 
| [[Barbarian]]
Line 116: Line 100:
 
| 8
 
| 8
 
| [[Intelligence|Int]]
 
| [[Intelligence|Int]]
| [[Haste self]]
+
| {{spell of|Haste self}}
 
|-
 
|-
 
| [[Caveman]]
 
| [[Caveman]]
Line 124: Line 108:
 
| 8
 
| 8
 
| [[Intelligence|Int]]
 
| [[Intelligence|Int]]
| [[Dig]]
+
| {{spell of|Dig}}
 
|-
 
|-
 
| [[Healer]]
 
| [[Healer]]
Line 132: Line 116:
 
| 10
 
| 10
 
| [[Wisdom|Wis]]
 
| [[Wisdom|Wis]]
| [[Cure sickness]]
+
| {{spell of|Cure sickness}}
 
|-
 
|-
 
| [[Knight]]
 
| [[Knight]]
Line 140: Line 124:
 
| 9
 
| 9
 
| [[Wisdom|Wis]]
 
| [[Wisdom|Wis]]
| [[Turn undead]]
+
| {{spell of|Turn undead}}
 
|-
 
|-
 
| [[Monk]]
 
| [[Monk]]
Line 148: Line 132:
 
| 20
 
| 20
 
| [[Wisdom|Wis]]
 
| [[Wisdom|Wis]]
| [[Restore ability]]
+
| {{spell of|Restore ability}}
 
|-
 
|-
 
| [[Priest]]
 
| [[Priest]]
Line 156: Line 140:
 
| 10
 
| 10
 
| [[Wisdom|Wis]]
 
| [[Wisdom|Wis]]
| [[Remove curse]]
+
| {{spell of|Remove curse}}
 
|-
 
|-
 
| [[Ranger]]
 
| [[Ranger]]
Line 164: Line 148:
 
| 10
 
| 10
 
| [[Intelligence|Int]]
 
| [[Intelligence|Int]]
| [[Invisibility]]
+
| {{spell of|Invisibility}}
 
|-
 
|-
 
| [[Rogue]]
 
| [[Rogue]]
Line 172: Line 156:
 
| 9
 
| 9
 
| [[Intelligence|Int]]
 
| [[Intelligence|Int]]
| [[Detect treasure]]
+
| {{spell of|Detect treasure}}
 
|-
 
|-
 
| [[Samurai]]
 
| [[Samurai]]
Line 180: Line 164:
 
| 8
 
| 8
 
| [[Intelligence|Int]]
 
| [[Intelligence|Int]]
| [[Clairvoyance]]
+
| {{spell of|Clairvoyance}}
 
|-
 
|-
 
| [[Tourist]]
 
| [[Tourist]]
Line 188: Line 172:
 
| 10
 
| 10
 
| [[Intelligence|Int]]
 
| [[Intelligence|Int]]
| [[Charm monster]]
+
| {{spell of|Charm monster}}
 
|-
 
|-
 
| [[Valkyrie]]
 
| [[Valkyrie]]
Line 196: Line 180:
 
| 9
 
| 9
 
| [[Wisdom|Wis]]
 
| [[Wisdom|Wis]]
| [[Cone of cold]]
+
| {{spell of|Cone of cold}}
 
|-
 
|-
 
| [[Wizard]]
 
| [[Wizard]]
Line 204: Line 188:
 
| 10
 
| 10
 
| [[Intelligence|Int]]
 
| [[Intelligence|Int]]
| [[Spellbook of magic missile|Magic missile]]
+
| {{spell of|Magic missile}}
 
|}
 
|}
  
 +
{{upcoming|NetHack 3.7.0|[[Knight]]s can now cast clerical spells as if they were not wearing metallic body armor, including the bonus for any worn robes.}}
 +
 +
Next, calculate your base chance of success, which is 5.5 times either your intelligence or wisdom depending on your role (see the "Stat" field). The maximum natural human Int/Wis of 18 gives a 99% base success rate. This chance is modified by the following factors:
 +
 +
* SKILL level (Unskilled = 0, Basic = 1, Skilled = 2, Expert = 3)
 +
* spell level (LVL)
 +
* experience level (XL)
  
Next, calculate a base chance of success, which is 5.5 times either your
+
The formula used to modify this chance is:{{refsrc|src/spell.c|1643|version=NetHack 3.6.0|comment=Spellcasting chance formula.}}
intelligence or wisdom, depending on your class (see the "Stat" field). The maximum natural human Int/Wis of 18 gives a 99% base success rate. This chance is
 
modified by the following factors:
 
*  SKILL level (Unskilled = 0, Basic = 1, Skilled = 2, Expert = 3)
 
*  spell level (LVL)
 
*  experience level (XL)
 
according to this formula:{{refsrc|src/spell.c|1643|version=NetHack 3.6.0|comment=Spellcasting chance formula.}}
 
 
:difficulty = (LVL * 4) - (SKILL * 6) - (XL/3) - 5
 
:difficulty = (LVL * 4) - (SKILL * 6) - (XL/3) - 5
  
 
If ''difficulty'' is positive, the spell is considered difficult. Your chance is reduced according to the following formula. A difficulty of 1 therefore gives a 53% penalty, and a difficulty of 9 gives a 100% penalty.
 
If ''difficulty'' is positive, the spell is considered difficult. Your chance is reduced according to the following formula. A difficulty of 1 therefore gives a 53% penalty, and a difficulty of 9 gives a 100% penalty.
 
:<math>\text{chance} = \text{base chance} - \sqrt{(900 \times \text{difficulty}) + 2000}</math>
 
:<math>\text{chance} = \text{base chance} - \sqrt{(900 \times \text{difficulty}) + 2000}</math>
If it is negative, it will be increased with diminishing returns: the
+
If it is negative, it will be increased with diminishing returns: the absolute value is multiplied by (15/LVL), capped at 20, and added to
absolute value is multiplied by (15/LVL), capped at 20, and added to
 
 
the base chance. A level 1 spell therefore achieves the full 20% bonus with a difficulty of -2. A level 7 spell cannot achieve a better difficulty than -5, which gives a bonus of 10%.
 
the base chance. A level 1 spell therefore achieves the full 20% bonus with a difficulty of -2. A level 7 spell cannot achieve a better difficulty than -5, which gives a bonus of 10%.
  
The resulting chance is clipped to the range of 0% to 120% success. If
+
The resulting chance is clipped to the range of 0% to 120% success. If you are wearing a shield larger than a small shield, the chance is then reduced to {{frac|4}} of the amount, or else halved if it is the special spell for your role{{refsrc|src/spell.c|1673|version=NetHack 3.6.0|comment=Big shields significantly impair spellcasting.}} Finally, the chance of success is adjusted by your total penalty using the following formula:
you are wearing a shield larger than a small shield, the chance is then
 
reduced to 1/4 its amount (except if it is the special spell for your
 
class -- then it is only halved).{{refsrc|src/spell.c|1673|version=NetHack 3.6.0|comment=Big shields significantly impair spellcasting.}}
 
 
 
Finally, the chance of success is adjusted by your total penalty using
 
the following formula:
 
 
:<math>\text{actual chance} = \frac{\text{chance} \times (20-\text{penalty})}{15} - \text{penalty}</math>
 
:<math>\text{actual chance} = \frac{\text{chance} \times (20-\text{penalty})}{15} - \text{penalty}</math>
 
The result is clipped to the range of 0% to 100% success.
 
The result is clipped to the range of 0% to 100% success.
  
One nonobvious consequence of this calculation is that sometimes gaining an experience level divisible by 3 can have a very large effect on the success rate of some spells.<ref>http://www.chiark.greenend.org.uk/~damerell/games/spellcliff.txt</ref>
+
One non-obvious consequence of this calculation is that sometimes gaining an experience level divisible by 3 can have a very large effect on the success rate of some spells.<ref>http://www.chiark.greenend.org.uk/~damerell/games/spellcliff.txt</ref>
 
{|class="prettytable"
 
{|class="prettytable"
|'''Spell Level
+
|'''Spell Level'''
 
|'''Skill Level'''
 
|'''Skill Level'''
 
|'''XL for large improvement'''
 
|'''XL for large improvement'''
Line 268: Line 246:
 
|}
 
|}
  
== Effects ==
+
===Minimum spell failure rates===
 +
Because "chance" in the above section is capped at 120%, there is a point where improving your skill, spellcasting stat, or level will not decrease spellcasting failure rates. The only way to decrease failure rates below the listed minimum is to reduce your spellcasting penalty (by putting on a robe or removing penalizing armor). The following table shows the minimum spell failure rates for a given penalty, not including the penalty change of -4 from your special spell:
  
Most spells act similarly to the corresponding wand {{refsrc|src/spell.c|1044|version=NetHack 3.6.0|comment=wand similar}}, scroll{{refsrc|src/spell.c|1096|version=NetHack 3.6.0|comment=scroll similar}}, or potion{{refsrc|src/spell.c|1112|version=NetHack 3.6.0|comment=potion similar}}.
+
{|class="prettytable"
 +
|'''Penalty'''
 +
|'''Min. failure rate'''
 +
|'''...with large shield'''
 +
|'''...with large shield, special spell'''
 +
|-
 +
| ≤-4
 +
| 0
 +
| 60+3*penalty
 +
| 0
 +
|-
 +
| -3
 +
| 0
 +
| 51
 +
| 5
 +
|-
 +
| -2
 +
| 0
 +
| 54
 +
| 10
 +
|-
 +
| -1
 +
| 0
 +
| 57
 +
| 15
 +
|-
 +
| 0
 +
| 0
 +
| 60
 +
| 20
 +
|-
 +
| 1
 +
| 0
 +
| 63
 +
| 25
 +
|-
 +
| 2
 +
| 0
 +
| 66
 +
| 30
 +
|-
 +
| 3
 +
| 0
 +
| 69
 +
| 35
 +
|-
 +
| 4
 +
| 0
 +
| 72
 +
| 40
 +
|-
 +
| 5
 +
| 0
 +
| 75
 +
| 45
 +
|-
 +
| 6
 +
| 0
 +
| 78
 +
| 50
 +
|-
 +
| 7
 +
| 3
 +
| 81
 +
| 55
 +
|-
 +
| 8
 +
| 12
 +
| 84
 +
| 60
 +
|-
 +
| 9
 +
| 21
 +
| 87
 +
| 65
 +
|-
 +
| 10
 +
| 30
 +
| 90
 +
| 70
 +
|-
 +
| 11
 +
| 39
 +
| 93
 +
| 75
 +
|-
 +
| 12
 +
| 48
 +
| 96
 +
| 80
 +
|-
 +
| 13
 +
| 57
 +
| 99
 +
| 85
 +
|-
 +
| 14
 +
| 66
 +
| 100
 +
| 90
 +
|-
 +
| 15
 +
| 75
 +
| 100
 +
| 95
 +
|-
 +
| 16
 +
| 84
 +
| 100
 +
| 100
 +
|-
 +
| 17
 +
| 93
 +
| 100
 +
| 100
 +
|-
 +
| ≥18
 +
| 100
 +
| 100
 +
| 100
 +
|}
  
=== Range ===
+
== Effects ==
 
+
Many spells have a corresponding wand, scroll or potion whose effects are similar or exactly the same.{{refsrc|src/spell.c|1044|version=NetHack 3.6.0|comment=wand similar}}{{refsrc|src/spell.c|1096|version=NetHack 3.6.0|comment=scroll similar}}{{refsrc|src/spell.c|1112|version=NetHack 3.6.0|comment=potion similar}}
[[Beam]] spells: 6–13{{refsrc|src/zap.c|2849|version=NetHack 3.6.0|comment=beam spell range}}
 
 
 
[[Ray]] spells: 7–13{{refsrc|src/zap.c|3846|version=NetHack 3.6.0|comment=ray spell range}}
 
 
 
{{spell of |Dig}}: 8–25{{refsrc|src/dig.c|1442|version=NetHack 3.6.0|comment=dig spell range}}
 
  
=== To Hit ===
+
===Range===
 +
The distance of a [[beam]]-type spell ranges from 6–13 squares.{{refsrc|src/zap.c|2849|version=NetHack 3.6.0|comment=beam spell range}} The distance of the [[ray]] from a spell of {{spell of|dig}} ranges from 8–25 squares;{{refsrc|src/dig.c|1442|version=NetHack 3.6.0|comment=dig spell range}} all other ray-type spells have a range of 7–13 squares.{{refsrc|src/zap.c|3846|version=NetHack 3.6.0|comment=ray spell range}}
  
The chance of hitting versus an armor class (ac) is based on a d20 equivalent (a random number 0-19 is generated).{{refsrc|src/zap.c|3733|version=NetHack 3.6.0|comment=spell to hit calculation}}
+
===To-hit===
 +
For applicable offensive spells, the chance of hitting a target with a given AC is based on a d20 roll, with an additional spell bonus calculated by taking the sum of all penalties and bonuses from your [[dexterity]] and the relevant spell skill (similar to physical combat).{{refsrc|src/zap.c|3733|version=NetHack 3.6.0|comment=spell to hit calculation}}{{refsrc|src/zap.c|2906|version=NetHack 3.6.0|comment=spell hit bonus}}
  
Also a spell bonus is calculated as the sum of the skill penalty/bonus and the dexterity penalty/bonus.{{refsrc|src/zap.c|2906|version=NetHack 3.6.0|comment=spell hit bonus}}  These are the same as used in physical combat.
+
If the chance is 0, success is calculated using this formula, where <math>B</math> is the spell bonus:
  
If the chance is 0, success is d10 < ac + spell bonus
+
<math>d10 < AC + B</math>
  
Otherwise, negative ac is weakened to a random number between -1 and the actual ac{{refsrc|src/hack.c|294|version=NetHack 3.6.0|comment=negative ac weakened}}; success is 3 - chance < ac + spell bonus
+
Otherwise, negative AC is 'weakened' to a random number between -1 and the actual AC, and the success is calculated using this formula, where <math>B</math> is the spell bonus and the chance is represented by <math>X</math>:{{refsrc|src/hack.c|294|version=NetHack 3.6.0|comment=negative ac weakened}}
  
=== Damage ===
+
<math>3 - X < AC + spell bonus</math>
  
A spell damage bonus based on intelligence (INT) and experience level (XL) is used in most attack spell damage calculations.{{reffunc|src/zap.c|spell_damage_bonus|version=NetHack 3.6.0|comment=spell damage bonus}}
+
===Damage===
 +
A spell damage bonus based on intelligence (INT) and [[experience level]] (XL) is used in most attack spell damage calculations:{{reffunc|src/zap.c|spell_damage_bonus|version=NetHack 3.6.0|comment=spell damage bonus}}
  
 
{| class="prettytable"
 
{| class="prettytable"
Line 313: Line 410:
 
|}
 
|}
  
[[Force bolt]]: 2d12 + spell damage bonus{{refsrc|src/zap.c|160|version=NetHack 3.6.0|comment=force bolt damage}}
+
Each spell has its own damage calculations that usually include this bonus in some manner:
 
 
[[Drain life]]:{{refsrc|src/zap.c|371|version=NetHack 3.6.0|comment=drain life damage}}{{reffunc|src/makemon.c|monhp_per_lvl|version=NetHack 3.6.0|comment=drain life damage routine}}
 
* base d8
 
** d4 for level 0 monsters
 
** 4-8 for adult [[dragon]]s
 
** 5-8 for [[named demon]]s (but they're immune)
 
** (base health) / (base level) for [[golem]]s
 
* + spell damage bonus
 
* if monster resists: half damage
 
* otherwise double damage and damage to max [[HP]]
 
  
[[Magic missile]] and [[Cone of cold]] (below skilled){{reffunc|src/zap.c|zhitm|version=NetHack 3.6.0|comment=routine containing mm and cold damage}}
+
* [[Force bolt]]:
* If monster resists: no damage!
+
** 2d12 + spell damage bonus{{refsrc|src/zap.c|160|version=NetHack 3.6.0|comment=force bolt damage}}
* base = XL / 2 + 1
+
* [[Drain life]]:{{refsrc|src/zap.c|371|version=NetHack 3.6.0|comment=drain life damage}}{{reffunc|src/makemon.c|monhp_per_lvl|version=NetHack 3.6.0|comment=drain life damage routine}}
* base d 6
+
** base d8
* Cone of Cold and monster has fire resistance: + base d 3
+
*** d4 for level 0 monsters
* + spell damage bonus
+
*** 4-8 for adult [[dragon]]s
 +
*** 5-8 for [[named demon]]s (though they are normally immune)
 +
*** (base health) / (base level) for [[golem]]s
 +
** Spell damage bonus is added after factoring the above, then damage is halved if the monster resists: otherwise, the spell deals double damage and also inflicts damage to max [[HP]]
 +
* [[Magic missile]]:{{reffunc|src/zap.c|zhitm|version=NetHack 3.6.0|comment=routine containing mm and cold damage}}
 +
** (XL / 2 + 1)d6 + spell damage bonus
 +
** no damage if the monster has [[magic resistance]]
 +
* [[Cone of cold]] (below Skilled):{{reffunc|src/zap.c|zhitm|version=NetHack 3.6.0|comment=routine containing mm and cold damage}}
 +
** (XL / 2 + 1)d6 + spell damage bonus; additional (XL / 2 + 1)d3 if monster has fire resistance
 +
* [[Fireball]] (below skilled){{refsrc|zap.c|4035|nethack=3.6.1}}
 +
** Base 12d6 damage explosion centered at the monster; no spell damage bonus
 +
** modified like Skilled below
 +
* Cone of cold and fireball (skilled or expert){{refsrc|src/spell.c|1010|version=NetHack 3.6.0|comment=skilled cold and fireball}}
 +
** 2 to 9 explosions covering a 3 x 3 space, the first centered on a starting point up to 10 steps away, remaining centered randomly 9 spaces centered on starting point
 +
** base + spell damage on each monster in affected space for each explosion
 +
** Cone of Cold and monster has fire resistance or Fireball and monster has cold resistance: double damage{{refsrc|src/explode.c|400|version=NetHack 3.6.0|comment=skilled cold and fireball resistance adjustments}}
 +
** Monster resists: 1/2 damage
 +
** additional damage for destroyed items{{refsrc|explode.c|445|nethack=3.6.1}}
  
[[Fireball]] (below skilled){{refsrc|zap.c|4035|nethack=3.6.1}}
+
==Strategy==
* one explosion centered at the monster
+
The three primary methods to improve your spellcasting rates are:
* base 12d6 damage
 
* no spell damage bonus
 
* modified like skilled below
 
  
[[Cone of cold]] (skilled or expert), and [[Fireball]] (skilled or expert){{refsrc|src/spell.c|1010|version=NetHack 3.6.0|comment=skilled cold and fireball}}
+
* Increasing the relevant spellcasting attribute.
* 2 to 9 explosions covering a 3 x 3 space, the first centered on a starting point up to 10 steps away, remaining centered randomly 9 spaces centered on starting point
+
* Increase your skill in the desired spell school(s).
* base + spell damage on each monster in affected space for each explosion
+
* Wear armor appropriate to your role's spellcasting abilities.
* Cone of Cold and monster has fire resistance or Fireball and monster has cold resistance: double damage{{refsrc|src/explode.c|400|version=NetHack 3.6.0|comment=skilled cold and fireball resistance adjustments}}
 
* Monster resists: 1/2 damage
 
* additional damage for destroyed items{{refsrc|explode.c|445|nethack=3.6.1}}
 
  
== Strategy ==
+
===Role and attribute strategy===
 +
Your casting attribute, role Base value (per [[#Calculating spell success rate|the above table]]), and metal armor determine your success chance for low-level spells. Experience level and spell school skill can raise your chance for high-level spells up to the chance of low-level spells, but will not make low-level spells more reliable.
  
There are three main ways to improve your spellcasting chances: increase your spellcasting stat, gain more skill and experience levels, and wear armor appropriate to your role's spellcasting abilities.
+
Each point of your spellcasting attribute up to 16 is significant in determining your success chance with "easy" spells. Roles with lower base spellcasting penalties (i.e. "base" values of 5 or lower) may be able to get by with fewer points in that attribute, but tend to start with that attribute at the racial maximum in any case. An intelligence or wisdom score of 17-18 is significant for roles with higher base penalties or low-penalty roles wearing metal armor; score of 19-22 are significant for high-level spells that the 20-point "easy" bonus does not apply to; and scores of 23 or higher are only significant for "difficult" spells, which generally have low success chances regardless.
  
An Intelligence or Wisdom score of 19 or more is needed to reach 100% base success rate, but [[human (starting race)|human]] characters cannot reach these levels without a [[helm of brilliance]].
+
With a base success chance of 120%, your spellcasting penalty (Base modified by armor) must be 6 or less to achieve an overall 100% success chance. Roles that can achieve this without a [[robe]] are [[Archeologist]], [[Healer]], [[Priest]], [[Tourist]], and [[Wizard]]. Roles that can achieve this when casting emergency spells or their special spell are [[Knight]] and [[Monk]]. Roles that can achieve this with their special spell only are [[Ranger]], [[Samurai]], [[Rogue]], and [[Valkyrie]]. The remaining two roles, [[Barbarian]] and [[Caveman]], cannot achieve 100% success chance in any spell without a robe.
  
=== Skill and experience strategy ===
+
===Skill and experience strategy===
 
+
Spells are much easier to cast when their [[#Skills and experience|difficulty]] is zero or less. The following table lists the most difficult spell level that is still considered ''easy'' (i.e. with no penalty for spell level) given a set of particular experience and skill levels.
Spells are much easier to cast when their ''[[#Skills and experience|difficulty]]'' is zero or less. The following table lists the most difficult spell level that is still considered ''easy'' (no penalty for spell level) given particular experience and skill levels.
 
  
 
{| class="prettytable"
 
{| class="prettytable"
Line 379: Line 477:
 
|}
 
|}
  
If your Intelligence or Wisdom is high, spells of this level or below are likely to have a near-100% base success rate. It is still possible to cast non-easy spells, but they tend to have much lower success rates.
+
If your Intelligence or Wisdom is high, spells of this level or below are likely to have a near-100% base success chance. It is still possible to cast non-easy spells, but they tend to have much lower success chances. One exception is a high-level Monk wearing a robe; they get enough of a bonus from it that even difficult spells of up to level 5 can be 100% reliable. With 22 wisdom from a [[helm of brilliance]], level 6 spells can also have a 100% success chance.
 
 
=== Equipment and role strategy ===
 
 
 
If you have raised your experience level, skill, and spellcasting stat high enough to reach a 100% or higher base success rate, your role and equipment will be the limiting factor in achieving low failure rates.
 
  
With a base success rate of 120%, your spellcasting penalty must be 6 or less to achieve an overall 100% success rate. Roles that can achieve this without a [[robe]] are [[archeologist]], [[tourist]], [[healer]], [[priest]], and [[wizard]].  The last three can retain 100% success while also wearing a [[small shield]]. Roles that can achieve this when casting emergency spells or their special spell are [[knight]] and [[monk]]. Roles that can achieve this with their special spell only are [[ranger]], [[samurai]], [[rogue]], and [[valkyrie]]. The remaining two roles, [[barbarian]] and [[caveman]], cannot achieve 100% success without a robe.
+
==History==
 +
Spellcasting is introduced along with spellbooks in [[NetHack 1.3d]]. A spell first had to be learned by transcribing it from the spellbook, which would then disappear from your inventory afterward - if the transcription was successful, you could then use the #cast [[extended command]] to use the spell. Transcribing a spell would always fail and use up the spellbook if you were [[blind]] or [[confused]]. A given spell had a limited number of castings before it expired, and another spellbook is required in order to re-learn the spell. Armor interactions with spellcasting were introduced in [[NetHack 3.2.0]], and the integration of the [[Wizard Patch]] into [[NetHack 3.3.0]] marks the origin of the current spellcasting system.
  
== Variants ==
+
In [[NetHack 3.6.0]] and previous versions, including some variants based on these versions, the Amulet of Yendor would increase the cost of casting a spell, instead of draining energy as you tried to cast it. This meant that it would also increase the nutrition cost, and it would not prevent emergency uses of a spell. In the example above of casting a level 3 spell, if you had only 16 energy left, you could still try again and again, without using any time, until the random penalty is rolled as 1.<ref>https://github.com/NetHack/NetHack/commit/8ff02c11d9979497396d4921bf0d7cf81808c5d1</ref> This was fixed in [[NetHack 3.6.1]].
  
=== SLASH'EM ===
+
==Variants==
 +
Many variants of ''NetHack'' end up making changes to the spellcasting system in some manner.
  
 +
===SLASH'EM===
 
{{main|Spellcasting (SLASH'EM)}}
 
{{main|Spellcasting (SLASH'EM)}}
 +
[[SLASH'EM]] makes several changes to NetHack's spellcasting: New spells have been added, and several existing ones have been reshuffled. SLASH'EM roles also tend to be more proficient in spell skills than their vanilla counterparts.
  
[[SLASH'EM]] makes several changes to NetHack's spellcasting system. New spells have been added, and several existing ones have been reshuffled. SLASH'EM roles tend to be more proficient in spell skills than their vanilla counterparts.
+
===FIQHack===
 
+
[[FIQHack]] has many changes to spellcasting for both players and monsters:
=== FIQHack ===
 
 
 
[[FIQHack]] has many changes to hows spellcasting works.
 
 
 
* Monsters use the same spellcasting system as players, which means that high-level spellcasting monsters have a lot of energy and can cast multiple spells quickly.  Monsters can also pick up and read spellbooks to gain new spells.
 
 
 
* There are new spells, all of which are level 7:
 
** [[Spellbook of charging|charging]] (enchantment), which is equivalent to an uncursed [[scroll of charging]].
 
** [[Spellbook of phase|phase]] (escape), which gives 21-60 (additional) turns of [[phasing]].
 
** [[Spellbook of astral eyesight|astral eyesight]] (divination), gives 11-30 turns of [[astral vision]].
 
** [[Spellbook of summon nasty|summon nasty]] (clerical) which is equivalent to the vanilla monster spell and summons tame monsters if you target a hostile monster.
 
 
 
* Some spells can be [[spell maintenance|maintained]], which slowly drains energy but provides a continuous effect.
 
 
 
* The [[curse items]] monster spell no longer exists but certain curse effects are more common/serious.
 
  
* Bones ghosts can be replaced by equivalent player monsters with the same spells as the late player.
+
* There are four new spells, all of which are level 7:
 
+
** [[Spellbook of charging|Charging]] (enchantment), which is equivalent to an uncursed [[scroll of charging]].
* Identity Spell Changes
+
** [[Spellbook of phase|Phase]] (escape), which gives 21-60 (additional) turns of [[phasing]].
** Unskilled only identifies object type, appearance, and artifacts.
+
** [[Spellbook of astral eyesight|Astral eyesight]] (divination), gives 11-30 turns of [[astral vision]].
** Basic also IDs enchantment, object properties, charge count, tin content and egg type.
+
** [[Spellbook of summon nasty|Summon nasty]] (clerical), which is equivalent to the vanilla monster spell and summons tame monsters if you target a hostile monster.
** Expert identifies fooproof state.
+
* The spell of identify is altered:
 
+
** When cast at unskilled, the spell only identifies object type, appearance, and artifacts.
* Changed spell levels
+
** At Basic, it also IDs enchantment, object properties, charge count, tin content and egg type.
 +
** At Expert, the spell identifies fooproof state.
 +
* Various other spells have their levels changed:
 
** Dig is level 2
 
** Dig is level 2
 
** Identify is level 2
 
** Identify is level 2
Line 425: Line 510:
 
** Polymorph is level 7
 
** Polymorph is level 7
 
** Create familiar is level 2
 
** Create familiar is level 2
 
+
* The [[spell of create monster]] is replaced with the [[spell of summoning]]. Summoned monsters disappear after a set number of turns, based on casting skill.
 
* [[Magic missile]] does less damage if cast at levels lower than expert.
 
* [[Magic missile]] does less damage if cast at levels lower than expert.
 
+
* Spellcasting no longer exercises wisdom; some spells can be [[Spell maintenance|maintained]], which slowly drains energy but provides a continuous effect.
* Instead of a spell failure percentage, the amount of power required to cast a spell changes.
+
* Instead of a spell failure percentage, the amount of power required to cast a spell changes:
 
** Spell cost is (base cost) * 100 / success%. Force bolt costs 5pw at 0% fail, 10pw at 50% fail, 20pw at 75% fail, 500pw at 99% fail, 1000pw at 100% fail (treated as 99.5%)
 
** Spell cost is (base cost) * 100 / success%. Force bolt costs 5pw at 0% fail, 10pw at 50% fail, 20pw at 75% fail, 500pw at 99% fail, 1000pw at 100% fail (treated as 99.5%)
 
** The Amulet doubles spell cost, instead of randomly draining 2-3x energy per spell.
 
** The Amulet doubles spell cost, instead of randomly draining 2-3x energy per spell.
 +
* Monsters use the same spellcasting system as players, which means that high-level spellcasting monsters have a lot of energy and can cast multiple spells quickly. Monsters can also pick up and read spellbooks to gain new spells.
 +
** The [[curse items]] monster spell no longer exists, but certain curse effects are stronger and more common.
 +
** Bones ghosts may be replaced by equivalent player monsters with the same spells as the late player.
  
* Spellcasting does not exercise wisdom.
+
==External links==
 
 
* The spell of [[spellbook of create monster|create monster]] is replaced with the spell of [[spellbook of summoning|summoning]].  Summoned monsters disappear after a set number of turns, based on casting skill.
 
 
 
== History ==
 
 
 
Before [[NetHack 3.6.1]], the Amulet of Yendor would increase the cost of casting a spell, instead of draining energy as you tried to cast it. This meant that it would also increase the nutrition cost, and it would not prevent emergency uses of a spell. In the example above of casting a level 3 spell, if you had only 16 energy left, you could still try again and again, without using any time, until the random penalty is rolled as 1.<ref>https://github.com/NetHack/NetHack/commit/8ff02c11d9979497396d4921bf0d7cf81808c5d1</ref>
 
 
 
== External links ==
 
 
 
 
* [http://nethack.gridbug.de/spells.html NetHack Spell Failure Rate Calculator] (JavaScript)
 
* [http://nethack.gridbug.de/spells.html NetHack Spell Failure Rate Calculator] (JavaScript)
 
** [http://nethack.gridbug.de/SpellFailureRates.html Older version of the above]
 
** [http://nethack.gridbug.de/SpellFailureRates.html Older version of the above]
  
== References ==
+
==References==
<references />
+
<references/>
 +
{{DOD}}
 +
{{nethack-366}}
 
[[Category:Spellcasting]]
 
[[Category:Spellcasting]]
 
[[Category:Commands]]
 
[[Category:Commands]]
{{DOD}}
 
{{nethack-366}}
 

Latest revision as of 01:38, 1 July 2023

Keyboard commands
~ ! @ # $ % ^ & * ( ) _ = +
Q W E R T Y U I O P { } |
q w e r t y u i o p [ ] \
A S D F G H J K L : "
a s d f g h j k l ; '
Z X C V B N M < > ?
z x c v b n m , . /
q w e r t u i o p Alt
a s d f j l Alt
c v n m ? Alt
A C R T O Alt
a c d o p r t [ Ctrl
For monsters' spellcasting mechanics, see monster spells.

In NetHack, spellcasting is the act of casting a spell, done by using the Z command. Casting a spell uses your innate magical power as a source, rather than using an external source of magic such as a scroll or wand.

Healers, Monks, Priests and Wizards begin the game with knowledge of one or more spells, whose corresponding spellbooks appear in their initial inventory; other roles must find at least one spellbook and successfully read it first.

Basics

You must know at least one spell in order to cast; when casting a spell, a menu of known spells and their chance of failure is displayed. You can also view your list of known spells by pressing +, and pressing + again allows you to rearrange the spells so you can place them on more convenient letters.

A spell's chance of failure is affected by your spellcasting attribute (either intelligence or wisdom), experience level, skill level, your role's innate magical affinity, and what armor you are wearing: metal armor in particular can impact chances of success, as well as any worn shield and their material if applicable. Failure rates can be reduced by wearing a robe, and can be additionally reduced further if the spell is an emergency spell or your role's special spell. For details, see the article section on how to calculate spell failure chance.

When you attempt to cast a spell, the game rolls for success or failure against this rate, with a message coming up if you failed to cast the spell; otherwise, the spell immediately takes effect, prompting for a direction if necessary. Training skills in spell schools is done by successfully casting spells in that school, and raises the percentage by an amount equal to the spell's level; the spell itself does not have to directly affect anything.

Casting spells requires a certain amount of energy and nutrition proportionate to the spell's level; failing to cast a spell correctly uses up only a portion of that energy, and the detect food spell does not drain nutrition when cast.[1][2] Wizards have access to hungerless casting that can reduce or even eliminate nutrition costs, based on their intelligence score.

You cannot cast a spell if you lack the required energy, and in certain circumstances your energy or nutrition can be drained enough that an otherwise successful spell will end up failing; see spellcasting costs for further information. There are also other circumstances and requirements that can affect spellcasting:

  • You cannot cast spells if you are stunned.[3]
  • Your strength must be at least 4 to cast a spell, unless you are trying to cast restore ability.
  • You cannot be overtaxed or overloaded in terms of encumbrance.
  • You must also be capable of physically vocalizing the spell to cast it[4]strangulation and polyforms that are headless, only make animal sounds or are otherwise incapable of speaking (e.g., grid bug, jabberwock, mimic, jaguar) will stop you from casting spells.
  • You must also have at least one free hand to direct the energy – this means you cannot cast if there are cursed weapons or shields in both hands.
    • This only applies if you are in a form that has hands; polyforms that lack hands do not prevent you from casting.
  • If confused, you can attempt to cast spells, but they will always fail with the same effects as random spell failure.

While using teleport at will is also considered to be a cast of a spell, and follows many of the same rules as casting teleport away, there are a few notable differences - teleport at will ignores failure rates, for instance.

Spellcasting costs

Each spell costs an amount of energy equal to 5 times the spell's level in order to cast;[5] if you are carrying the Amulet of Yendor, it drains an amount of energy between 1 point and 2 times the usual cost as you attempt to cast.[6]. If you do not have the required energy to cast the spell, nothing happens; if the Amulet drains enough energy to prevent the spell being cast, this uses up a move.[7] If you have the energy for a spell and fail to cast it correctly, only half of that spell's energy cost (rounded down) is used up.

In addition, casting any spell other than detect food uses an amount of nutrition equal to two times the energy cost; this is usually 10 times the spell's level, before factoring in reduced-hunger casting for Wizards (hungerless casting ignores this entirely). A failed cast of a spell costs as much as a successful one, and carrying the Amulet has no impact on nutrition costs. Being weak and very close to fainting from hunger can prevent you from properly casting any spell other than detect food; fainting will outright prevent casting of those other spells, regardless of whether or not you have hungerless casting.

As an example, casting a level 3 spell normally requires 15 energy and 30 nutrition; if you fail to cast it, only 7 energy is used. When carrying the Amulet of Yendor, there is an energy penalty of 1 to 30 points, so the total energy cost varies from 16 to 45. The nutrition cost will always be 30 regardless of the circumstance.

Forgotten spells

Spell knowledge lasts for 20,000 turns after learning the spell from a spellbook; a spell is forgotten once this duration expires, and forgotten spells are marked with an asterisk * in the casting menu. Re-reading a spellbook for a spell with a timeout at or below 1,000 turns will refresh knowledge of that spell and reset the timeout to 20,000 turns;[8] attempting to read a spellbook before the timeout is low enough will not use up a reading of the spellbook (meaning it will not result in a usage fee with unpaid spellbooks in a shop).[9]

Attempting to cast a forgotten spell will leave you confused and/or stunned, with the duration dependent on the level of the forgotten spell; this does not consume any nutrition or power. The exact effects of casting a forgotten spell are as follows:[10]

Probability Effect
40%
  • confused for (spell-level + 1) * 3 turns
30%
  • confused for (spell-level + 1) * 2 turns
  • stunned for (spell-level + 1) turns
20%
  • confused for (spell-level + 1) turns
  • stunned for (spell-level + 1) * 2 turns
10%
  • stunned for (spell-level + 1) * 3 turns

Forgotten spells are a common way to deliberately become confused and invoke the alternative effects of certain scrolls.

Calculating spell success rate

The spell failure rate given in the spellcasting menu is calculated using the listed algorithm below, and the values in the table below this list, with higher numbers signifying harsher penalties (limited to a maximum of 20):

  • Start with the "base" value associated with your role.
  • Each role also has an "Emergency" modifier for emergency spells - specifically, remove curse and all healing spells except for stone to flesh - that is applied when casting such a spell.[11]
  • If you are wearing any shield, add the amount in the "shield" field. Though these amounts are small, note that wearing any shield other than a small shield also incurs a severe penalty later in the success chance calculation.
  • If you are wearing metallic body armor, add the amount in the "Suit" field.
    • If you are also wearing a robe, only add half the amount (rounded down).[12]
    • If you are wearing a robe without metallic armor, then subtract the amount in the "Suit" field. [13]
  • If you are wearing a metallic helmet other than the helm of brilliance, add 4.[14][15]
  • If you are wearing metallic gloves, add 6.[16]
  • If you are wearing metallic boots, then add 2.[17]
  • If you are casting the corresponding special spell for your role (also listed in the table), subtract 4.
Class Base Emergency Shield Suit Stat Special spell
Archeologist 5 0 2 10 Int Magic mapping
Barbarian 14 0 0 8 Int Haste self
Caveman 12 0 1 8 Int Dig
Healer 3 -3 2 10 Wis Cure sickness
Knight 8 -2 0 9 Wis Turn undead
Monk 8 -2 2 20 Wis Restore ability
Priest 3 -2 2 10 Wis Remove curse
Ranger 9 2 1 10 Int Invisibility
Rogue 8 0 1 9 Int Detect treasure
Samurai 10 0 0 8 Int Clairvoyance
Tourist 5 1 2 10 Int Charm monster
Valkyrie 10 -2 0 9 Wis Cone of cold
Wizard 1 0 3 10 Int Magic missile

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.

Knights can now cast clerical spells as if they were not wearing metallic body armor, including the bonus for any worn robes.

Next, calculate your base chance of success, which is 5.5 times either your intelligence or wisdom depending on your role (see the "Stat" field). The maximum natural human Int/Wis of 18 gives a 99% base success rate. This chance is modified by the following factors:

  • SKILL level (Unskilled = 0, Basic = 1, Skilled = 2, Expert = 3)
  • spell level (LVL)
  • experience level (XL)

The formula used to modify this chance is:[18]

difficulty = (LVL * 4) - (SKILL * 6) - (XL/3) - 5

If difficulty is positive, the spell is considered difficult. Your chance is reduced according to the following formula. A difficulty of 1 therefore gives a 53% penalty, and a difficulty of 9 gives a 100% penalty.

\text{chance} = \text{base chance} - \sqrt{(900 \times \text{difficulty}) + 2000}

If it is negative, it will be increased with diminishing returns: the absolute value is multiplied by (15/LVL), capped at 20, and added to the base chance. A level 1 spell therefore achieves the full 20% bonus with a difficulty of -2. A level 7 spell cannot achieve a better difficulty than -5, which gives a bonus of 10%.

The resulting chance is clipped to the range of 0% to 120% success. If you are wearing a shield larger than a small shield, the chance is then reduced to 14 of the amount, or else halved if it is the special spell for your role[19] Finally, the chance of success is adjusted by your total penalty using the following formula:

\text{actual chance} = \frac{\text{chance} \times (20-\text{penalty})}{15} - \text{penalty}

The result is clipped to the range of 0% to 100% success.

One non-obvious consequence of this calculation is that sometimes gaining an experience level divisible by 3 can have a very large effect on the success rate of some spells.[20]

Spell Level Skill Level XL for large improvement
2 unskilled 9
3 unskilled 21
4 basic 15
5 basic 27
5 skilled 9
6 skilled 21
7 expert 15

Minimum spell failure rates

Because "chance" in the above section is capped at 120%, there is a point where improving your skill, spellcasting stat, or level will not decrease spellcasting failure rates. The only way to decrease failure rates below the listed minimum is to reduce your spellcasting penalty (by putting on a robe or removing penalizing armor). The following table shows the minimum spell failure rates for a given penalty, not including the penalty change of -4 from your special spell:

Penalty Min. failure rate ...with large shield ...with large shield, special spell
≤-4 0 60+3*penalty 0
-3 0 51 5
-2 0 54 10
-1 0 57 15
0 0 60 20
1 0 63 25
2 0 66 30
3 0 69 35
4 0 72 40
5 0 75 45
6 0 78 50
7 3 81 55
8 12 84 60
9 21 87 65
10 30 90 70
11 39 93 75
12 48 96 80
13 57 99 85
14 66 100 90
15 75 100 95
16 84 100 100
17 93 100 100
≥18 100 100 100

Effects

Many spells have a corresponding wand, scroll or potion whose effects are similar or exactly the same.[21][22][23]

Range

The distance of a beam-type spell ranges from 6–13 squares.[24] The distance of the ray from a spell of dig ranges from 8–25 squares;[25] all other ray-type spells have a range of 7–13 squares.[26]

To-hit

For applicable offensive spells, the chance of hitting a target with a given AC is based on a d20 roll, with an additional spell bonus calculated by taking the sum of all penalties and bonuses from your dexterity and the relevant spell skill (similar to physical combat).[27][28]

If the chance is 0, success is calculated using this formula, where B is the spell bonus:

d10 < AC + B

Otherwise, negative AC is 'weakened' to a random number between -1 and the actual AC, and the success is calculated using this formula, where B is the spell bonus and the chance is represented by X:[29]

3 - X < AC + spell bonus

Damage

A spell damage bonus based on intelligence (INT) and experience level (XL) is used in most attack spell damage calculations:[30]

Criteria Bonus
INT <= 9 -3
INT <= 13 OR XL < 5 0
INT <= 18 +1
INT <= 24 OR XL < 14 +2
INT = 25 +3

Each spell has its own damage calculations that usually include this bonus in some manner:

  • Force bolt:
    • 2d12 + spell damage bonus[31]
  • Drain life:[32][33]
    • base d8
      • d4 for level 0 monsters
      • 4-8 for adult dragons
      • 5-8 for named demons (though they are normally immune)
      • (base health) / (base level) for golems
    • Spell damage bonus is added after factoring the above, then damage is halved if the monster resists: otherwise, the spell deals double damage and also inflicts damage to max HP
  • Magic missile:[34]
    • (XL / 2 + 1)d6 + spell damage bonus
    • no damage if the monster has magic resistance
  • Cone of cold (below Skilled):[35]
    • (XL / 2 + 1)d6 + spell damage bonus; additional (XL / 2 + 1)d3 if monster has fire resistance
  • Fireball (below skilled)[36]
    • Base 12d6 damage explosion centered at the monster; no spell damage bonus
    • modified like Skilled below
  • Cone of cold and fireball (skilled or expert)[37]
    • 2 to 9 explosions covering a 3 x 3 space, the first centered on a starting point up to 10 steps away, remaining centered randomly 9 spaces centered on starting point
    • base + spell damage on each monster in affected space for each explosion
    • Cone of Cold and monster has fire resistance or Fireball and monster has cold resistance: double damage[38]
    • Monster resists: 1/2 damage
    • additional damage for destroyed items[39]

Strategy

The three primary methods to improve your spellcasting rates are:

  • Increasing the relevant spellcasting attribute.
  • Increase your skill in the desired spell school(s).
  • Wear armor appropriate to your role's spellcasting abilities.

Role and attribute strategy

Your casting attribute, role Base value (per the above table), and metal armor determine your success chance for low-level spells. Experience level and spell school skill can raise your chance for high-level spells up to the chance of low-level spells, but will not make low-level spells more reliable.

Each point of your spellcasting attribute up to 16 is significant in determining your success chance with "easy" spells. Roles with lower base spellcasting penalties (i.e. "base" values of 5 or lower) may be able to get by with fewer points in that attribute, but tend to start with that attribute at the racial maximum in any case. An intelligence or wisdom score of 17-18 is significant for roles with higher base penalties or low-penalty roles wearing metal armor; score of 19-22 are significant for high-level spells that the 20-point "easy" bonus does not apply to; and scores of 23 or higher are only significant for "difficult" spells, which generally have low success chances regardless.

With a base success chance of 120%, your spellcasting penalty (Base modified by armor) must be 6 or less to achieve an overall 100% success chance. Roles that can achieve this without a robe are Archeologist, Healer, Priest, Tourist, and Wizard. Roles that can achieve this when casting emergency spells or their special spell are Knight and Monk. Roles that can achieve this with their special spell only are Ranger, Samurai, Rogue, and Valkyrie. The remaining two roles, Barbarian and Caveman, cannot achieve 100% success chance in any spell without a robe.

Skill and experience strategy

Spells are much easier to cast when their difficulty is zero or less. The following table lists the most difficult spell level that is still considered easy (i.e. with no penalty for spell level) given a set of particular experience and skill levels.

Highest easy spell level
Xlvl Unskilled Basic Skilled Expert
1–2 1 2 4 5
3–8 1 3 4 6
9–14 2 3 5 6
15–20 2 4 5 7
21–26 3 4 6 7
27–30 3 5 6 7

If your Intelligence or Wisdom is high, spells of this level or below are likely to have a near-100% base success chance. It is still possible to cast non-easy spells, but they tend to have much lower success chances. One exception is a high-level Monk wearing a robe; they get enough of a bonus from it that even difficult spells of up to level 5 can be 100% reliable. With 22 wisdom from a helm of brilliance, level 6 spells can also have a 100% success chance.

History

Spellcasting is introduced along with spellbooks in NetHack 1.3d. A spell first had to be learned by transcribing it from the spellbook, which would then disappear from your inventory afterward - if the transcription was successful, you could then use the #cast extended command to use the spell. Transcribing a spell would always fail and use up the spellbook if you were blind or confused. A given spell had a limited number of castings before it expired, and another spellbook is required in order to re-learn the spell. Armor interactions with spellcasting were introduced in NetHack 3.2.0, and the integration of the Wizard Patch into NetHack 3.3.0 marks the origin of the current spellcasting system.

In NetHack 3.6.0 and previous versions, including some variants based on these versions, the Amulet of Yendor would increase the cost of casting a spell, instead of draining energy as you tried to cast it. This meant that it would also increase the nutrition cost, and it would not prevent emergency uses of a spell. In the example above of casting a level 3 spell, if you had only 16 energy left, you could still try again and again, without using any time, until the random penalty is rolled as 1.[40] This was fixed in NetHack 3.6.1.

Variants

Many variants of NetHack end up making changes to the spellcasting system in some manner.

SLASH'EM

SLASH'EM makes several changes to NetHack's spellcasting: New spells have been added, and several existing ones have been reshuffled. SLASH'EM roles also tend to be more proficient in spell skills than their vanilla counterparts.

FIQHack

FIQHack has many changes to spellcasting for both players and monsters:

  • There are four new spells, all of which are level 7:
  • The spell of identify is altered:
    • When cast at unskilled, the spell only identifies object type, appearance, and artifacts.
    • At Basic, it also IDs enchantment, object properties, charge count, tin content and egg type.
    • At Expert, the spell identifies fooproof state.
  • Various other spells have their levels changed:
    • Dig is level 2
    • Identify is level 2
    • Cancellation is level 5
    • Teleport away is level 5
    • Polymorph is level 7
    • Create familiar is level 2
  • The spell of create monster is replaced with the spell of summoning. Summoned monsters disappear after a set number of turns, based on casting skill.
  • Magic missile does less damage if cast at levels lower than expert.
  • Spellcasting no longer exercises wisdom; some spells can be maintained, which slowly drains energy but provides a continuous effect.
  • Instead of a spell failure percentage, the amount of power required to cast a spell changes:
    • Spell cost is (base cost) * 100 / success%. Force bolt costs 5pw at 0% fail, 10pw at 50% fail, 20pw at 75% fail, 500pw at 99% fail, 1000pw at 100% fail (treated as 99.5%)
    • The Amulet doubles spell cost, instead of randomly draining 2-3x energy per spell.
  • Monsters use the same spellcasting system as players, which means that high-level spellcasting monsters have a lot of energy and can cast multiple spells quickly. Monsters can also pick up and read spellbooks to gain new spells.
    • The curse items monster spell no longer exists, but certain curse effects are stronger and more common.
    • Bones ghosts may be replaced by equivalent player monsters with the same spells as the late player.

External links

References

  1. src/spell.c in NetHack 3.6.0, line 982: Failing to correctly cast a spell wastes only half of casting cost.
  2. src/spell.c in NetHack 3.6.0, line 929: Detect food has no casting hunger cost.
  3. src/spell.c in NetHack 3.6.6, line 644
  4. src/spell.c in NetHack 3.6.6, line 644
  5. src/spell.c in NetHack 3.6.0, line 908: Spell cost.
  6. src/spell.c in NetHack 3.6.1, line 952: Amulet of Yendor's penalty on spell cost.
  7. src/spell.c in NetHack 3.6.1, line 956: Attempting to cast a remembered spell without enough energy uses a move if Amulet drain occurred.
  8. src/spell.c in NetHack 3.6.0, line 379: Refreshing or learning a spell.
  9. src/spell.c in NetHack 3.6.0, line 376: Reading book of keenly known spell.
  10. spell_backfire in src/spell.c in NetHack 3.6.0: Casting a forgotten spell.
  11. src/spell.c in NetHack 3.6.0, line 1618: List of emergency spells.
  12. src/spell.c in NetHack 3.6.0, line 1601: Robe worn over metallic armor halves the spellcasting penalty of the armor.
  13. src/spell.c in NetHack 3.6.0, line 1603: Robe worn without metallic body armor increases spellcasting chance.
  14. src/spell.c in NetHack 3.6.0, line 95: Metal helmets interfere with the mind.
  15. src/spell.c in NetHack 3.6.0, line 1608: Helm of brilliance imposes no spellcasting penalty.
  16. src/spell.c in NetHack 3.6.0, line 96: Casting channels through the hands.
  17. src/spell.c in NetHack 3.6.0, line 97: All metal interferes to some degree.
  18. src/spell.c in NetHack 3.6.0, line 1643: Spellcasting chance formula.
  19. src/spell.c in NetHack 3.6.0, line 1673: Big shields significantly impair spellcasting.
  20. http://www.chiark.greenend.org.uk/~damerell/games/spellcliff.txt
  21. src/spell.c in NetHack 3.6.0, line 1044: wand similar
  22. src/spell.c in NetHack 3.6.0, line 1096: scroll similar
  23. src/spell.c in NetHack 3.6.0, line 1112: potion similar
  24. src/zap.c in NetHack 3.6.0, line 2849: beam spell range
  25. src/dig.c in NetHack 3.6.0, line 1442: dig spell range
  26. src/zap.c in NetHack 3.6.0, line 3846: ray spell range
  27. src/zap.c in NetHack 3.6.0, line 3733: spell to hit calculation
  28. src/zap.c in NetHack 3.6.0, line 2906: spell hit bonus
  29. src/hack.c in NetHack 3.6.0, line 294: negative ac weakened
  30. spell_damage_bonus in src/zap.c in NetHack 3.6.0: spell damage bonus
  31. src/zap.c in NetHack 3.6.0, line 160: force bolt damage
  32. src/zap.c in NetHack 3.6.0, line 371: drain life damage
  33. monhp_per_lvl in src/makemon.c in NetHack 3.6.0: drain life damage routine
  34. zhitm in src/zap.c in NetHack 3.6.0: routine containing mm and cold damage
  35. zhitm in src/zap.c in NetHack 3.6.0: routine containing mm and cold damage
  36. zap.c in NetHack 3.6.1, line 4035
  37. src/spell.c in NetHack 3.6.0, line 1010: skilled cold and fireball
  38. src/explode.c in NetHack 3.6.0, line 400: skilled cold and fireball resistance adjustments
  39. explode.c in NetHack 3.6.1, line 445
  40. https://github.com/NetHack/NetHack/commit/8ff02c11d9979497396d4921bf0d7cf81808c5d1

This page is based on a spoiler by Dylan O'Donnell. The original license is:

Redistribution, copying, and editing of these spoilers, with or without modification, are permitted provided that the following conditions are met:

  1. The original contributors to any spoiler must continue to be credited.
  2. Any modifications to the spoiler must be acknowledged and credited.