1 /* SCCS Id: @(#)pline.c 3.4 1999/11/28 */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
5 #define NEED_VARARGS /* Uses ... */ /* comment line for pre-compiled headers */
14 static boolean no_repeat = FALSE;
16 static char *FDECL(You_buf, (int));
19 /* Note that these declarations rely on knowledge of the internals
20 * of the variable argument handling stuff in "tradstdc.h"
23 #if defined(USE_STDARG) || defined(USE_VARARGS)
24 static void FDECL(vpline, (const char *, va_list));
27 pline VA_DECL(const char *, line)
29 VA_INIT(line, char *);
30 vpline(line, VA_ARGS);
36 vpline(const char *line, va_list the_args) {
39 vpline(line, the_args) const char *line; va_list the_args; {
42 #else /* USE_STDARG | USE_VARARG */
47 pline VA_DECL(const char *, line)
48 #endif /* USE_STDARG | USE_VARARG */
51 /* Do NOT use VA_START and VA_END in here... see above */
53 if (!line || !*line) return;
54 if (index(line, '%')) {
55 Vsprintf(pbuf,line,VA_ARGS);
58 if (!iflags.window_inited) {
63 if (no_repeat && !strcmp(line, toplines))
66 if (vision_full_recalc) vision_recalc(0);
67 if (u.ux) flush_screen(1); /* %% */
68 putstr(WIN_MESSAGE, 0, line);
73 Norep VA_DECL(const char *, line)
75 VA_INIT(line, const char *);
77 vpline(line, VA_ARGS);
83 /* work buffer for You(), &c and verbalize() */
84 static char *you_buf = 0;
85 static int you_buf_siz = 0;
91 if (siz > you_buf_siz) {
92 if (you_buf) free((genericptr_t) you_buf);
93 you_buf_siz = siz + 10;
94 you_buf = (char *) alloc((unsigned) you_buf_siz);
102 if (you_buf) free((genericptr_t) you_buf), you_buf = (char *)0;
106 /* `prefix' must be a string literal, not a pointer */
107 #define YouPrefix(pointer,prefix,text) \
108 Strcpy((pointer = You_buf((int)(strlen(text) + sizeof prefix))), prefix)
110 #define YouMessage(pointer,prefix,text) \
111 strcat((YouPrefix(pointer, prefix, text), pointer), text)
115 You VA_DECL(const char *, line)
118 VA_INIT(line, const char *);
119 vpline(YouMessage(tmp, "You ", line), VA_ARGS);
125 Your VA_DECL(const char *,line)
128 VA_INIT(line, const char *);
129 vpline(YouMessage(tmp, "Your ", line), VA_ARGS);
135 You_feel VA_DECL(const char *,line)
138 VA_INIT(line, const char *);
139 vpline(YouMessage(tmp, "You feel ", line), VA_ARGS);
146 You_cant VA_DECL(const char *,line)
149 VA_INIT(line, const char *);
150 vpline(YouMessage(tmp, "You can't ", line), VA_ARGS);
156 pline_The VA_DECL(const char *,line)
159 VA_INIT(line, const char *);
160 vpline(YouMessage(tmp, "The ", line), VA_ARGS);
166 There VA_DECL(const char *,line)
169 VA_INIT(line, const char *);
170 vpline(YouMessage(tmp, "There ", line), VA_ARGS);
176 You_hear VA_DECL(const char *,line)
179 VA_INIT(line, const char *);
181 YouPrefix(tmp, "You barely hear ", line);
183 YouPrefix(tmp, "You dream that you hear ", line);
185 YouPrefix(tmp, "You hear ", line);
186 vpline(strcat(tmp, line), VA_ARGS);
192 verbalize VA_DECL(const char *,line)
194 if (!flags.soundok) return;
196 VA_INIT(line, const char *);
197 tmp = You_buf((int)strlen(line) + sizeof "\"\"");
201 vpline(tmp, VA_ARGS);
206 /* Note that these declarations rely on knowledge of the internals
207 * of the variable argument handling stuff in "tradstdc.h"
210 #if defined(USE_STDARG) || defined(USE_VARARGS)
211 static void FDECL(vraw_printf,(const char *,va_list));
214 raw_printf VA_DECL(const char *, line)
216 VA_INIT(line, char *);
217 vraw_printf(line, VA_ARGS);
223 vraw_printf(const char *line, va_list the_args) {
226 vraw_printf(line, the_args) const char *line; va_list the_args; {
229 #else /* USE_STDARG | USE_VARARG */
232 raw_printf VA_DECL(const char *, line)
234 /* Do NOT use VA_START and VA_END in here... see above */
236 if(!index(line, '%'))
240 Vsprintf(pbuf,line,VA_ARGS);
248 impossible VA_DECL(const char *, s)
250 VA_INIT(s, const char *);
251 if (program_state.in_impossible)
252 panic("impossible called impossible");
253 program_state.in_impossible = 1;
256 Vsprintf(pbuf,s,VA_ARGS);
257 paniclog("impossible", pbuf);
260 pline("Program in disorder - perhaps you'd better #quit.");
261 program_state.in_impossible = 0;
269 switch ((int)alignment) {
270 case A_CHAOTIC: return "chaotic";
271 case A_NEUTRAL: return "neutral";
272 case A_LAWFUL: return "lawful";
273 case A_NONE: return "unaligned";
280 register struct monst *mtmp;
283 char info[BUFSZ], monnambuf[BUFSZ];
285 if (mtmp->ispriest || mtmp->data == &mons[PM_ALIGNED_PRIEST]
286 || mtmp->data == &mons[PM_ANGEL])
287 alignment = EPRI(mtmp)->shralign;
289 alignment = mtmp->data->maligntyp;
290 alignment = (alignment > 0) ? A_LAWFUL :
291 (alignment < 0) ? A_CHAOTIC :
295 if (mtmp->mtame) { Strcat(info, ", tame");
298 Sprintf(eos(info), " (%d", mtmp->mtame);
300 Sprintf(eos(info), "; hungry %ld; apport %d",
301 EDOG(mtmp)->hungrytime, EDOG(mtmp)->apport);
306 else if (mtmp->mpeaceful) Strcat(info, ", peaceful");
307 if (mtmp->meating) Strcat(info, ", eating");
308 if (mtmp->mcan) Strcat(info, ", cancelled");
309 if (mtmp->mconf) Strcat(info, ", confused");
310 if (mtmp->mblinded || !mtmp->mcansee)
311 Strcat(info, ", blind");
312 if (mtmp->mstun) Strcat(info, ", stunned");
313 if (mtmp->msleeping) Strcat(info, ", asleep");
314 #if 0 /* unfortunately mfrozen covers temporary sleep and being busy
315 (donning armor, for instance) as well as paralysis */
316 else if (mtmp->mfrozen) Strcat(info, ", paralyzed");
318 else if (mtmp->mfrozen || !mtmp->mcanmove)
319 Strcat(info, ", can't move");
321 /* [arbitrary reason why it isn't moving] */
322 else if (mtmp->mstrategy & STRAT_WAITMASK)
323 Strcat(info, ", meditating");
324 else if (mtmp->mflee) Strcat(info, ", scared");
325 if (mtmp->mtrapped) Strcat(info, ", trapped");
326 if (mtmp->mspeed) Strcat(info,
327 mtmp->mspeed == MFAST ? ", fast" :
328 mtmp->mspeed == MSLOW ? ", slow" :
330 if (mtmp->mundetected) Strcat(info, ", concealed");
331 if (mtmp->minvis) Strcat(info, ", invisible");
332 if (mtmp == u.ustuck) Strcat(info,
333 (sticks(youmonst.data)) ? ", held by you" :
334 u.uswallow ? (is_animal(u.ustuck->data) ?
339 if (mtmp == u.usteed) Strcat(info, ", carrying you");
342 /* avoid "Status of the invisible newt ..., invisible" */
343 /* and unlike a normal mon_nam, use "saddled" even if it has a name */
344 Strcpy(monnambuf, x_monnam(mtmp, ARTICLE_THE, (char *)0,
345 (SUPPRESS_IT|SUPPRESS_INVISIBLE), FALSE));
347 pline("Status of %s (%s): Level %d HP %d(%d) AC %d%s.",
349 align_str(alignment),
364 Strcat(info, ", dying from");
365 if (u.usick_type & SICK_VOMITABLE)
366 Strcat(info, " food poisoning");
367 if (u.usick_type & SICK_NONVOMITABLE) {
368 if (u.usick_type & SICK_VOMITABLE)
369 Strcat(info, " and");
370 Strcat(info, " illness");
373 if (Stoned) Strcat(info, ", solidifying");
374 if (Slimed) Strcat(info, ", becoming slimy");
375 if (Strangled) Strcat(info, ", being strangled");
376 if (Vomiting) Strcat(info, ", nauseated"); /* !"nauseous" */
377 if (Confusion) Strcat(info, ", confused");
379 Strcat(info, ", blind");
381 if ((long)u.ucreamed < Blinded || Blindfolded
382 || !haseyes(youmonst.data))
383 Strcat(info, ", cover");
384 Strcat(info, "ed by sticky goop");
385 } /* note: "goop" == "glop"; variation is intentional */
387 if (Stunned) Strcat(info, ", stunned");
392 const char *what = body_part(LEG);
393 if ((Wounded_legs & BOTH_SIDES) == BOTH_SIDES)
394 what = makeplural(what);
395 Sprintf(eos(info), ", injured %s", what);
397 if (Glib) Sprintf(eos(info), ", slippery %s",
398 makeplural(body_part(HAND)));
399 if (u.utrap) Strcat(info, ", trapped");
400 if (Fast) Strcat(info, Very_fast ?
401 ", very fast" : ", fast");
402 if (u.uundetected) Strcat(info, ", concealed");
403 if (Invis) Strcat(info, ", invisible");
405 if (sticks(youmonst.data))
406 Strcat(info, ", holding ");
408 Strcat(info, ", held by ");
409 Strcat(info, mon_nam(u.ustuck));
412 pline("Status of %s (%s%s): Level %d HP %d(%d) AC %d%s.",
414 (u.ualign.record >= 20) ? "piously " :
415 (u.ualign.record > 13) ? "devoutly " :
416 (u.ualign.record > 8) ? "fervently " :
417 (u.ualign.record > 3) ? "stridently " :
418 (u.ualign.record == 3) ? "" :
419 (u.ualign.record >= 1) ? "haltingly " :
420 (u.ualign.record == 0) ? "nominally " :
422 align_str(u.ualign.type),
423 Upolyd ? mons[u.umonnum].mlevel : u.ulevel,
424 Upolyd ? u.mh : u.uhp,
425 Upolyd ? u.mhmax : u.uhpmax,
434 Hallucination ? "Far out, man! You" : "Gee! All of a sudden, you",
435 See_invisible ? "can see right through yourself" :
436 "can't see yourself");