1 /* $NetBSD: hack.pri.c,v 1.7 2002/05/26 00:12:12 wiz Exp $ */
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
9 __RCSID("$NetBSD: hack.pri.c,v 1.7 2002/05/26 00:12:12 wiz Exp $");
14 xchar scrlx
, scrhx
, scrly
, scrhy
; /* corners of new area on
24 curs(u
.ux
- 1, u
.uy
+ 1);
25 fputs("/-\\", stdout
);
27 curs(u
.ux
- 1, u
.uy
+ 2);
30 curs(u
.ux
- 1, u
.uy
+ 3);
31 fputs("\\-/", stdout
);
43 panic(const char *fmt
, ...)
49 exit(1); /* avoid loops - this should never happen */
51 puts(" Suddenly, the dungeon collapses.");
52 fputs(" ERROR: ", stdout
);
58 abort(); /* generate core dump */
61 more(); /* contains a fflush() */
69 struct rm
*crm
= &levl
[x
][y
];
71 if (x
< 0 || x
> COLNO
- 1 || y
< 0 || y
> ROWNO
- 1) {
72 impossible("atl(%d,%d,%c)", x
, y
, ch
);
75 if (crm
->seen
&& crm
->scrsym
== ch
)
97 * call: (x,y) - display (-1,0) - close (leave last symbol) (-1,-1)- close
98 * (undo last symbol) (-1,let)-open: initialize symbol (-2,let)-change let
105 static schar prevx
, prevy
;
107 if ((int) x
== -2) { /* change let call */
111 if ((int) x
== -1 && (int) y
>= 0) { /* open or close call */
116 if (prevx
>= 0 && cansee(prevx
, prevy
)) {
118 prl(prevx
, prevy
); /* in case there was a monster */
119 at(prevx
, prevy
, levl
[prevx
][prevy
].scrsym
);
121 if (x
>= 0) { /* normal call */
126 } else { /* close call */
132 /* like the previous, but the symbols are first erased on completion */
139 static coord tc
[COLNO
]; /* but watch reflecting beams! */
142 if (y
> 0) { /* open call */
147 /* close call (do not distinguish y==0 and y==-1) */
152 at(xx
, yy
, levl
[xx
][yy
].scrsym
);
154 cnt
= let
= 0; /* superfluous */
157 if ((int) x
== -2) { /* change let call */
169 panic("Tmp_at overflow?");
170 levl
[x
][y
].new = 0; /* prevent pline-nscr erasing --- */
177 error("Hack needs a screen of size at least %d by %d.\n",
187 /* if xchar is unsigned, lint will complain about if(x < 0) */
188 if (x
< 0 || x
> COLNO
- 1 || y
< 0 || y
> ROWNO
- 1) {
189 impossible("At gets 0%o at %d %d.", ch
, x
, y
);
194 impossible("At gets null at %d %d.", x
, y
);
207 at(u
.ux
, u
.uy
, u
.usym
);
231 * Some ridiculous code to get display of @ and monsters (almost)
235 levl
[(u
.udisx
= u
.ux
)][(u
.udisy
= u
.uy
)].scrsym
= u
.usym
;
236 levl
[u
.udisx
][u
.udisy
].seen
= 1;
241 seemons(); /* reset old positions */
242 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
244 seemons(); /* force new positions to be shown */
246 * This nonsense should disappear soon
247 * ---------------------------------
250 for (y
= 0; y
< ROWNO
; y
++)
251 for (x
= 0; x
< COLNO
; x
++)
252 if ((room
= &levl
[x
][y
])->new) {
254 at(x
, y
, room
->scrsym
);
255 } else if (room
->seen
)
256 at(x
, y
, room
->scrsym
);
272 if (u
.uswallow
) { /* Can be done more efficiently */
276 seemons(); /* reset old positions */
277 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
278 if (mtmp
->mx
>= xmin
&& mtmp
->my
< ymax
)
280 seemons(); /* force new positions to be shown */
282 for (y
= 0; y
< ymax
; y
++) {
288 for (x
= xmin
; x
< COLNO
; x
++) {
289 if ((room
= &levl
[x
][y
])->new) {
291 at(x
, y
, room
->scrsym
);
292 } else if (room
->seen
)
293 at(x
, y
, room
->scrsym
);
299 if (ymax
> ROWNO
+ 1 && CD
) {
309 curs(u
.ux
, u
.uy
+ 2);
315 if (u
.udispl
&& (Invisible
|| u
.udisx
!= u
.ux
|| u
.udisy
!= u
.uy
))
316 /* if(! levl[u.udisx][u.udisy].new) */
317 if (!vism_at(u
.udisx
, u
.udisy
))
318 newsym(u
.udisx
, u
.udisy
);
322 } else if (!u
.udispl
|| u
.udisx
!= u
.ux
|| u
.udisy
!= u
.uy
) {
323 atl(u
.ux
, u
.uy
, u
.usym
);
328 levl
[u
.ux
][u
.uy
].seen
= 1;
332 #include "def.wseg.h"
335 /* print a position that is visible for @ */
343 if (x
== u
.ux
&& y
== u
.uy
&& (!Invisible
)) {
351 (IS_ROCK(room
->typ
) && levl
[u
.ux
][u
.uy
].typ
== CORR
))
353 if ((mtmp
= m_at(x
, y
)) && !mtmp
->mhide
&&
354 (!mtmp
->minvis
|| See_invisible
)) {
361 } else if ((otmp
= o_at(x
, y
)) && room
->typ
!= POOL
)
362 atl(x
, y
, otmp
->olet
);
363 else if (mtmp
&& (!mtmp
->minvis
|| See_invisible
)) {
364 /* must be a hiding monster, but not hiding right now */
365 /* assume for the moment that long worms do not hide */
367 } else if (g_at(x
, y
) && room
->typ
!= POOL
)
369 else if (!room
->seen
|| room
->scrsym
== ' ') {
370 room
->new = room
->seen
= 1;
389 else if (room
->typ
== POOL
)
391 else if (!Blind
&& (otmp
= o_at(x
, y
)))
393 else if (!Blind
&& g_at(x
, y
))
395 else if (x
== xupstair
&& y
== yupstair
)
397 else if (x
== xdnstair
&& y
== ydnstair
)
399 else if ((ttmp
= t_at(x
, y
)) && ttmp
->tseen
)
405 tmp
= room
->scrsym
; /* %% wrong after killing
422 if (room
->lit
|| cansee(x
, y
) || Blind
)
442 atl(x
, y
, news0(x
, y
));
445 /* used with wand of digging (or pick-axe): fill scrsym and force display */
446 /* also when a POOL evaporates */
454 if (!vism_at(x
, y
)) {
456 newscrsym
= news0(x
, y
);
457 if (room
->scrsym
!= newscrsym
) {
458 room
->scrsym
= newscrsym
;
473 if (room
->scrsym
== '.' && !room
->lit
&& !Blind
) {
487 prl(x
- (2 * u
.dx
), y
);
491 prl(x
, y
- (2 * u
.dy
));
511 nosee(x
, u
.uy
- u
.dy
);
513 nosee(u
.ux
- u
.dx
, y
);
534 return ((x
== u
.ux
&& y
== u
.uy
&& !Invisible
)
537 ? ((Blind
&& Telepat
) || canseemon(mtmp
)) :
546 int show
= (!obj
->oinvis
|| See_invisible
) &&
547 cansee(obj
->ox
, obj
->oy
);
549 if (obj
->odx
!= obj
->ox
|| obj
->ody
!= obj
->oy
|| !show
)
550 if (!vism_at(obj
->odx
, obj
->ody
)) {
551 newsym(obj
->odx
, obj
->ody
);
555 if (show
&& !vism_at(obj
->ox
, obj
->oy
)) {
556 atl(obj
->ox
, obj
->oy
, obj
->olet
);
569 * if(obj->odispl){ if(!vism_at(obj->odx, obj->ody)) newsym(obj->odx,
570 * obj->ody); obj->odispl = 0; }
572 if (!vism_at(obj
->ox
, obj
->oy
))
573 newsym(obj
->ox
, obj
->oy
);
579 struct obj
*obj
, *obj2
;
580 for (obj
= fobj
; obj
; obj
= obj2
) {
582 if (obj
->olet
== FOOD_SYM
&& obj
->otyp
>= CORPSE
583 && obj
->age
+ 250 < moves
)
586 for (obj
= invent
; obj
; obj
= obj2
) {
588 if (obj
->olet
== FOOD_SYM
&& obj
->otyp
>= CORPSE
589 && obj
->age
+ 250 < moves
)
598 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
) {
599 if (mtmp
->data
->mlet
== ';')
600 mtmp
->minvis
= (u
.ustuck
!= mtmp
&&
601 levl
[mtmp
->mx
][mtmp
->my
].typ
== POOL
);
605 wormsee(mtmp
->wormno
);
614 int show
= (Blind
&& Telepat
) || canseemon(mon
);
616 if (mon
->mdx
!= mon
->mx
|| mon
->mdy
!= mon
->my
|| !show
)
619 if (show
&& !mon
->mdispl
) {
620 atl(mon
->mx
, mon
->my
,
622 || u
.uprops
[PROP(RIN_PROTECTION_FROM_SHAPE_CHANGERS
)].p_flgs
623 ) ? mon
->data
->mlet
: mon
->mappearance
);
635 newsym(mon
->mdx
, mon
->mdy
);
646 if (u
.uswallow
|| u
.ux
== FAR
|| flags
.nscrinh
)
649 for (y
= scrly
; y
<= scrhy
; y
++)
650 for (x
= scrlx
; x
<= scrhx
; x
++)
651 if ((room
= &levl
[x
][y
])->new) {
653 at(x
, y
, room
->scrsym
);
660 /* 100 suffices for bot(); no relation with COLNO */
661 char oldbot
[100], newbot
[100];
666 if (lth
< sizeof(oldbot
)) {
675 char *ob
= oldbot
, *nb
= newbot
;
679 flags
.botl
= flags
.botlx
= 0;
681 (void) sprintf(newbot
,
682 "Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Str ",
683 dlevel
, u
.ugold
, u
.uhp
, u
.uhpmax
, u
.uac
);
685 (void) sprintf(newbot
,
686 "Level %-2d Hp %3d(%d) Ac %-2d Str ",
687 dlevel
, u
.uhp
, u
.uhpmax
, u
.uac
);
688 #endif /* GOLD_ON_BOTL */
691 (void) strcat(newbot
, "18/**");
693 (void) sprintf(eos(newbot
), "18/%02d", u
.ustr
- 18);
695 (void) sprintf(eos(newbot
), "%-2d ", u
.ustr
);
697 (void) sprintf(eos(newbot
), " Exp %2d/%-5lu ", u
.ulevel
, u
.uexp
);
699 (void) sprintf(eos(newbot
), " Exp %2u ", u
.ulevel
);
700 #endif /* EXP_ON_BOTL */
701 (void) strcat(newbot
, hu_stat
[u
.uhs
]);
703 (void) sprintf(eos(newbot
), " %ld", moves
);
704 if (strlen(newbot
) >= COLNO
) {
708 if (*bp0
!= ' ' || bp0
[1] != ' ' || bp0
[2] != ' ')
712 for (i
= 1; i
< COLNO
; i
++) {
715 (void) putchar(*nb
? *nb
: ' ');
723 (void) strcpy(oldbot
, newbot
);
731 pline("Status of %s: ", monnam(mtmp
));
732 pline("Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Dam %d",
733 mtmp
->data
->mlevel
, mtmp
->mgold
, mtmp
->mhp
, mtmp
->mhpmax
,
734 mtmp
->data
->ac
, (mtmp
->data
->damn
+ 1) * (mtmp
->data
->damd
+ 1));
736 #endif /* WAN_PROBING */
741 if (flags
.toplin
== 1)