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

Function polyself

src/polyself.c:468–731  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

466}
467
468void
469polyself(int psflags)
470{
471 char buf[BUFSZ];
472 int old_light, new_light, mntmp, class, tryct, gvariant = NEUTRAL;
473 boolean forcecontrol = ((psflags & POLY_CONTROLLED) != 0),
474 low_control = ((psflags & POLY_LOW_CTRL) != 0),
475 monsterpoly = ((psflags & POLY_MONSTER) != 0),
476 formrevert = ((psflags & POLY_REVERT) != 0),
477 draconian = (uarm && Is_dragon_armor(uarm)),
478 iswere = (ismnum(u.ulycn)),
479 isvamp = (is_vampire(gy.youmonst.data)
480 || is_vampshifter(&gy.youmonst)),
481 controllable_poly = Polymorph_control && !(Stunned || Unaware);
482
483 if (Unchanging) {
484 You("fail to transform!");
485 return;
486 }
487 /* being Stunned|Unaware doesn't negate this aspect of Poly_control */
488 if (!Polymorph_control && !forcecontrol && !draconian && !iswere
489 && !isvamp) {
490 if (rn2(20) > ACURR(A_CON)) {
491 You1(shudder_for_moment);
492 losehp(rnd(30), "system shock", KILLED_BY_AN);
493 exercise(A_CON, FALSE);
494 return;
495 }
496 }
497 old_light = emits_light(gy.youmonst.data);
498 mntmp = NON_PM;
499
500 if (formrevert) {
501 mntmp = gy.youmonst.cham;
502 monsterpoly = TRUE;
503 controllable_poly = FALSE;
504 }
505
506 if (forcecontrol && low_control
507 && (draconian || monsterpoly || isvamp || iswere))
508 forcecontrol = FALSE;
509
510 if (monsterpoly && isvamp)
511 goto do_vampyr;
512
513 if (controllable_poly || forcecontrol) {
514 buf[0] = '\0';
515 tryct = 5;
516
517 do {
518 mntmp = NON_PM;
519 getlin("Become what kind of monster? [type the name]", buf);
520 (void) mungspaces(buf);
521 if (*buf == '\033') {
522 /* user is cancelling controlled poly */
523 if (forcecontrol) { /* wizard mode #polyself */
524 pline1(Never_mind);
525 return;

Callers 13

allmain.cFile · 0.85
special_throne_effectFunction · 0.85
peffect_polymorphFunction · 0.85
potionhitFunction · 0.85
mon_polyFunction · 0.85
wiz_polyselfFunction · 0.85
dopolyFunction · 0.85
cpostfxFunction · 0.85
trapeffect_poly_trapFunction · 0.85
zapyourselfFunction · 0.85
do_class_genocideFunction · 0.85
do_genocideFunction · 0.85

Calls 15

YouFunction · 0.85
rn2Function · 0.85
losehpFunction · 0.85
rndFunction · 0.85
exerciseFunction · 0.85
getlinFunction · 0.85
mungspacesFunction · 0.85
name_to_monFunction · 0.85
name_to_monclassFunction · 0.85
armor_to_dragonFunction · 0.85
mkclass_polyFunction · 0.85
You_cantFunction · 0.85

Tested by

no test coverage detected