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

Function mon_catchup_elapsed_time

src/dog.c:626–724  ·  view source on GitHub ↗

heal monster for time spent elsewhere */

Source from the content-addressed store, hash-verified

624
625/* heal monster for time spent elsewhere */
626void
627mon_catchup_elapsed_time(
628 struct monst *mtmp,
629 long nmv) /* number of moves */
630{
631 int imv = 0; /* avoid zillions of casts and lint warnings */
632
633#if defined(DEBUG) || (NH_DEVEL_STATUS != NH_STATUS_RELEASED)
634
635 if (nmv < 0L) { /* crash likely... */
636 panic("catchup from future time?");
637 /*NOTREACHED*/
638 return;
639 } else if (nmv == 0L) { /* safe, but shouldn't happen */
640 impossible("catchup from now?");
641 } else
642#endif
643 if (nmv >= LARGEST_INT) /* paranoia */
644 imv = LARGEST_INT - 1;
645 else
646 imv = (int) nmv;
647
648 /* might stop being afraid, blind or frozen */
649 /* set to 1 and allow final decrement in movemon() */
650 if (mtmp->mblinded) {
651 if (imv >= (int) mtmp->mblinded)
652 mtmp->mblinded = 1;
653 else
654 mtmp->mblinded -= imv;
655 }
656 if (mtmp->mfrozen) {
657 if (imv >= (int) mtmp->mfrozen)
658 mtmp->mfrozen = 1;
659 else
660 mtmp->mfrozen -= imv;
661 }
662 if (mtmp->mfleetim) {
663 if (imv >= (int) mtmp->mfleetim)
664 mtmp->mfleetim = 1;
665 else
666 mtmp->mfleetim -= imv;
667 }
668
669 /* might recover from temporary trouble */
670 if (mtmp->mtrapped && rn2(imv + 1) > 40 / 2)
671 mtmp->mtrapped = 0;
672 if (mtmp->mconf && rn2(imv + 1) > 50 / 2)
673 mtmp->mconf = 0;
674 if (mtmp->mstun && rn2(imv + 1) > 10 / 2)
675 mtmp->mstun = 0;
676
677 /* might finish eating or be able to use special ability again */
678 if (mtmp->meating) {
679 if (imv > mtmp->meating)
680 finish_meating(mtmp);
681 else
682 mtmp->meating -= imv;
683 }

Callers 3

getlevFunction · 0.85
resurrectFunction · 0.85
mon_arriveFunction · 0.85

Calls 7

rn2Function · 0.85
finish_meatingFunction · 0.85
m_unleashFunction · 0.85
healmonFunction · 0.85
set_mon_lastmoveFunction · 0.85
impossibleFunction · 0.70
panicFunction · 0.50

Tested by

no test coverage detected