try to revive all corpses and eggs carried by `mon' */
| 1153 | |
| 1154 | /* try to revive all corpses and eggs carried by `mon' */ |
| 1155 | int |
| 1156 | unturn_dead(struct monst *mon) |
| 1157 | { |
| 1158 | struct obj *otmp, *otmp2; |
| 1159 | struct monst *mtmp2; |
| 1160 | char owner[BUFSZ], corpse[BUFSZ]; |
| 1161 | unsigned save_norevive; |
| 1162 | boolean youseeit, different_type, is_u = (mon == &gy.youmonst); |
| 1163 | int corpsenm, res = 0; |
| 1164 | |
| 1165 | youseeit = is_u ? TRUE : canseemon(mon); |
| 1166 | otmp2 = is_u ? gi.invent : mon->minvent; |
| 1167 | owner[0] = corpse[0] = '\0'; /* lint suppression */ |
| 1168 | |
| 1169 | while ((otmp = otmp2) != 0) { |
| 1170 | otmp2 = otmp->nobj; |
| 1171 | if (otmp->otyp == EGG) |
| 1172 | revive_egg(otmp); |
| 1173 | if (otmp->otyp != CORPSE) |
| 1174 | continue; |
| 1175 | /* save the name; the object is liable to go away */ |
| 1176 | if (youseeit) { |
| 1177 | Strcpy(corpse, corpse_xname(otmp, (const char *) 0, CXN_NORMAL)); |
| 1178 | /* shk_your/Shk_Your produces a value with a trailing space */ |
| 1179 | if (otmp->quan > 1L) { |
| 1180 | Strcpy(owner, "One of "); |
| 1181 | (void) shk_your(eos(owner), otmp); |
| 1182 | } else |
| 1183 | (void) Shk_Your(owner, otmp); |
| 1184 | } |
| 1185 | /* for a stack, only one is revived; if is_u, revive() calls |
| 1186 | useup() which calls update_inventory() but not encumber_msg() */ |
| 1187 | corpsenm = otmp->corpsenm; |
| 1188 | /* norevive applies to revive timer, not to explicit unturn_dead() */ |
| 1189 | save_norevive = otmp->norevive; |
| 1190 | otmp->norevive = 0; |
| 1191 | |
| 1192 | if ((mtmp2 = revive(otmp, !svc.context.mon_moving)) != 0) { |
| 1193 | ++res; |
| 1194 | /* might get revived as a zombie rather than corpse's monster */ |
| 1195 | different_type = (mtmp2->data != &mons[corpsenm]); |
| 1196 | if (iflags.last_msg == PLNMSG_OBJ_GLOWS) { |
| 1197 | /* when hero zaps undead turning at self (or breaks |
| 1198 | non-empty wand), revive() reports "[one of] your <mon> |
| 1199 | corpse[s] glows iridescently"; override saved corpse |
| 1200 | and owner names to say "It comes alive" [note: we did |
| 1201 | earlier setup because corpse gets used up but need to |
| 1202 | do the override here after revive() sets 'last_msg'] */ |
| 1203 | Strcpy(corpse, "It"); |
| 1204 | owner[0] = '\0'; |
| 1205 | } |
| 1206 | if (youseeit) |
| 1207 | pline("%s%s suddenly %s%s%s!", owner, corpse, |
| 1208 | nonliving(mtmp2->data) ? "reanimates" : "comes alive", |
| 1209 | different_type ? " as " : "", |
| 1210 | different_type ? an(mon_pmname(mtmp2)) : ""); |
| 1211 | else if (canseemon(mtmp2)) |
| 1212 | pline("%s suddenly appears!", Amonnam(mtmp2)); |
no test coverage detected