From 8c831fcad074bfde7f488d222aa1ea01b9bb0f8e Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Mon, 28 Nov 2022 22:37:34 -0500 Subject: [PATCH 1/3] Add a funny message for smelling yourself I know this is inane, especially for a little-used debug-mode-only command, but I can't get it out of my head... The use of the actual monster data instead of the glyph as a proxy ought to make it somewhat more consistent as well (e.g. hallucination and 'showrace' won't affect the results), though I think that'd hardly be worth it were it not for the incredibly funny message. --- src/cmd.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/cmd.c b/src/cmd.c index 420be4efb..2ff419d48 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1916,14 +1916,14 @@ DISABLE_WARNING_CONDEXPR_IS_CONSTANT static int wiz_smell(void) { + struct monst *mtmp; /* monster being smelled */ + struct permonst *mptr; int ans = 0; - int mndx; /* monster index */ - coord cc; /* screen pos of unknown glyph */ - int glyph; /* glyph at selected position */ + coord cc; /* screen pos to sniff */ + boolean is_you; cc.x = u.ux; cc.y = u.uy; - mndx = 0; /* gcc -Wall lint */ if (!olfaction(gy.youmonst.data)) { You("are incapable of detecting odors in your present form."); return ECMD_OK; @@ -1936,18 +1936,29 @@ wiz_smell(void) if (ans < 0 || cc.x < 0) { return ECMD_CANCEL; /* done */ } - /* Convert the glyph at the selected position to a mndxbol. */ - glyph = glyph_at(cc.x, cc.y); - if (glyph_is_monster(glyph)) - mndx = glyph_to_mon(glyph); - else - mndx = 0; + is_you = FALSE; + if (u_at(cc.x, cc.y)) { + if (u.usteed) { + mptr = u.usteed->data; + } else { + mptr = gy.youmonst.data; + is_you = TRUE; + } + } else if ((mtmp = m_at(cc.x, cc.y)) && canspotmon(mtmp)) { + mptr = mtmp->data; + } else { + mptr = (struct permonst *) 0; + } /* Is it a monster? */ - if (mndx) { - if (!usmellmon(&mons[mndx])) - pline("That monster seems to give off no smell."); - } else - pline("That is not a monster."); + if (mptr) { + if (is_you) + You("surreptitiously sniff under your %s.", body_part(ARM)); + if (!usmellmon(mptr)) + pline("%s to give off no smell.", + is_you ? "You seem" : "That monster seems"); + } else { + You("see no monster there."); + } } while (TRUE); return ECMD_OK; } From be810f3edeb246189d77a8c6995828daa3c61712 Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Thu, 1 Dec 2022 17:56:00 -0500 Subject: [PATCH 2/3] Remove canspotmon() requirement from #wizsmell You can attempt to smell a monster at particular coordinates even if you can't see it. Revert the message for the 'can't find a monster there to smell' case to "That is not a monster", as it was before, since the change makes it so that you only reach that line if there genuinely is no monster there (previously it would be reached if there was a hidden or undetected monster on the specified spot). --- src/cmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd.c b/src/cmd.c index 2ff419d48..da40f94f4 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1944,7 +1944,7 @@ wiz_smell(void) mptr = gy.youmonst.data; is_you = TRUE; } - } else if ((mtmp = m_at(cc.x, cc.y)) && canspotmon(mtmp)) { + } else if ((mtmp = m_at(cc.x, cc.y)) != (struct monst *) 0) { mptr = mtmp->data; } else { mptr = (struct permonst *) 0; @@ -1957,7 +1957,7 @@ wiz_smell(void) pline("%s to give off no smell.", is_you ? "You seem" : "That monster seems"); } else { - You("see no monster there."); + pline("That is not a monster."); } } while (TRUE); return ECMD_OK; From dcd3fe843728af5d5d0276864a61a6f030cdbab4 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 31 Dec 2022 12:11:28 -0800 Subject: [PATCH 3/3] smelling an unseen monster puts 'I' on map --- src/cmd.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cmd.c b/src/cmd.c index da40f94f4..823f7490a 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1918,7 +1918,7 @@ wiz_smell(void) { struct monst *mtmp; /* monster being smelled */ struct permonst *mptr; - int ans = 0; + int ans, glyph; coord cc; /* screen pos to sniff */ boolean is_you; @@ -1949,15 +1949,22 @@ wiz_smell(void) } else { mptr = (struct permonst *) 0; } + /* Buglet: mapping or unmapping "remembered, unseen monster" should + cause time to elapse; since we're in wizmode, don't bother */ + glyph = glyph_at(cc.x, cc.y); /* Is it a monster? */ if (mptr) { if (is_you) You("surreptitiously sniff under your %s.", body_part(ARM)); if (!usmellmon(mptr)) - pline("%s to give off no smell.", + pline("%s to not give off any smell.", is_you ? "You seem" : "That monster seems"); + if (!glyph_is_monster(glyph)) + map_invisible(cc.x, cc.y); } else { - pline("That is not a monster."); + You("don't smell any monster there."); + if (glyph_is_invisible(glyph)) + unmap_invisible(cc.x, cc.y); } } while (TRUE); return ECMD_OK;