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

Function wary_dog

src/dog.c:1291–1359  ·  view source on GitHub ↗

* Called during pet revival or pet life-saving. * If you killed the pet, it revives wild. * If you abused the pet a lot while alive, it revives wild. * If you abused the pet at all while alive, it revives untame. * If the pet wasn't abused and was very tame, it might revive tame. */

Source from the content-addressed store, hash-verified

1289 * If the pet wasn't abused and was very tame, it might revive tame.
1290 */
1291void
1292wary_dog(struct monst *mtmp, boolean was_dead)
1293{
1294 struct edog *edog;
1295 boolean quietly = was_dead;
1296
1297 finish_meating(mtmp);
1298
1299 if (!mtmp->mtame)
1300 return;
1301 edog = !mtmp->isminion ? EDOG(mtmp) : 0;
1302
1303 /* if monster was starving when it died, undo that now */
1304 if (edog && edog->mhpmax_penalty) {
1305 mtmp->mhpmax += edog->mhpmax_penalty;
1306 mtmp->mhp += edog->mhpmax_penalty; /* heal it */
1307 edog->mhpmax_penalty = 0;
1308 }
1309
1310 if (edog && (edog->killed_by_u == 1 || edog->abuse > 2)) {
1311 mtmp->mpeaceful = mtmp->mtame = 0;
1312 if (edog->abuse >= 0 && edog->abuse < 10)
1313 if (!rn2(edog->abuse + 1))
1314 mtmp->mpeaceful = 1;
1315 if (!quietly && cansee(mtmp->mx, mtmp->my)) {
1316 if (haseyes(gy.youmonst.data)) {
1317 if (haseyes(mtmp->data))
1318 pline_mon(mtmp,
1319 "%s %s to look you in the %s.", Monnam(mtmp),
1320 mtmp->mpeaceful ? "seems unable" : "refuses",
1321 body_part(EYE));
1322 else
1323 pline_mon(mtmp, "%s avoids your gaze.", Monnam(mtmp));
1324 }
1325 }
1326 } else {
1327 /* chance it goes wild anyway - Pet Sematary */
1328 mtmp->mtame = rn2(mtmp->mtame + 1);
1329 if (!mtmp->mtame)
1330 mtmp->mpeaceful = rn2(2);
1331 }
1332
1333 if (!mtmp->mtame) {
1334 if (!quietly && canspotmon(mtmp))
1335 pline_mon(mtmp, "%s %s.", Monnam(mtmp),
1336 mtmp->mpeaceful ? "is no longer tame" : "has become feral");
1337 newsym(mtmp->mx, mtmp->my);
1338 /* a life-saved monster might be leashed;
1339 don't leave it that way if it's no longer tame */
1340 if (mtmp->mleashed)
1341 m_unleash(mtmp, TRUE);
1342 if (mtmp == u.usteed)
1343 dismount_steed(DISMOUNT_THROWN);
1344 } else if (edog) {
1345 /* it's still a pet; start a clean pet-slate now */
1346 edog->revivals++;
1347 edog->killed_by_u = 0;
1348 edog->abuse = 0;

Callers 3

lifesaved_monsterFunction · 0.85
animate_statueFunction · 0.85
reviveFunction · 0.85

Calls 8

finish_meatingFunction · 0.85
rn2Function · 0.85
pline_monFunction · 0.85
MonnamFunction · 0.85
body_partFunction · 0.85
newsymFunction · 0.85
m_unleashFunction · 0.85
dismount_steedFunction · 0.85

Tested by

no test coverage detected