MCPcopy Index your code
hub / github.com/NetHack/NetHack / fixuporacle

Function fixuporacle

src/bones.c:307–352  ·  view source on GitHub ↗

possibly restore oracle's room and/or put her back inside it; returns False if she's on the wrong level and should be removed, True otherwise */

Source from the content-addressed store, hash-verified

305/* possibly restore oracle's room and/or put her back inside it; returns
306 False if she's on the wrong level and should be removed, True otherwise */
307staticfn boolean
308fixuporacle(struct monst *oracle)
309{
310 coord cc;
311 int ridx, o_ridx;
312
313 /* oracle doesn't move, but knight's joust or monk's staggering blow
314 could push her onto a hole in the floor; at present, traps don't
315 activate in such situation hence she won't fall to another level;
316 however, that could change so be prepared to cope with such things */
317 if (!Is_oracle_level(&u.uz))
318 return FALSE;
319
320 oracle->mpeaceful = 1; /* for behavior toward next character */
321 o_ridx = levl[oracle->mx][oracle->my].roomno - ROOMOFFSET;
322 if (o_ridx >= 0 && svr.rooms[o_ridx].rtype == DELPHI)
323 return TRUE; /* no fixup needed */
324
325 /*
326 * The Oracle isn't in DELPHI room. Either hero entered her chamber
327 * and got the one-time welcome message, converting it into an
328 * ordinary room, or she got teleported out, or both. Try to put
329 * her back inside her room, if necessary, and restore its type.
330 */
331
332 /* find original delphi chamber; should always succeed */
333 for (ridx = 0; ridx < SIZE(svr.rooms); ++ridx)
334 if (svr.rooms[ridx].orig_rtype == DELPHI)
335 break;
336
337 if (o_ridx != ridx && ridx < SIZE(svr.rooms)) {
338 /* room found and she's not in it, so try to move her there */
339 cc.x = (svr.rooms[ridx].lx + svr.rooms[ridx].hx) / 2;
340 cc.y = (svr.rooms[ridx].ly + svr.rooms[ridx].hy) / 2;
341 if (enexto(&cc, cc.x, cc.y, oracle->data)) {
342 rloc_to(oracle, cc.x, cc.y);
343 o_ridx = levl[oracle->mx][oracle->my].roomno - ROOMOFFSET;
344 }
345 /* [if her room is already full, she might end up outside;
346 that's ok, next hero just won't get any welcome message,
347 same as used to happen before this fixup was introduced] */
348 }
349 if (ridx == o_ridx) /* if she's in her room, mark it as such */
350 svr.rooms[ridx].rtype = DELPHI;
351 return TRUE; /* keep oracle in new bones file */
352}
353
354/* check whether bones are feasible */
355boolean

Callers 1

remove_mon_from_bonesFunction · 0.85

Calls 2

enextoFunction · 0.85
rloc_toFunction · 0.85

Tested by

no test coverage detected