MCPcopy Create free account
hub / github.com/NetHack/NetHack / priestini

Function priestini

src/priest.c:219–276  ·  view source on GitHub ↗

exclusively for mktemple() */

Source from the content-addressed store, hash-verified

217
218/* exclusively for mktemple() */
219void
220priestini(
221 d_level *lvl,
222 struct mkroom *sroom,
223 int sx, int sy,
224 boolean sanctum) /* is it the seat of the high priest? */
225{
226 struct monst *priest;
227 struct obj *otmp;
228 int cnt;
229 int px = 0, py = 0, i, si = rn2(N_DIRS);
230 struct permonst *prim = &mons[sanctum ? PM_HIGH_CLERIC
231 : PM_ALIGNED_CLERIC];
232
233 for (i = 0; i < N_DIRS; i++) {
234 px = sx + xdir[DIR_CLAMP(i+si)];
235 py = sy + ydir[DIR_CLAMP(i+si)];
236 if (pm_good_location(px, py, prim))
237 break;
238 }
239 if (i == N_DIRS)
240 px = sx, py = sy;
241
242 if (MON_AT(px, py))
243 (void) rloc(m_at(px, py), RLOC_NOMSG); /* insurance */
244
245 priest = makemon(prim, px, py, MM_EPRI);
246 if (priest) {
247 EPRI(priest)->shroom = (schar) ((sroom - svr.rooms) + ROOMOFFSET);
248 EPRI(priest)->shralign = Amask2align(levl[sx][sy].altarmask);
249 EPRI(priest)->shrpos.x = sx;
250 EPRI(priest)->shrpos.y = sy;
251 assign_level(&(EPRI(priest)->shrlevel), lvl);
252 mon_learns_traps(priest, ALL_TRAPS); /* traps are known */
253 priest->mpeaceful = 1;
254 priest->ispriest = 1;
255 priest->isminion = 0;
256 priest->msleeping = 0;
257 set_malign(priest); /* mpeaceful may have changed */
258
259 /* now his/her goodies... */
260 if (sanctum && EPRI(priest)->shralign == A_NONE
261 && on_level(&sanctum_level, &u.uz)) {
262 (void) mongets(priest, AMULET_OF_YENDOR);
263 }
264 /* 2 to 4 spellbooks */
265 for (cnt = rn1(3, 2); cnt > 0; --cnt) {
266 (void) mpickobj(priest, mkobj(SPBOOK_no_NOVEL, FALSE));
267 }
268 /* robe [via makemon()] */
269 if (rn2(2) && (otmp = which_armor(priest, W_ARMC)) != 0) {
270 if (p_coaligned(priest))
271 uncurse(otmp);
272 else
273 curse(otmp);
274 }
275 }
276}

Callers 2

mktempleFunction · 0.85
create_altarFunction · 0.85

Calls 15

rn2Function · 0.85
pm_good_locationFunction · 0.85
rlocFunction · 0.85
makemonFunction · 0.85
assign_levelFunction · 0.85
mon_learns_trapsFunction · 0.85
set_malignFunction · 0.85
on_levelFunction · 0.85
mongetsFunction · 0.85
mpickobjFunction · 0.85
mkobjFunction · 0.85
which_armorFunction · 0.85

Tested by

no test coverage detected