Return values (same as m_move): * 0: did not move, but can still attack and do other stuff. * 1: moved, possibly can attack. * 2: monster died. * 3: did not move, and can't do anything else either. * (may have attacked something) */
| 974 | * (may have attacked something) |
| 975 | */ |
| 976 | int |
| 977 | dog_move( |
| 978 | struct monst *mtmp, /* pet */ |
| 979 | int after) /* this is extra fast monster movement */ |
| 980 | { |
| 981 | int omx, omy; /* original mtmp position */ |
| 982 | int appr, whappr, udist; |
| 983 | int i, j, k; |
| 984 | struct edog *edog = (mtmp->mtame && has_edog(mtmp)) ? EDOG(mtmp) : 0; |
| 985 | struct obj *obj = (struct obj *) 0; |
| 986 | xint16 otyp; |
| 987 | boolean cursemsg[9], do_eat = FALSE; |
| 988 | boolean better_with_displacing = FALSE, ranged_only; |
| 989 | coordxy nix, niy; /* position mtmp is (considering) moving to */ |
| 990 | coordxy nx, ny; /* temporary coordinates */ |
| 991 | xint16 cnt, uncursedcnt, chcnt; |
| 992 | int chi = -1, nidist, ndist; |
| 993 | long allowflags; |
| 994 | struct mfndposdata mfp; |
| 995 | #define GDIST(x, y) (dist2(x, y, gg.gx, gg.gy)) |
| 996 | |
| 997 | /* |
| 998 | * Tame Angels have isminion set and an ispriest structure instead of |
| 999 | * an edog structure. Fortunately, guardian Angels need not worry |
| 1000 | * about mundane things like eating and fetching objects, and can |
| 1001 | * spend all their energy defending the player. (They are the only |
| 1002 | * monsters with other structures that can be tame.) |
| 1003 | */ |
| 1004 | if (!edog && !mtmp->isminion) { |
| 1005 | impossible("dog_move for non-pet?"); |
| 1006 | return MMOVE_NOTHING; |
| 1007 | } |
| 1008 | |
| 1009 | omx = mtmp->mx; |
| 1010 | omy = mtmp->my; |
| 1011 | if (edog && dog_hunger(mtmp, edog)) |
| 1012 | return MMOVE_DIED; /* starved */ |
| 1013 | |
| 1014 | udist = distu(omx, omy); |
| 1015 | /* Let steeds eat and maybe throw rider during Conflict */ |
| 1016 | if (mtmp == u.usteed) { |
| 1017 | if (Conflict && !resist_conflict(mtmp)) { |
| 1018 | dismount_steed(DISMOUNT_THROWN); |
| 1019 | return MMOVE_MOVED; |
| 1020 | } |
| 1021 | udist = 1; |
| 1022 | } else if (!udist) { |
| 1023 | /* maybe we tamed him while being swallowed --jgm */ |
| 1024 | return MMOVE_NOTHING; |
| 1025 | } |
| 1026 | |
| 1027 | nix = omx; /* set before newdogpos */ |
| 1028 | niy = omy; |
| 1029 | cursemsg[0] = FALSE; /* lint suppression */ |
| 1030 | |
| 1031 | if (edog) { |
| 1032 | j = dog_invent(mtmp, edog, udist); |
| 1033 | if (j == 2 || mon_offmap(mtmp)) |
no test coverage detected