* See comment at top of mattackm(), for return values. */
| 1013 | * See comment at top of mattackm(), for return values. |
| 1014 | */ |
| 1015 | staticfn int |
| 1016 | mdamagem( |
| 1017 | struct monst *magr, |
| 1018 | struct monst *mdef, |
| 1019 | struct attack *mattk, |
| 1020 | struct obj *mwep, |
| 1021 | int dieroll) |
| 1022 | { |
| 1023 | struct permonst *pa = magr->data, *pd = mdef->data; |
| 1024 | struct mhitm_data mhm; |
| 1025 | mhm.damage = d((int) mattk->damn, (int) mattk->damd); |
| 1026 | mhm.hitflags = M_ATTK_MISS; |
| 1027 | mhm.permdmg = 0; |
| 1028 | mhm.specialdmg = 0; |
| 1029 | mhm.dieroll = dieroll; |
| 1030 | mhm.done = FALSE; |
| 1031 | |
| 1032 | if ((touch_petrifies(pd) /* or flesh_petrifies() */ |
| 1033 | || (mattk->adtyp == AD_DGST && pd == &mons[PM_MEDUSA])) |
| 1034 | && !resists_ston(magr)) { |
| 1035 | long protector = attk_protection((int) mattk->aatyp), |
| 1036 | wornitems = magr->misc_worn_check; |
| 1037 | |
| 1038 | /* wielded weapon gives same protection as gloves here */ |
| 1039 | if (mwep) |
| 1040 | wornitems |= W_ARMG; |
| 1041 | |
| 1042 | if (protector == 0L |
| 1043 | || (protector != ~0L && (wornitems & protector) != protector)) { |
| 1044 | if (poly_when_stoned(pa)) { |
| 1045 | mon_to_stone(magr); |
| 1046 | return M_ATTK_HIT; /* no damage during the polymorph */ |
| 1047 | } |
| 1048 | if (gv.vis && canspotmon(magr)) |
| 1049 | pline_mon(magr, "%s turns to stone!", Monnam(magr)); |
| 1050 | monstone(magr); |
| 1051 | if (!DEADMONSTER(magr)) |
| 1052 | return M_ATTK_HIT; /* lifesaved */ |
| 1053 | else if (magr->mtame && !gv.vis) |
| 1054 | You(brief_feeling, "peculiarly sad"); |
| 1055 | return M_ATTK_AGR_DIED; |
| 1056 | } |
| 1057 | } |
| 1058 | |
| 1059 | mhitm_adtyping(magr, mattk, mdef, &mhm); |
| 1060 | |
| 1061 | if (mhitm_knockback(magr, mdef, mattk, &mhm.hitflags, |
| 1062 | (MON_WEP(magr) != 0)) |
| 1063 | && ((mhm.hitflags & (M_ATTK_DEF_DIED | M_ATTK_HIT)) != 0 |
| 1064 | || mon_offmap(mdef))) |
| 1065 | return mhm.hitflags; |
| 1066 | |
| 1067 | if (mhm.done) |
| 1068 | return mhm.hitflags; |
| 1069 | |
| 1070 | if (!mhm.damage) |
| 1071 | return mhm.hitflags; |
| 1072 |
no test coverage detected