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

Function fig_transform

src/apply.c:2397–2508  ·  view source on GitHub ↗

* Timer callback routine: turn figurine into monster */

Source from the content-addressed store, hash-verified

2395 * Timer callback routine: turn figurine into monster
2396 */
2397void
2398fig_transform(anything *arg, long timeout)
2399{
2400 struct obj *figurine = arg->a_obj;
2401 struct monst *mtmp;
2402 coord cc;
2403 boolean cansee_spot, silent, okay_spot;
2404 boolean redraw = FALSE;
2405 boolean suppress_see = FALSE;
2406 char monnambuf[BUFSZ], carriedby[BUFSZ];
2407
2408 if (!figurine) {
2409 impossible("null figurine in fig_transform()");
2410 return;
2411 }
2412 silent = (timeout != svm.moves); /* happened while away */
2413 okay_spot = get_obj_location(figurine, &cc.x, &cc.y, 0);
2414 if (figurine->where == OBJ_INVENT || figurine->where == OBJ_MINVENT)
2415 okay_spot = enexto(&cc, cc.x, cc.y, &mons[figurine->corpsenm]);
2416 if (!okay_spot || !figurine_location_checks(figurine, &cc, TRUE)) {
2417 /* reset the timer to try again later */
2418 (void) start_timer((long) rnd(5000), TIMER_OBJECT, FIG_TRANSFORM,
2419 obj_to_any(figurine));
2420 return;
2421 }
2422
2423 cansee_spot = cansee(cc.x, cc.y);
2424 mtmp = make_familiar(figurine, cc.x, cc.y, TRUE);
2425 if (mtmp) {
2426 char and_vanish[BUFSZ];
2427 struct obj *mshelter = svl.level.objects[mtmp->mx][mtmp->my];
2428
2429 /* [m_monnam() yields accurate mon type, overriding hallucination] */
2430 Sprintf(monnambuf, "%s", an(m_monnam(mtmp)));
2431 and_vanish[0] = '\0';
2432 if ((mtmp->minvis && !See_invisible)
2433 || (mtmp->data->mlet == S_MIMIC
2434 && M_AP_TYPE(mtmp) != M_AP_NOTHING))
2435 suppress_see = TRUE;
2436
2437 if (mtmp->mundetected) {
2438 if (hides_under(mtmp->data) && mshelter) {
2439 Sprintf(and_vanish, " and %s under %s",
2440 locomotion(mtmp->data, "crawl"), doname(mshelter));
2441 } else if (mtmp->data->mlet == S_MIMIC
2442 || mtmp->data->mlet == S_EEL) {
2443 suppress_see = TRUE;
2444 } else
2445 Strcpy(and_vanish, " and vanish");
2446 }
2447
2448 switch (figurine->where) {
2449 case OBJ_INVENT:
2450 if (Blind || suppress_see)
2451 You_feel("%s %s from your pack!", something,
2452 locomotion(mtmp->data, "drop"));
2453 else
2454 You_see("%s %s out of your pack%s!", monnambuf,

Callers

nothing calls this directly

Calls 15

get_obj_locationFunction · 0.85
enextoFunction · 0.85
figurine_location_checksFunction · 0.85
start_timerFunction · 0.85
rndFunction · 0.85
obj_to_anyFunction · 0.85
make_familiarFunction · 0.85
anFunction · 0.85
m_monnamFunction · 0.85
locomotionFunction · 0.85
donameFunction · 0.85
You_feelFunction · 0.85

Tested by

no test coverage detected