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

Function keepdogs

src/dog.c:788–884  ·  view source on GitHub ↗

called when you move to another level */

Source from the content-addressed store, hash-verified

786
787/* called when you move to another level */
788void
789keepdogs(
790 boolean pets_only) /* true for ascension or final escape */
791{
792 struct monst *mtmp, *mtmp2;
793
794 for (mtmp = fmon; mtmp; mtmp = mtmp2) {
795 mtmp2 = mtmp->nmon;
796 if (DEADMONSTER(mtmp))
797 continue;
798 if (pets_only) {
799 if (!mtmp->mtame)
800 continue; /* reject non-pets */
801 /* don't block pets from accompanying hero's dungeon
802 escape or ascension simply due to mundane trifles;
803 unlike level change for steed, don't bother trying
804 to achieve a normal trap escape first */
805 mtmp->mtrapped = 0;
806 finish_meating(mtmp);
807 mtmp->msleeping = 0;
808 mtmp->mfrozen = 0;
809 mtmp->mcanmove = 1;
810 }
811 if (((monnear(mtmp, u.ux, u.uy) && levl_follower(mtmp))
812 /* the wiz will level t-port from anywhere to chase
813 the amulet; if you don't have it, will chase you
814 only if in range. -3. */
815 || (u.uhave.amulet && mtmp->iswiz))
816 && (!helpless(mtmp)
817 /* eg if level teleport or new trap, steed has no control
818 to avoid following */
819 || (mtmp == u.usteed))
820 /* monster won't follow if it hasn't noticed you yet */
821 && !(mtmp->mstrategy & STRAT_WAITFORU)) {
822 int num_segs;
823 boolean stay_behind = FALSE;
824
825 if (mtmp->mtrapped)
826 (void) mintrap(mtmp, NO_TRAP_FLAGS); /* try to escape */
827 if (mtmp == u.usteed) {
828 /* make sure steed is eligible to accompany hero */
829 mtmp->mtrapped = 0; /* escape trap */
830 mtmp->meating = 0; /* terminate eating */
831 mdrop_special_objs(mtmp); /* drop Amulet */
832 } else if (mtmp->meating || mtmp->mtrapped) {
833 if (canseemon(mtmp))
834 pline_mon(mtmp, "%s is still %s.", Monnam(mtmp),
835 mtmp->meating ? "eating" : "trapped");
836 stay_behind = TRUE;
837 } else if (mon_has_amulet(mtmp)) {
838 if (canseemon(mtmp))
839 pline("%s seems very disoriented for a moment.",
840 Monnam(mtmp));
841 stay_behind = TRUE;
842 }
843 if (stay_behind) {
844 if (mtmp->mleashed) {
845 pline("%s leash suddenly comes loose.",

Callers 3

really_doneFunction · 0.85
goto_levelFunction · 0.85
makemap_remove_monsFunction · 0.85

Calls 15

finish_meatingFunction · 0.85
monnearFunction · 0.85
levl_followerFunction · 0.85
mintrapFunction · 0.85
mdrop_special_objsFunction · 0.85
canseemonFunction · 0.85
pline_monFunction · 0.85
MonnamFunction · 0.85
mon_has_amuletFunction · 0.85
m_unleashFunction · 0.85
dismount_steedFunction · 0.85
mon_leaveFunction · 0.85

Tested by

no test coverage detected