| 1469 | } |
| 1470 | |
| 1471 | void |
| 1472 | quickmimic(struct monst *mtmp) |
| 1473 | { |
| 1474 | int idx = 0, trycnt = 5, spotted, seeloc; |
| 1475 | boolean was_leashed = mtmp->mleashed; |
| 1476 | char buf[BUFSZ]; |
| 1477 | |
| 1478 | if (Protection_from_shape_changers || !mtmp->meating) |
| 1479 | return; |
| 1480 | |
| 1481 | /* with polymorph, the steed's equipment would be re-checked and its |
| 1482 | saddle would come off, triggering DISMOUNT_FELL, but mimicking |
| 1483 | doesn't impact monster's equipment; normally DISMOUNT_POLY is for |
| 1484 | rider taking on an unsuitable shape, but its message works fine |
| 1485 | for this and also avoids inflicting damage during forced dismount; |
| 1486 | do this before changing so that dismount refers to original shape */ |
| 1487 | if (mtmp == u.usteed) |
| 1488 | dismount_steed(DISMOUNT_POLY); |
| 1489 | |
| 1490 | do { |
| 1491 | idx = rn2(SIZE(qm)); |
| 1492 | if (qm[idx].mndx != 0 && monsndx(mtmp->data) == qm[idx].mndx) |
| 1493 | break; |
| 1494 | if (qm[idx].mlet != 0 && mtmp->data->mlet == qm[idx].mlet) |
| 1495 | break; |
| 1496 | if (qm[idx].mndx == 0 && qm[idx].mlet == 0) |
| 1497 | break; |
| 1498 | } while (--trycnt > 0); |
| 1499 | if (trycnt == 0) |
| 1500 | idx = SIZE(qm) - 1; |
| 1501 | |
| 1502 | Strcpy(buf, y_monnam(mtmp)); /* "your <pet>" or "the <mon>" or "Fang" */ |
| 1503 | spotted = canspotmon(mtmp); |
| 1504 | seeloc = cansee(mtmp->mx, mtmp->my); |
| 1505 | |
| 1506 | mtmp->m_ap_type = qm[idx].m_ap_type; |
| 1507 | mtmp->mappearance = qm[idx].mappearance; |
| 1508 | |
| 1509 | if (spotted || seeloc || canspotmon(mtmp)) { |
| 1510 | int prev_glyph = glyph_at(mtmp->mx, mtmp->my); |
| 1511 | const char *what = (M_AP_TYPE(mtmp) == M_AP_FURNITURE) |
| 1512 | ? defsyms[mtmp->mappearance].explanation |
| 1513 | : (M_AP_TYPE(mtmp) == M_AP_OBJECT |
| 1514 | && OBJ_DESCR(objects[mtmp->mappearance])) |
| 1515 | ? OBJ_DESCR(objects[mtmp->mappearance]) |
| 1516 | : (M_AP_TYPE(mtmp) == M_AP_OBJECT |
| 1517 | && OBJ_NAME(objects[mtmp->mappearance])) |
| 1518 | ? OBJ_NAME(objects[mtmp->mappearance]) |
| 1519 | : (M_AP_TYPE(mtmp) == M_AP_MONSTER) |
| 1520 | ? pmname(&mons[mtmp->mappearance], |
| 1521 | Mgender(mtmp)) |
| 1522 | : something; |
| 1523 | |
| 1524 | newsym(mtmp->mx, mtmp->my); |
| 1525 | if (was_leashed |
| 1526 | && (M_AP_TYPE(mtmp) != M_AP_MONSTER |
| 1527 | || !mnum_leashable(mtmp->mappearance))) { |
| 1528 | Your("leash goes slack."); |
no test coverage detected