called when you move to another level */
| 786 | |
| 787 | /* called when you move to another level */ |
| 788 | void |
| 789 | keepdogs( |
| 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.", |
no test coverage detected