| 466 | } |
| 467 | |
| 468 | void |
| 469 | polyself(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; |
no test coverage detected