| 1119 | } |
| 1120 | |
| 1121 | int |
| 1122 | mon_poly(struct monst *magr, struct monst *mdef, int dmg) |
| 1123 | { |
| 1124 | static const char freaky[] = " undergoes a freakish metamorphosis"; |
| 1125 | struct permonst *oldform = mdef->data; |
| 1126 | |
| 1127 | if (mdef == &gy.youmonst) { |
| 1128 | if (Antimagic) { |
| 1129 | shieldeff(u.ux, u.uy); |
| 1130 | } else if (Unchanging) { |
| 1131 | ; /* just take a little damage */ |
| 1132 | } else { |
| 1133 | /* system shock might take place in polyself() */ |
| 1134 | if (u.ulycn == NON_PM) { |
| 1135 | You("are subjected to a freakish metamorphosis."); |
| 1136 | polyself(POLY_NOFLAGS); |
| 1137 | } else if (u.umonnum != u.ulycn) { |
| 1138 | You_feel("an unnatural urge coming on."); |
| 1139 | you_were(); |
| 1140 | } else { |
| 1141 | You_feel("a natural urge coming on."); |
| 1142 | you_unwere(FALSE); |
| 1143 | } |
| 1144 | dmg = 0; |
| 1145 | } |
| 1146 | } else { |
| 1147 | char Before[BUFSZ]; |
| 1148 | |
| 1149 | Strcpy(Before, Monnam(mdef)); |
| 1150 | if (resists_magm(mdef)) { |
| 1151 | /* Magic resistance */ |
| 1152 | if (gv.vis) |
| 1153 | shieldeff_mon(mdef); |
| 1154 | } else if (resist(mdef, WAND_CLASS, 0, TELL)) { |
| 1155 | /* general resistance to magic... */ |
| 1156 | ; |
| 1157 | } else if (!rn2(25) && mdef->cham == NON_PM |
| 1158 | && (mdef->mcan |
| 1159 | || pm_to_cham(monsndx(mdef->data)) != NON_PM)) { |
| 1160 | /* system shock; this variation takes away half of mon's HP |
| 1161 | rather than kill outright */ |
| 1162 | if (gv.vis) |
| 1163 | pline("%s shudders!", Before); |
| 1164 | |
| 1165 | dmg += (mdef->mhpmax + 1) / 2; |
| 1166 | mdef->mhp -= dmg; |
| 1167 | dmg = 0; |
| 1168 | if (DEADMONSTER(mdef)) { |
| 1169 | if (magr == &gy.youmonst) |
| 1170 | xkilled(mdef, XKILL_GIVEMSG | XKILL_NOCORPSE); |
| 1171 | else |
| 1172 | monkilled(mdef, "", AD_RBRE); |
| 1173 | } |
| 1174 | } else if (newcham(mdef, (struct permonst *) 0, NO_NC_FLAGS)) { |
| 1175 | if (gv.vis) { /* either seen or adjacent */ |
| 1176 | boolean was_seen = !!strcmpi("It", Before), |
| 1177 | verbosely = flags.verbose || !was_seen; |
| 1178 |
no test coverage detected