Merge branch 'use_leash' of https://github.com/argrath/NetHack into NetHack-3.7

This commit is contained in:
nhmall
2024-11-03 09:16:09 -05:00

View File

@@ -13,6 +13,7 @@ staticfn void use_whistle(struct obj *);
staticfn void use_magic_whistle(struct obj *);
staticfn void magic_whistled(struct obj *);
staticfn int use_leash(struct obj *);
staticfn void use_leash_core(struct obj *, struct monst *, coord, int);
staticfn boolean mleashed_next2u(struct monst *);
staticfn int use_mirror(struct obj *);
staticfn void use_bell(struct obj **);
@@ -752,13 +753,11 @@ leashable(struct monst *mtmp)
&& (!nolimbs(mtmp->data) || has_head(mtmp->data)));
}
/* ARGSUSED */
staticfn int
use_leash(struct obj *obj)
{
coord cc;
struct monst *mtmp;
int spotmon;
if (u.uswallow) {
/* if the leash isn't in use, assume we're trying to leash
@@ -785,8 +784,8 @@ use_leash(struct obj *obj)
if (u_at(cc.x, cc.y)) {
if (u.usteed && u.dz > 0) {
mtmp = u.usteed;
spotmon = 1;
goto got_target;
use_leash_core(obj, mtmp, cc, 1);
return ECMD_TIME;
}
pline("Leash yourself? Very funny...");
return ECMD_OK;
@@ -802,9 +801,13 @@ use_leash(struct obj *obj)
return ECMD_TIME;
}
spotmon = canspotmon(mtmp);
got_target:
use_leash_core(obj, mtmp, cc, canspotmon(mtmp));
return ECMD_TIME;
}
staticfn void
use_leash_core(struct obj *obj, struct monst *mtmp, coord cc, int spotmon)
{
if (!spotmon && !glyph_is_invisible(levl[cc.x][cc.y].glyph)) {
/* for the unleash case, we don't verify whether this unseen
monster is the creature attached to the current leash */
@@ -858,7 +861,6 @@ use_leash(struct obj *obj)
spotmon ? "your " : "", l_monnam(mtmp));
}
}
return ECMD_TIME;
}
/* assuming mtmp->mleashed has been checked */