* Animate the given statue. May have been via shatter attempt, trap, * or stone to flesh spell. Return a monster if successfully animated. * If the monster is animated, the object is deleted. If fail_reason * is non-null, then fill in the reason for failure (or success). * * The cause of animation is: * * ANIMATE_NORMAL - hero "finds" the monster * ANIMATE_SHATTER - hero trie
| 723 | * shop status--it's not worth the hassle.] |
| 724 | */ |
| 725 | struct monst * |
| 726 | animate_statue( |
| 727 | struct obj *statue, |
| 728 | coordxy x, |
| 729 | coordxy y, |
| 730 | int cause, |
| 731 | int *fail_reason) |
| 732 | { |
| 733 | static const char |
| 734 | historic_statue_is_gone[] = "that the historic statue is now gone"; |
| 735 | int mnum = statue->corpsenm; |
| 736 | struct permonst *mptr = &mons[mnum]; |
| 737 | struct monst *mon = 0, *shkp; |
| 738 | struct obj *item; |
| 739 | coord cc; |
| 740 | boolean historic = (Role_if(PM_ARCHEOLOGIST) |
| 741 | && (statue->spe & CORPSTAT_HISTORIC) != 0), |
| 742 | golem_xform = FALSE, use_saved_traits; |
| 743 | const char *comes_to_life; |
| 744 | char statuename[BUFSZ], tmpbuf[BUFSZ]; |
| 745 | |
| 746 | if (cant_revive(&mnum, TRUE, statue)) { |
| 747 | /* mnum has changed; we won't be animating this statue as itself */ |
| 748 | if (mnum != PM_DOPPELGANGER) |
| 749 | mptr = &mons[mnum]; |
| 750 | use_saved_traits = FALSE; |
| 751 | } else if (is_golem(mptr) && cause == ANIMATE_SPELL) { |
| 752 | /* statue of any golem hit by stone-to-flesh becomes flesh golem */ |
| 753 | golem_xform = (mptr != &mons[PM_FLESH_GOLEM]); |
| 754 | mnum = PM_FLESH_GOLEM; |
| 755 | mptr = &mons[PM_FLESH_GOLEM]; |
| 756 | use_saved_traits = (has_omonst(statue) && !golem_xform); |
| 757 | } else { |
| 758 | use_saved_traits = has_omonst(statue); |
| 759 | } |
| 760 | |
| 761 | if (use_saved_traits) { |
| 762 | /* restore a petrified monster */ |
| 763 | cc.x = x, cc.y = y; |
| 764 | mon = montraits(statue, &cc, (cause == ANIMATE_SPELL)); |
| 765 | if (mon && mon->mtame && !mon->isminion) |
| 766 | wary_dog(mon, TRUE); |
| 767 | } else { |
| 768 | int sgend = (statue->spe & CORPSTAT_GENDER); |
| 769 | mmflags_nht mmflags = (NO_MINVENT | MM_NOMSG |
| 770 | | ((sgend == CORPSTAT_MALE) ? MM_MALE : 0) |
| 771 | | ((sgend == CORPSTAT_FEMALE) ? MM_FEMALE : 0)); |
| 772 | |
| 773 | /* statues of unique monsters from bones or wishing end |
| 774 | up here (cant_revive() sets mnum to be doppelganger; |
| 775 | mptr reflects the original form for use by newcham()) */ |
| 776 | if ((mnum == PM_DOPPELGANGER && mptr != &mons[PM_DOPPELGANGER]) |
| 777 | /* block quest guards from other roles */ |
| 778 | || (mptr->msound == MS_GUARDIAN |
| 779 | && quest_info(MS_GUARDIAN) != mnum)) { |
| 780 | mmflags |= MM_NOCOUNTBIRTH | MM_ADJACENTOK; |
| 781 | mon = makemon(&mons[PM_DOPPELGANGER], x, y, mmflags); |
| 782 | /* if hero has protection from shape changers, cham field will |
no test coverage detected