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