# Temple
An altar with a priest tending it is a temple. If the priest and altar are co-aligned with you and your alignment record is good enough, the temple is a sanctuary. If a temple's resident priest dies or is otherwise removed from the room, the temple becomes desecrated; every time you enter a desecrated temple, there is 1/5 chance of "an enormous ghost" appearing next to you, paralyzing you for three turns, and then acting as an ordinary ghost.[1] A desecrated temple cannot be restored; in all desecrated temples that are generated normally (i.e. not in a bones file) the altar will be unaligned if present.

Contents

1 Generation
2 Special levels with temples
3 Messages
4 Strategy
5 History
6 References

Generation
One temple is created with probability 1/5 from level 9 on in an ordinary rooms-and-corridors level in the main dungeon, provided it does not already have a shop, a throne room, a leprechaun hall or a zoo.[2] There is an 80% chance the temple is the same alignment as its hosting dungeon branch, the rest of the time it has 1/3 chance of each alignment.[3][4]

Special levels with temples
Minetown is guaranteed to have a temple
This level may leave bones, meaning a file can occur where the altar, the priest or both may not exist
Orcish Town has a desecrated temple.
The Valley of the Dead contains a temple of Moloch with an unaligned altar
Moloch's Sanctum has a temple housing the high priest of Moloch
The Knight quest locate level has a neutral temple
The Healer quest locate level has a chaotic temple
The Caveman quest home level has a temple that is always co-aligned
The Wizard quest goal level has a desecrated temple that is always cross-aligned
The Monk quest home level contains a desecrated temple
The Priest quest
The home level has a desecrated temple
There is a temple to Moloch on the locate level
The Tourist quest locate level has a desecrated temple that does not contain an altar at all
The room with the unaligned altar in Orcus Town is not considered a temple.

Messages
You hear a strident plea for donations.You hear someone praising 

<deity>.You hear someone beseeching <deity>.
A priest who can speak is present whose alignment matches that of the altar.[5]
You hear an an animal carcass being offered in sacrifice.
A priest who can speak is present whose alignment matches that of the altar, but you cannot see the priest or altar.[6]
You have a forbidding feeling...
You are entering a desecrated or cross-aligned temple.
You have a strange forbidding feeling.
You are entering a temple and have an alignment record of -4 or lower.
You experience a sense of peace.
You are entering a coaligned temple and have an alignment record of 20 or higher.
You experience an unusual sense of peace.
You are entering a temple and have an alignment record below 20.
You have an eerie feeling...You feel like you are being watched.A shiver runs down your <spine>.
You are entering a temple without a priest.[7]
Strategy
You can chat to a priest and donate gold to get protection, which improves your AC.
It is possible to change the alignment of an altar in a temple by sacrificing a monster, especially the right type of unicorn, but doing so will anger the priest.
After using the altar to BUC test rings and scrolls, it's a good idea to leave the temple before using them. Otherwise you risk causing the priest to attack you with a ring of conflict or angering them with a scroll of fire.
Do not test a drum that might be a drum of earthquake anywhere on the level. If the altar is within line of sight, it may be destroyed, and the priest be made hostile. Even if the altar is not within line of sight, the priest may still be made hostile by a chasm opening underneath him.
If there is a gas spore in the room, lure it out of the temple before killing it. If you kill it while in the temple and the priest is caught in the explosion, the priest will get angry.

History
The messages involving priests pleading, praising, beseeching or sacrificing were not always limited to priests who matched the alignment of the altar. That limitation was added in NetHack 3.6.0. 

References

↑ src/priest.c in NetHack 3.6.6, line 502

↑ src/mklev.c in NetHack 3.6.6, line 776

↑ src/mkroom.c in NetHack 3.6.6, line 590

↑ src/dungeon.c in NetHack 3.6.6, line 1560

↑ src/sounds.c in NetHack 3.6.6, line 241: Temple sounds

↑ src/sounds.c in NetHack 3.6.6, line 241: Temple sounds

↑ src/priest.c in NetHack 3.6.6, line 482

</spine></deity></deity>