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

Function dog_hunger

src/dogmove.c:361–394  ·  view source on GitHub ↗

hunger effects -- returns TRUE on starvation */

Source from the content-addressed store, hash-verified

359
360/* hunger effects -- returns TRUE on starvation */
361staticfn boolean
362dog_hunger(struct monst *mtmp, struct edog *edog)
363{
364 if (svm.moves > edog->hungrytime + DOG_WEAK) {
365 if (!carnivorous(mtmp->data) && !herbivorous(mtmp->data)) {
366 edog->hungrytime = svm.moves + DOG_WEAK;
367 /* but not too high; it might polymorph */
368 } else if (!edog->mhpmax_penalty) {
369 /* starving pets are limited in healing */
370 int newmhpmax = mtmp->mhpmax / 3;
371 mtmp->mconf = 1;
372 edog->mhpmax_penalty = mtmp->mhpmax - newmhpmax;
373 mtmp->mhpmax = newmhpmax;
374 if (mtmp->mhp > mtmp->mhpmax)
375 mtmp->mhp = mtmp->mhpmax;
376 if (DEADMONSTER(mtmp)) {
377 dog_starve(mtmp);
378 return TRUE;
379 }
380 if (cansee(mtmp->mx, mtmp->my))
381 pline_mon(mtmp, "%s is confused from hunger.", Monnam(mtmp));
382 else if (couldsee(mtmp->mx, mtmp->my))
383 beg(mtmp);
384 else
385 You_feel("worried about %s.", y_monnam(mtmp));
386 stop_occupation();
387 } else if (svm.moves > edog->hungrytime + DOG_STARVE
388 || DEADMONSTER(mtmp)) {
389 dog_starve(mtmp);
390 return TRUE;
391 }
392 }
393 return FALSE;
394}
395
396/* do something with object (drop, pick up, eat) at current position
397 * returns 1 if object eaten (since that counts as dog's move), 2 if died

Callers 1

dog_moveFunction · 0.85

Calls 7

dog_starveFunction · 0.85
pline_monFunction · 0.85
MonnamFunction · 0.85
begFunction · 0.85
You_feelFunction · 0.85
y_monnamFunction · 0.85
stop_occupationFunction · 0.85

Tested by

no test coverage detected