Prayer

Prayer, invoked with the #pray extended command, is an action used to communicate with the player's god. The purpose of praying is to ask for help from your god, and as such, it must not be done too often. The player has a prayer timeout, a counter which is raised when praying, and decrements one turn at a time. Only when this counter reaches zero may the player pray safely again (exceptions exist, see below). Thus prayer is usually reserved for one of a few things: saving the player from almost certain doom, performing some action the player cannot yet do (removing cursed items, getting out of walls, etc.), or creating holy water. For those players who like a challenge, avoiding any interaction with gods, altars and other religious concepts in the game will satisfy the atheist conduct.

When not to pray
Because prayer is usually used in dire situations, it is important to know when prayer will not save you. In fact, praying at the wrong time can hurt you, as your god may become angry enough to strike you with lightning or enact some other punishment. The following conditions make it unsafe to pray:
 * You are polymorphed into a demon and are attempting to pray to a non-chaotic god.
 * You are polymorphed into an undead creature and are attempting to pray to a non-chaotic god. (Neutrals have a 10% chance of being able to pray anyway.)
 * Your alignment record is negative.
 * Your luck is negative.
 * Your god is still angry at you from an earlier event.
 * Your prayer timeout is not yet zero. (If you are currently suffering from a major problem, it is safe to pray with a timeout as high as 200; if a minor problem, it may be as high as 100.)
 * You are in Gehennom.
 * You are standing on another god's altar.

When to pray for help
Not all afflictions are equally severe. Gods make a distinction between two groups of problems: minor problems and major problems. Most players do not bother to pray for relief from minor problems, but it is often the solution to a major problem.

Major problems:
 * Turning to stone (thanks to a cockatrice or chickatrice)
 * Sliming from a green slime
 * Wearing an amulet of strangulation
 * Standing in lava
 * Fatal illness (food poisoning or sickness attack a la Juiblex and Pestilence)
 * Hunger status "Weak" or worse
 * HP less than or equal to 1/7 of the maximum, or less than 6
 * Lycanthropy
 * Being overtaxed or worse as a result of strength drain (based on your base strength, not counting armor modifiers)
 * Being stuck in a wall without means of escape
 * Wearing a cursed blindfold
 * Wearing a cursed ring or boots of levitation
 * Not having use of ones hands

Minor problems:
 * Punishment
 * Wearing one or more cursed items (other than a ring or boots of levitation or a blindfold)
 * Blindness
 * Poison
 * Having wounded legs (from kicking a wall or heavy object for example)
 * Being "Hungry" but not worse
 * Stunning
 * Confusion
 * Hallucination
 * When your pet is turned to stone

Note that if your maximum HP is less than or equal to 5 * (level + 2) and you are praying as a result of low HP, you will also receive 1d5 extra points to your maximum, and then be healed to that new maximum.

Other times to pray
The other useful purpose of prayer (besides praying for help) is to make holy or unholy water. Praying while standing on an altar on which potions of water were dropped will create (assuming the prayer is successful) these. Which one you get is dependent on your own alignment and that of the altar you are praying on. If you are standing on a coaligned altar, the water will become blessed (holy), and you will also receive the benefit of the prayer. If you are standing on another god's altar, the water will become cursed (unholy). Note that praying while standing on another god's altar will anger your god, so this should be done with extreme caution.

Alignment clues
After a prayer is completed, you will receive a message giving you a hint as to your current alignment, in the form of "You feel that is ".

How god decides what to grant

 * This section has been updated for NetHack 3.4.3.

The following table shows how your god decides what you are worthy of receiving during a prayer. This assumes that it is safe to pray.
 * If your alignment is at least 14, and you have no major or minor problems, you are granted a favor. See "Favors and gifts", below.
 * If your alignment is less than 4, but still positive, the result is always 1.
 * If your alignment is 0, there is a chance based on Luck that the result will be 1, otherwise it is 0.
 * If none of the above apply, your base roll is a number between 1 and Luck + x inclusive, where x is:
 * 4 if you are on an altar in a temple with a priest,
 * 3 if you are on an altar not in a temple (or the priest is missing), or
 * 2 if you are not on an altar.
 * If you are not on an altar, the result is capped at 3.

Favors and gifts
If your god decides, as per the previous explanation, to grant you a favor or wish, the following table is used. The lookup number is generated by 1d(luck + 6), divided by 2, rounded up.

Unsuccessful prayers
Unsuccessful prayers can happen for a variety of reasons, documented above. The following table indicates the result of praying during one of these situations.

Possible negative effects of praying
The negative effect that an unsuccessful prayer might incur depends on four things:
 * Your god's anger
 * Whether you were praying to your own god or a different god
 * Your luck
 * Your alignment

The following algorithm and lookup table shows how the negative effect is chosen.
 * 1) Base value
 * 2) If you are praying to your own god, start with three times your god's anger.
 * 3) If you are praying to a different god, start with half your alignment (likely to be greater than three times your god's anger, so praying to a different god is usually worse).
 * 4) Luck modifier
 * 5) If your luck is positive or your alignment is at least 4, subtract one third of your luck from the base value.
 * 6) Otherwise, add the absolute value of your luck to the base value (so the more negative your luck is, the more the punishment is going to hurt).
 * 7) Rolling
 * 8) If the value is greater than 15, it is capped at 15.
 * 9) Roll 1d(your value) and use the following lookup table.

You will lose any protection you may have in addition to the following possible effects.