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

Function mon_poly

src/mhitm.c:1121–1207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1119}
1120
1121int
1122mon_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

Callers 1

mhitm_ad_polyFunction · 0.85

Calls 15

shieldeffFunction · 0.85
YouFunction · 0.85
polyselfFunction · 0.85
You_feelFunction · 0.85
you_wereFunction · 0.85
you_unwereFunction · 0.85
MonnamFunction · 0.85
resists_magmFunction · 0.85
shieldeff_monFunction · 0.85
resistFunction · 0.85
rn2Function · 0.85
pm_to_chamFunction · 0.85

Tested by

no test coverage detected