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

Function use_misc

src/muse.c:2380–2626  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2378}
2379
2380DISABLE_WARNING_UNREACHABLE_CODE
2381
2382int
2383use_misc(struct monst *mtmp)
2384{
2385 static const char MissingMiscellaneousItem[] = "use_misc: no %s";
2386 char nambuf[BUFSZ];
2387 boolean vis, vismon, vistrapspot, oseen;
2388 int i;
2389 struct trap *t;
2390 struct obj *otmp = gm.m.misc;
2391
2392 if ((i = precheck(mtmp, otmp)) != 0)
2393 return i;
2394 vis = cansee(mtmp->mx, mtmp->my);
2395 vismon = canseemon(mtmp);
2396 oseen = otmp && vismon;
2397
2398 switch (gm.m.has_misc) {
2399 case MUSE_POT_GAIN_LEVEL:
2400 if (!otmp)
2401 panic(MissingMiscellaneousItem, "potion of gain level");
2402 mquaffmsg(mtmp, otmp);
2403 if (otmp->cursed) {
2404 if (Can_rise_up(mtmp->mx, mtmp->my, &u.uz)) {
2405 int tolev = depth(&u.uz) - 1;
2406 d_level tolevel;
2407
2408 get_level(&tolevel, tolev);
2409 /* insurance against future changes... */
2410 if (on_level(&tolevel, &u.uz))
2411 goto skipmsg;
2412 if (vismon) {
2413 pline_mon(mtmp, "%s rises up, through the %s!",
2414 Monnam(mtmp),
2415 ceiling(mtmp->mx, mtmp->my));
2416 trycall(otmp);
2417 }
2418 m_useup(mtmp, otmp);
2419 migrate_to_level(mtmp, ledger_no(&tolevel), MIGR_RANDOM,
2420 (coord *) 0);
2421 return 2;
2422 } else {
2423 skipmsg:
2424 if (vismon) {
2425 pline_mon(mtmp, "%s looks uneasy.", Monnam(mtmp));
2426 trycall(otmp);
2427 }
2428 m_useup(mtmp, otmp);
2429 return 2;
2430 }
2431 }
2432 if (vismon)
2433 pline_mon(mtmp, "%s seems more experienced.", Monnam(mtmp));
2434 if (oseen)
2435 makeknown(POT_GAIN_LEVEL);
2436 m_useup(mtmp, otmp);
2437 if (!grow_up(mtmp, (struct monst *) 0))

Callers 1

dochugFunction · 0.85

Calls 15

canseemonFunction · 0.85
mquaffmsgFunction · 0.85
Can_rise_upFunction · 0.85
depthFunction · 0.85
get_levelFunction · 0.85
on_levelFunction · 0.85
pline_monFunction · 0.85
MonnamFunction · 0.85
ceilingFunction · 0.85
trycallFunction · 0.85
m_useupFunction · 0.85
migrate_to_levelFunction · 0.85

Tested by

no test coverage detected