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(). */
| 1016 | * This is some common code between explmu() and explmm(). |
| 1017 | */ |
| 1018 | void |
| 1019 | mon_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*/ |
no test coverage detected