also used by newcham() */
| 535 | |
| 536 | /* also used by newcham() */ |
| 537 | int |
| 538 | pick_nasty( |
| 539 | int difcap) /* if non-zero, try to make difficulty be lower than this */ |
| 540 | { |
| 541 | int alt, res = ROLL_FROM(nasties); |
| 542 | |
| 543 | /* To do? Possibly should filter for appropriate forms when |
| 544 | * in the elemental planes or surrounded by water or lava. |
| 545 | * |
| 546 | * We want monsters represented by uppercase on rogue level, |
| 547 | * but we don't try very hard. |
| 548 | */ |
| 549 | if (Is_rogue_level(&u.uz) |
| 550 | && !('A' <= monsym(&mons[res]) && monsym(&mons[res]) <= 'Z')) |
| 551 | res = ROLL_FROM(nasties); |
| 552 | |
| 553 | /* if genocided or too difficult or out of place, try a substitute |
| 554 | when a suitable one exists |
| 555 | arch-lich -> master lich, |
| 556 | master mind flayer -> mind flayer, |
| 557 | but the substitutes are likely to be genocided too */ |
| 558 | alt = res; |
| 559 | if ((svm.mvitals[res].mvflags & G_GENOD) != 0 |
| 560 | || (difcap > 0 && mons[res].difficulty >= difcap) |
| 561 | /* note: nasty() -> makemon() ignores G_HELL|G_NOHELL; |
| 562 | arch-lich and master lich are both flagged as hell-only; |
| 563 | this filtering demotes arch-lich to master lich when |
| 564 | outside of Gehennom (unless the latter has been genocided) */ |
| 565 | || (mons[res].geno & (Inhell ? G_NOHELL : G_HELL)) != 0) |
| 566 | alt = big_to_little(res); |
| 567 | if (alt != res && (svm.mvitals[alt].mvflags & G_GENOD) == 0) { |
| 568 | const char *mnam = mons[alt].pmnames[NEUTRAL], |
| 569 | *lastspace = strrchr(mnam, ' '); |
| 570 | |
| 571 | /* only non-juveniles can become alternate choice */ |
| 572 | if (strncmp(mnam, "baby ", 5) |
| 573 | && (!lastspace |
| 574 | || (strcmp(lastspace, " hatchling") |
| 575 | && strcmp(lastspace, " pup") |
| 576 | && strcmp(lastspace, " cub")))) |
| 577 | res = alt; |
| 578 | } |
| 579 | |
| 580 | return res; |
| 581 | } |
| 582 | |
| 583 | /* create some nasty monsters, aligned with the caster or neutral; chaotic |
| 584 | and unaligned are treated as equivalent; if summoner is Null, this is |
no test coverage detected