MCPcopy Index your code
hub / github.com/NetHack/NetHack / mhidden_description

Function mhidden_description

src/pager.c:185–280  ·  view source on GitHub ↗

describe a hidden monster; used for look_at during extended monster detection and for probing; also when looking at self and camera feedback */

Source from the content-addressed store, hash-verified

183/* describe a hidden monster; used for look_at during extended monster
184 detection and for probing; also when looking at self and camera feedback */
185void
186mhidden_description(
187 struct monst *mon, /* hidden monster to describe */
188 unsigned mhid_flags, /* controls optional aspects of description */
189 char *outbuf) /* output buffer */
190{
191 struct obj *otmp;
192 const char *what;
193 NhRegion *reg;
194 size_t buflen;
195 boolean incl_prefix = (mhid_flags & MHID_PREFIX) != 0,
196 incl_article = (mhid_flags & MHID_ARTICLE) != 0,
197 show_altmon = (mhid_flags & MHID_ALTMON) != 0,
198 force_region = (mhid_flags & MHID_REGION) != 0;
199 boolean fakeobj, isyou = (mon == &gy.youmonst);
200 coordxy x = isyou ? u.ux : mon->mx, y = isyou ? u.uy : mon->my;
201 int glyph = (svl.level.flags.hero_memory && !isyou) ? levl[x][y].glyph
202 : glyph_at(x, y);
203
204 *outbuf = '\0';
205 if (M_AP_TYPE(mon) == M_AP_FURNITURE
206 || M_AP_TYPE(mon) == M_AP_OBJECT) {
207 if (incl_prefix)
208 Strcpy(outbuf, ", mimicking ");
209 if (M_AP_TYPE(mon) == M_AP_FURNITURE) {
210 what = defsyms[mon->mappearance].explanation;
211 if (incl_article)
212 what = an(what);
213 Strcat(outbuf, what);
214 } else if (M_AP_TYPE(mon) == M_AP_OBJECT
215 /* remembered glyph, not glyph_at() which is 'mon' */
216 && glyph_is_object(glyph)) {
217 objfrommap:
218 otmp = (struct obj *) 0;
219 fakeobj = object_from_map(glyph, x, y, &otmp);
220 what = (otmp && otmp->otyp != STRANGE_OBJECT)
221 ? simpleonames(otmp)
222 : obj_descr[STRANGE_OBJECT].oc_name;
223 if (incl_article && (!otmp || otmp->quan == 1L))
224 what = an(what);
225 Strcat(outbuf, what);
226
227 if (fakeobj && otmp) {
228 otmp->where = OBJ_FREE; /* object_from_map set to OBJ_FLOOR */
229 dealloc_obj(otmp); /* has no contents */
230 }
231 } else {
232 Strcat(outbuf, something);
233 }
234 } else if (M_AP_TYPE(mon) == M_AP_MONSTER) {
235 if (show_altmon) {
236 if (incl_prefix)
237 Strcat(outbuf, ", masquerading as ");
238 what = pmname(&mons[mon->mappearance], Mgender(mon));
239 if (incl_prefix)
240 what = an(what);
241 Strcat(outbuf, what);
242 }

Callers 5

flash_hits_monFunction · 0.85
makemonFunction · 0.85
self_lookatFunction · 0.85
look_at_monsterFunction · 0.85
mstatuslineFunction · 0.85

Calls 12

glyph_atFunction · 0.85
anFunction · 0.85
object_from_mapFunction · 0.85
simpleonamesFunction · 0.85
dealloc_objFunction · 0.85
pmnameFunction · 0.85
MgenderFunction · 0.85
eosFunction · 0.85
surfaceFunction · 0.85
is_poolFunction · 0.85
visible_region_atFunction · 0.85
glyph_to_cmapFunction · 0.85

Tested by

no test coverage detected