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

Function do_mgivenname

src/do_name.c:198–282  ·  view source on GitHub ↗

allow player to assign a name to some chosen monster */

Source from the content-addressed store, hash-verified

196
197/* allow player to assign a name to some chosen monster */
198staticfn void
199do_mgivenname(void)
200{
201 char buf[BUFSZ], monnambuf[BUFSZ], qbuf[QBUFSZ];
202 coord cc;
203 int cx, cy;
204 struct monst *mtmp = 0;
205 boolean do_swallow = FALSE;
206
207 if (Hallucination) {
208 You("would never recognize it anyway.");
209 return;
210 }
211 cc.x = u.ux;
212 cc.y = u.uy;
213 if (getpos(&cc, FALSE, "the monster you want to name") < 0
214 || !isok(cc.x, cc.y))
215 return;
216 cx = cc.x, cy = cc.y;
217
218 if (u_at(cx, cy)) {
219 if (u.usteed && canspotmon(u.usteed)) {
220 mtmp = u.usteed;
221 } else {
222 pline("This %s creature is called %s and cannot be renamed.",
223 beautiful(), svp.plname);
224 return;
225 }
226 } else
227 mtmp = m_at(cx, cy);
228
229 /* Allow you to name the monster that has swallowed you */
230 if (!mtmp && u.uswallow) {
231 int glyph = glyph_at(cx, cy);
232
233 if (glyph_is_swallow(glyph)) {
234 mtmp = u.ustuck;
235 do_swallow = TRUE;
236 }
237 }
238
239 if (!do_swallow && (!mtmp
240 || (!sensemon(mtmp)
241 && (!(cansee(cx, cy) || see_with_infrared(mtmp))
242 || mtmp->mundetected || M_AP_TYPE(mtmp) == M_AP_FURNITURE
243 || M_AP_TYPE(mtmp) == M_AP_OBJECT
244 || (mtmp->minvis && !See_invisible))))) {
245
246 pline("I see no monster there.");
247 return;
248 }
249 /* special case similar to the one in lookat() */
250 Sprintf(qbuf, "What do you want to call %s?",
251 distant_monnam(mtmp, ARTICLE_THE, monnambuf));
252 /* use getlin() to get a name string from the player */
253 if (!name_from_player(buf, qbuf,
254 has_mgivenname(mtmp) ? MGIVENNAME(mtmp) : NULL))
255 return;

Callers 1

docallcmdFunction · 0.85

Calls 15

YouFunction · 0.85
getposFunction · 0.85
isokFunction · 0.85
beautifulFunction · 0.85
glyph_atFunction · 0.85
sensemonFunction · 0.85
see_with_infraredFunction · 0.85
distant_monnamFunction · 0.85
name_from_playerFunction · 0.85
alreadynamedFunction · 0.85
upstartFunction · 0.85
verbalizeFunction · 0.85

Tested by

no test coverage detected