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

Function explmm

src/mhitm.c:969–1010  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

967}
968
969staticfn int
970explmm(struct monst *magr, struct monst *mdef, struct attack *mattk)
971{
972 int result;
973
974 if (magr->mcan)
975 return M_ATTK_MISS;
976
977 if (cansee(magr->mx, magr->my))
978 pline_mon(magr, "%s explodes!", Monnam(magr));
979 else
980 noises(magr, mattk);
981
982 /* monster explosion types which actually create an explosion */
983 if (mattk->adtyp == AD_FIRE || mattk->adtyp == AD_COLD
984 || mattk->adtyp == AD_ELEC) {
985 mon_explodes(magr, mattk);
986 /* unconditionally set AGR_DIED here; lifesaving is accounted below */
987 result = M_ATTK_AGR_DIED | (DEADMONSTER(mdef) ? M_ATTK_DEF_DIED : 0);
988 } else {
989 result = mdamagem(magr, mdef, mattk, (struct obj *) 0, 0);
990 }
991
992 /* Kill off aggressor if it didn't die. */
993 if (!(result & M_ATTK_AGR_DIED)) {
994 boolean was_leashed = (magr->mleashed != 0);
995
996 mondead(magr);
997 if (!DEADMONSTER(magr))
998 return result; /* life saved */
999 result |= M_ATTK_AGR_DIED;
1000
1001 /* mondead() -> m_detach() -> m_unleash() always suppresses
1002 the m_unleash() slack message, so deliver it here instead */
1003 if (was_leashed)
1004 Your("leash falls slack.");
1005 }
1006 if (magr->mtame) /* give this one even if it was visible */
1007 You(brief_feeling, "melancholy");
1008
1009 return result;
1010}
1011
1012/*
1013 * See comment at top of mattackm(), for return values.

Callers 1

mattackmFunction · 0.85

Calls 8

pline_monFunction · 0.85
MonnamFunction · 0.85
noisesFunction · 0.85
mon_explodesFunction · 0.85
mdamagemFunction · 0.85
mondeadFunction · 0.85
YourFunction · 0.85
YouFunction · 0.85

Tested by

no test coverage detected