* hitmu: monster hits you * returns MM_ flags */
| 1141 | * returns MM_ flags |
| 1142 | */ |
| 1143 | staticfn int |
| 1144 | hitmu(struct monst *mtmp, struct attack *mattk) |
| 1145 | { |
| 1146 | struct permonst *mdat = mtmp->data; |
| 1147 | struct permonst *olduasmon = gy.youmonst.data; |
| 1148 | int res; |
| 1149 | struct mhitm_data mhm; |
| 1150 | mhm.hitflags = M_ATTK_MISS; |
| 1151 | mhm.permdmg = 0; |
| 1152 | mhm.specialdmg = 0; |
| 1153 | mhm.done = FALSE; |
| 1154 | |
| 1155 | if (!canspotmon(mtmp)) |
| 1156 | map_invisible(mtmp->mx, mtmp->my); |
| 1157 | |
| 1158 | /* If the monster is undetected & hits you, you should know where |
| 1159 | * the attack came from. |
| 1160 | */ |
| 1161 | if (mtmp->mundetected && (hides_under(mdat) || mdat->mlet == S_EEL)) { |
| 1162 | mtmp->mundetected = 0; |
| 1163 | if (!tp_sensemon(mtmp) && !Detect_monsters) { |
| 1164 | struct obj *obj; |
| 1165 | const char *what; |
| 1166 | char Amonbuf[BUFSZ]; |
| 1167 | |
| 1168 | if ((obj = svl.level.objects[mtmp->mx][mtmp->my]) != 0) { |
| 1169 | if (Blind && !obj->dknown) |
| 1170 | what = something; |
| 1171 | else if (is_pool(mtmp->mx, mtmp->my) && !Underwater) |
| 1172 | what = "the water"; |
| 1173 | else |
| 1174 | what = doname(obj); |
| 1175 | |
| 1176 | Strcpy(Amonbuf, Amonnam(mtmp)); |
| 1177 | /* mtmp might be invisible with hero unable to see same */ |
| 1178 | if (!strcmp(Amonbuf, "It")) /* note: not strcmpi() */ |
| 1179 | Strcpy(Amonbuf, Something); |
| 1180 | pline("%s was hidden under %s!", Amonbuf, what); |
| 1181 | } |
| 1182 | newsym(mtmp->mx, mtmp->my); |
| 1183 | } |
| 1184 | } |
| 1185 | |
| 1186 | /* First determine the base damage done */ |
| 1187 | mhm.damage = d((int) mattk->damn, (int) mattk->damd); |
| 1188 | if ((is_undead(mdat) || is_vampshifter(mtmp)) && midnight()) |
| 1189 | mhm.damage += d((int) mattk->damn, (int) mattk->damd); /* extra dmg */ |
| 1190 | |
| 1191 | mhitm_adtyping(mtmp, mattk, &gy.youmonst, &mhm); |
| 1192 | |
| 1193 | (void) mhitm_knockback(mtmp, &gy.youmonst, mattk, &mhm.hitflags, |
| 1194 | (MON_WEP(mtmp) != 0)); |
| 1195 | |
| 1196 | if (mhm.done) |
| 1197 | return mhm.hitflags; |
| 1198 | |
| 1199 | if ((Upolyd ? u.mh : u.uhp) < 1) { |
| 1200 | /* already dead? call rehumanize() or done_in_by() as appropriate */ |
no test coverage detected