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

Function revive_mon

src/do.c:2250–2295  ·  view source on GitHub ↗

Revive the corpse via a timeout. */ ARGSUSED*/

Source from the content-addressed store, hash-verified

2248/* Revive the corpse via a timeout. */
2249/*ARGSUSED*/
2250void
2251revive_mon(anything *arg, long timeout UNUSED)
2252{
2253 struct obj *body = arg->a_obj;
2254 struct permonst *mptr = &mons[body->corpsenm];
2255 struct monst *mtmp;
2256 coordxy x, y;
2257
2258 /* corpse will revive somewhere else if there is a monster in the way;
2259 Riders get a chance to try to bump the obstacle out of their way */
2260 if (is_displacer(mptr) && body->where == OBJ_FLOOR
2261 && get_obj_location(body, &x, &y, 0) && (mtmp = m_at(x, y)) != 0 &&
2262 svl.level.flags.stasis_until < svm.moves) {
2263 boolean notice_it = canseemon(mtmp); /* before rloc() */
2264 char *monname = Monnam(mtmp);
2265
2266 if (rloc(mtmp, RLOC_NOMSG)) {
2267 if (notice_it && !canseemon(mtmp))
2268 pline("%s vanishes.", monname);
2269 else if (!notice_it && canseemon(mtmp))
2270 pline("%s appears.", Monnam(mtmp)); /* not pre-rloc monname */
2271 else if (notice_it && dist2(mtmp->mx, mtmp->my, x, y) > 2)
2272 pline("%s teleports.", monname); /* saw it and still see it */
2273 }
2274 }
2275
2276 /* if we succeed, the corpse is gone */
2277 if (!revive_corpse(body)) {
2278 long when;
2279 int action;
2280
2281 if (is_rider(mptr) && rn2(99)) { /* Rider usually tries again */
2282 action = REVIVE_MON;
2283 when = rider_revival_time(body, TRUE);
2284 } else { /* rot this corpse away */
2285 if (!obj_has_timer(body, ROT_CORPSE))
2286 You_feel("%sless hassled.", is_rider(mptr) ? "much " : "");
2287 action = ROT_CORPSE;
2288 when = (long) d(5, 50) - (svm.moves - body->age);
2289 if (when < 1L)
2290 when = 1L;
2291 }
2292 if (!obj_has_timer(body, action))
2293 (void) start_timer(when, TIMER_OBJECT, action, arg);
2294 }
2295}
2296
2297/* Timeout callback. Revive the corpse as a zombie. */
2298void

Callers 1

zombify_monFunction · 0.85

Calls 13

get_obj_locationFunction · 0.85
canseemonFunction · 0.85
MonnamFunction · 0.85
rlocFunction · 0.85
dist2Function · 0.85
revive_corpseFunction · 0.85
rn2Function · 0.85
rider_revival_timeFunction · 0.85
obj_has_timerFunction · 0.85
You_feelFunction · 0.85
dFunction · 0.85
start_timerFunction · 0.85

Tested by

no test coverage detected