MCPcopy Create free account
hub / github.com/NetHack/NetHack / lifesaved_monster

Function lifesaved_monster

src/mon.c:2838–2884  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2836}
2837
2838staticfn void
2839lifesaved_monster(struct monst *mtmp)
2840{
2841 boolean surviver;
2842 struct obj *lifesave = mlifesaver(mtmp);
2843
2844 if (lifesave) {
2845 /* not canseemon; amulets are on the head, so you don't want
2846 * to show this for a long worm with only a tail visible.
2847 * Nor do you check invisibility, because glowing and
2848 * disintegrating amulets are always visible. */
2849 if (cansee(mtmp->mx, mtmp->my)) {
2850 pline("But wait...");
2851 pline("%s medallion begins to glow!", s_suffix(Monnam(mtmp)));
2852 makeknown(AMULET_OF_LIFE_SAVING);
2853 /* amulet is visible, but monster might not be */
2854 if (canseemon(mtmp)) {
2855 if (attacktype(mtmp->data, AT_EXPL)
2856 || attacktype(mtmp->data, AT_BOOM))
2857 pline("%s reconstitutes!", Monnam(mtmp));
2858 else
2859 pline("%s looks much better!", Monnam(mtmp));
2860 }
2861 pline_The("medallion crumbles to dust!");
2862 }
2863 m_useup(mtmp, lifesave);
2864 /* equip replacement amulet, if any, on next move */
2865 check_gear_next_turn(mtmp);
2866
2867 surviver = !(svm.mvitals[monsndx(mtmp->data)].mvflags & G_GENOD);
2868 mtmp->mcanmove = 1;
2869 mtmp->mfrozen = 0;
2870 if (mtmp->mtame && !mtmp->isminion) {
2871 wary_dog(mtmp, !surviver);
2872 }
2873 set_mon_min_mhpmax(mtmp, 10); /* mtmp->mhpmax=max(mtmp->m_lev+1,10) */
2874 mtmp->mhp = mtmp->mhpmax;
2875
2876 if (!surviver) {
2877 /* genocided monster can't be life-saved */
2878 if (cansee(mtmp->mx, mtmp->my))
2879 pline("Unfortunately, %s is still genocided...",
2880 mon_nam(mtmp));
2881 mtmp->mhp = 0;
2882 }
2883 }
2884}
2885
2886/* when a shape-shifted vampire is killed, it reverts to base form instead
2887 of dying; returns True if mtmp successfully revives, False otherwise;

Callers 2

mondeadFunction · 0.85
monstoneFunction · 0.85

Calls 12

mlifesaverFunction · 0.85
s_suffixFunction · 0.85
MonnamFunction · 0.85
canseemonFunction · 0.85
attacktypeFunction · 0.85
pline_TheFunction · 0.85
m_useupFunction · 0.85
check_gear_next_turnFunction · 0.85
wary_dogFunction · 0.85
set_mon_min_mhpmaxFunction · 0.85
mon_namFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected