MCPcopy Create free account
hub / github.com/NetHack/NetHack / wiz_smell

Function wiz_smell

src/wizcmds.c:884–939  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

882
883/* #wizsmell command - test usmellmon(). */
884int
885wiz_smell(void)
886{
887 struct monst *mtmp; /* monster being smelled */
888 struct permonst *mptr;
889 int ans, glyph;
890 coord cc; /* screen pos to sniff */
891 boolean is_you;
892
893 cc.x = u.ux;
894 cc.y = u.uy;
895 if (!olfaction(gy.youmonst.data)) {
896 You("are incapable of detecting odors in your present form.");
897 return ECMD_OK;
898 }
899
900 You("can move the cursor to a monster that you want to smell.");
901 do {
902 pline("Pick a monster to smell.");
903 ans = getpos(&cc, TRUE, "a monster");
904 if (ans < 0 || cc.x < 0) {
905 return ECMD_CANCEL; /* done */
906 }
907 is_you = FALSE;
908 if (u_at(cc.x, cc.y)) {
909 if (u.usteed) {
910 mptr = u.usteed->data;
911 } else {
912 mptr = gy.youmonst.data;
913 is_you = TRUE;
914 }
915 } else if ((mtmp = m_at(cc.x, cc.y)) != (struct monst *) 0) {
916 mptr = mtmp->data;
917 } else {
918 mptr = (struct permonst *) 0;
919 }
920 /* Buglet: mapping or unmapping "remembered, unseen monster" should
921 cause time to elapse; since we're in wizmode, don't bother */
922 glyph = glyph_at(cc.x, cc.y);
923 /* Is it a monster? */
924 if (mptr) {
925 if (is_you)
926 You("surreptitiously sniff under your %s.", body_part(ARM));
927 if (!usmellmon(mptr))
928 pline("%s to not give off any smell.",
929 is_you ? "You seem" : "That monster seems");
930 if (!glyph_is_monster(glyph))
931 map_invisible(cc.x, cc.y);
932 } else {
933 You("don't smell any monster there.");
934 if (glyph_is_invisible(glyph))
935 unmap_invisible(cc.x, cc.y);
936 }
937 } while (TRUE);
938 return ECMD_OK;
939}
940
941RESTORE_WARNING_CONDEXPR_IS_CONSTANT

Callers

nothing calls this directly

Calls 9

olfactionFunction · 0.85
YouFunction · 0.85
getposFunction · 0.85
glyph_atFunction · 0.85
body_partFunction · 0.85
usmellmonFunction · 0.85
map_invisibleFunction · 0.85
unmap_invisibleFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected