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

Function mon_explodes

src/explode.c:1018–1067  ·  view source on GitHub ↗

A monster explodes in a way that produces a real explosion (e.g. a sphere * or gas spore, not a yellow light or similar). * This is some common code between explmu() and explmm(). */

Source from the content-addressed store, hash-verified

1016 * This is some common code between explmu() and explmm().
1017 */
1018void
1019mon_explodes(
1020 struct monst *mon,
1021 struct attack *mattk)
1022{
1023 int dmg;
1024 int type;
1025 if (mattk->damn) {
1026 dmg = d((int) mattk->damn, (int) mattk->damd);
1027 }
1028 else if (mattk->damd) {
1029 dmg = d((int) mon->data->mlevel + 1, (int) mattk->damd);
1030 }
1031 else {
1032 dmg = 0;
1033 }
1034
1035 if (mattk->adtyp == AD_PHYS) {
1036 type = PHYS_EXPL_TYPE;
1037 }
1038 else if (mattk->adtyp >= AD_MAGM && mattk->adtyp <= AD_SPC2) {
1039 /* The -1, +20, *-1 math is to set it up as a 'monster breath' type
1040 * for the explosions (it isn't, but this is the closest analogue). */
1041 /* FIXME: there are macros for kind of thing... */
1042 type = -((mattk->adtyp - 1) + 20);
1043 }
1044 else {
1045 impossible("unknown type for mon_explode %d", mattk->adtyp);
1046 return;
1047 }
1048
1049 /* Kill it now so it won't appear to be caught in its own explosion.
1050 * Must check to see if already dead - which happens if this is called
1051 * from an AT_BOOM attack upon death. */
1052 if (!DEADMONSTER(mon)) {
1053 mondead(mon);
1054 }
1055
1056 /* This might end up killing you, too; you never know...
1057 * also, it is used in explode() messages */
1058 Sprintf(svk.killer.name, "%s explosion",
1059 s_suffix(pmname(mon->data, Mgender(mon))));
1060 svk.killer.format = KILLED_BY_AN;
1061
1062 explode(mon->mx, mon->my, type, dmg, MON_EXPLODE,
1063 adtyp_to_expltype(mattk->adtyp));
1064
1065 /* reset killer */
1066 svk.killer.name[0] = '\0';
1067}
1068
1069/*explode.c*/

Callers 3

explmmFunction · 0.85
corpse_chanceFunction · 0.85
explmuFunction · 0.85

Calls 8

dFunction · 0.85
mondeadFunction · 0.85
s_suffixFunction · 0.85
pmnameFunction · 0.85
MgenderFunction · 0.85
explodeFunction · 0.85
adtyp_to_expltypeFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected