| 766 | } |
| 767 | |
| 768 | staticfn int |
| 769 | use_leash(struct obj *obj) |
| 770 | { |
| 771 | coord cc; |
| 772 | struct monst *mtmp; |
| 773 | |
| 774 | if (u.uswallow) { |
| 775 | /* if the leash isn't in use, assume we're trying to leash |
| 776 | the engulfer; if it is use, distinguish between removing |
| 777 | it from the engulfer versus from some other creature |
| 778 | (note: the two in-use cases can't actually occur; all |
| 779 | leashes are released when the hero gets engulfed) */ |
| 780 | You_cant((!obj->leashmon |
| 781 | ? "leash %s from inside." |
| 782 | : (obj->leashmon == (int) u.ustuck->m_id) |
| 783 | ? "unleash %s from inside." |
| 784 | : "unleash anything from inside %s."), |
| 785 | noit_mon_nam(u.ustuck)); |
| 786 | return ECMD_OK; |
| 787 | } |
| 788 | if (!obj->leashmon && number_leashed() >= MAXLEASHED) { |
| 789 | You("cannot leash any more pets."); |
| 790 | return ECMD_OK; |
| 791 | } |
| 792 | |
| 793 | if (!get_adjacent_loc((char *) 0, (char *) 0, u.ux, u.uy, &cc)) |
| 794 | return ECMD_OK; |
| 795 | |
| 796 | if (u_at(cc.x, cc.y)) { |
| 797 | if (u.usteed && u.dz > 0) { |
| 798 | mtmp = u.usteed; |
| 799 | use_leash_core(obj, mtmp, &cc, 1); |
| 800 | return ECMD_TIME; |
| 801 | } |
| 802 | pline("Leash yourself? Very funny..."); |
| 803 | return ECMD_OK; |
| 804 | } |
| 805 | |
| 806 | /* |
| 807 | * From here on out, return value is 1 == a move is used. |
| 808 | */ |
| 809 | |
| 810 | if (!(mtmp = m_at(cc.x, cc.y))) { |
| 811 | There("is no creature there."); |
| 812 | (void) unmap_invisible(cc.x, cc.y); |
| 813 | return ECMD_TIME; |
| 814 | } |
| 815 | |
| 816 | use_leash_core(obj, mtmp, &cc, canspotmon(mtmp)); |
| 817 | return ECMD_TIME; |
| 818 | } |
| 819 | |
| 820 | staticfn void |
| 821 | use_leash_core(struct obj *obj, struct monst *mtmp, coord *cc, int spotmon) |
no test coverage detected