| 928 | } |
| 929 | |
| 930 | void |
| 931 | check_leash(coordxy x, coordxy y) |
| 932 | { |
| 933 | struct obj *otmp; |
| 934 | struct monst *mtmp; |
| 935 | |
| 936 | for (otmp = gi.invent; otmp; otmp = otmp->nobj) { |
| 937 | if (otmp->otyp != LEASH || otmp->leashmon == 0) |
| 938 | continue; |
| 939 | mtmp = find_mid(otmp->leashmon, FM_FMON); |
| 940 | if (!mtmp) { |
| 941 | impossible("leash in use isn't attached to anything?"); |
| 942 | otmp->leashmon = 0; |
| 943 | continue; |
| 944 | } |
| 945 | if (dist2(u.ux, u.uy, mtmp->mx, mtmp->my) |
| 946 | > dist2(x, y, mtmp->mx, mtmp->my)) { |
| 947 | if (!um_dist(mtmp->mx, mtmp->my, 3)) { |
| 948 | ; /* still close enough */ |
| 949 | } else if (otmp->cursed && !breathless(mtmp->data)) { |
| 950 | if (um_dist(mtmp->mx, mtmp->my, 5) |
| 951 | || (mtmp->mhp -= rnd(2)) <= 0) { |
| 952 | long save_pacifism = u.uconduct.killer; |
| 953 | |
| 954 | Your("leash chokes %s to death!", mon_nam(mtmp)); |
| 955 | /* hero might not have intended to kill pet, but |
| 956 | that's the result of his actions; gain experience, |
| 957 | lose pacifism, take alignment and luck hit, make |
| 958 | corpse less likely to remain tame after revival */ |
| 959 | xkilled(mtmp, XKILL_NOMSG); |
| 960 | /* life-saving doesn't ordinarily reset this */ |
| 961 | if (!DEADMONSTER(mtmp)) |
| 962 | u.uconduct.killer = save_pacifism; |
| 963 | } else { |
| 964 | pline_mon(mtmp, "%s is choked by the leash!", |
| 965 | Monnam(mtmp)); |
| 966 | /* tameness eventually drops to 1 here (never 0) */ |
| 967 | if (mtmp->mtame && rn2(mtmp->mtame)) |
| 968 | mtmp->mtame--; |
| 969 | } |
| 970 | } else { |
| 971 | if (um_dist(mtmp->mx, mtmp->my, 5)) { |
| 972 | pline("%s leash snaps loose!", s_suffix(Monnam(mtmp))); |
| 973 | m_unleash(mtmp, FALSE); |
| 974 | } else { |
| 975 | You("pull on the leash."); |
| 976 | if (mtmp->data->msound != MS_SILENT) |
| 977 | switch (rn2(3)) { |
| 978 | case 0: |
| 979 | growl(mtmp); |
| 980 | break; |
| 981 | case 1: |
| 982 | yelp(mtmp); |
| 983 | break; |
| 984 | default: |
| 985 | whimper(mtmp); |
| 986 | break; |
| 987 | } |