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

Function obj_pmname

src/do_name.c:1320–1359  ·  view source on GitHub ↗

mons[]->pmname for a corpse or statue or figurine */

Source from the content-addressed store, hash-verified

1318
1319/* mons[]->pmname for a corpse or statue or figurine */
1320const char *
1321obj_pmname(struct obj *obj)
1322{
1323#if 0 /* ignore saved montraits even when they're available; they determine
1324 * what a corpse would revive as if resurrected (human corpse from
1325 * slain vampire revives as vampire rather than as human, for example)
1326 * and don't necessarily reflect the state of the corpse itself */
1327 if (has_omonst(obj)) {
1328 struct monst *m = OMONST(obj);
1329
1330 /* obj->oextra->omonst->data is Null but ...->mnum is set */
1331 if (ismnum(m->mnum))
1332 return pmname(&mons[m->mnum], Mgender(m));
1333 }
1334#endif
1335 if ((obj->otyp == CORPSE || obj->otyp == STATUE || obj->otyp == FIGURINE)
1336 && ismnum(obj->corpsenm)) {
1337 int cgend = (obj->spe & CORPSTAT_GENDER),
1338 mgend = ((cgend == CORPSTAT_MALE) ? MALE
1339 : (cgend == CORPSTAT_FEMALE) ? FEMALE
1340 : NEUTRAL),
1341 mndx = obj->corpsenm;
1342
1343 /* mons[].pmnames[] for monster cleric uses "priest" or "priestess"
1344 or "aligned cleric"; we want to avoid "aligned cleric [corpse]"
1345 unless it has been explicitly flagged as neuter rather than
1346 defaulting to random (which fails male or female check above);
1347 role monster cleric uses "priest" or "priestess" or "cleric"
1348 without "aligned" prefix so we switch to that; [can't force
1349 random gender to be chosen here because splitting a stack of
1350 corpses could cause the split-off portion to change gender, so
1351 settle for avoiding "aligned"] */
1352 if (mndx == PM_ALIGNED_CLERIC && cgend == CORPSTAT_RANDOM)
1353 mndx = PM_CLERIC;
1354
1355 return pmname(&mons[mndx], mgend);
1356 }
1357 impossible("obj_pmname otyp:%i,corpsenm:%i", obj->otyp, obj->corpsenm);
1358 return "two-legged glorkum-seeker";
1359}
1360
1361/* used by bogusmon(next) and also by init_CapMons(rumors.c);
1362 bogon_is_pname(below) checks a hard-coded subset of these rather than

Callers 6

better_not_take_that_offFunction · 0.85
xname_flagsFunction · 0.85
corpse_xnameFunction · 0.85
selftouchFunction · 0.85
its_deadFunction · 0.85

Calls 3

pmnameFunction · 0.85
MgenderFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected