1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.pri.c - version 1.0.3 */
3 /* $FreeBSD: src/games/hack/hack.pri.c,v 1.5 1999/11/16 10:26:37 marcel Exp $ */
4 /* $DragonFly: src/games/hack/hack.pri.c,v 1.5 2006/08/21 19:45:32 pavalos Exp $ */
8 xchar scrlx
, scrhx
, scrly
, scrhy
; /* corners of new area on screen */
13 static void pobj(struct obj
*);
15 static void cornbot(int);
20 char ulook
[] = { "|@|" };
25 curs(u
.ux
- 1, u
.uy
+ 1);
26 fputs("/-\\", stdout
);
28 curs(u
.ux
- 1, u
.uy
+ 2);
31 curs(u
.ux
- 1, u
.uy
+ 3);
32 fputs("\\-/", stdout
);
43 panic(const char *str
, ...)
47 if (panicking
) /* avoid loops - this should never happen*/
53 puts(" Suddenly, the dungeon collapses.");
54 fputs(" ERROR: ", stdout
);
61 abort(); /* generate core dump */
64 more(); /* contains a fflush() */
69 atl(int x
, int y
, char ch
)
71 struct rm
*crm
= &levl
[x
][y
];
73 if (x
< 0 || x
> COLNO
- 1 || y
< 0 || y
> ROWNO
- 1) {
74 impossible("atl(%d,%d,%c)", x
, y
, ch
);
77 if (crm
->seen
&& crm
->scrsym
== ch
)
97 /* call: (x,y) - display
98 * (-1,0) - close (leave last symbol)
99 * (-1,-1)- close (undo last symbol)
100 * (-1,let)-open: initialize symbol
101 * (-2,let)-change let
105 tmp_at(schar x
, schar y
)
107 static schar prevx
, prevy
;
110 if ((int)x
== -2) { /* change let call */
114 if ((int)x
== -1 && (int)y
>= 0) { /* open or close call */
119 if (prevx
>= 0 && cansee(prevx
, prevy
)) {
121 prl(prevx
, prevy
); /* in case there was a monster */
122 at(prevx
, prevy
, levl
[prevx
][prevy
].scrsym
);
124 if (x
>= 0) { /* normal call */
129 } else { /* close call */
135 /* like the previous, but the symbols are first erased on completion */
137 Tmp_at(schar x
, schar y
)
141 static coord tc
[COLNO
]; /* but watch reflecting beams! */
145 if (y
> 0) { /* open call */
150 /* close call (do not distinguish y==0 and y==-1) */
155 at(xx
, yy
, levl
[xx
][yy
].scrsym
);
157 cnt
= let
= 0; /* superfluous */
160 if ((int)x
== -2) { /* change let call */
172 panic("Tmp_at overflow?");
173 levl
[x
][y
].new = 0; /* prevent pline-nscr erasing --- */
180 error("Hack needs a screen of size at least %d by %d.\n",
185 at(xchar x
, xchar y
, char ch
)
188 /* if xchar is unsigned, lint will complain about if (x < 0) */
189 if (x
< 0 || x
> COLNO
- 1 || y
< 0 || y
> ROWNO
- 1) {
190 impossible("At gets 0%o at %d %d.", ch
, x
, y
);
195 impossible("At gets null at %d %d.", x
, y
);
208 at(u
.ux
, u
.uy
, u
.usym
);
231 /* Some ridiculous code to get display of @ and monsters (almost) right */
233 levl
[(u
.udisx
= u
.ux
)][(u
.udisy
= u
.uy
)].scrsym
= u
.usym
;
234 levl
[u
.udisx
][u
.udisy
].seen
= 1;
239 seemons(); /* reset old positions */
240 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
242 seemons(); /* force new positions to be shown */
243 /* This nonsense should disappear soon --------------------------------- */
245 for (y
= 0; y
< ROWNO
; y
++)
246 for (x
= 0; x
< COLNO
; x
++)
247 if ((room
= &levl
[x
][y
])->new) {
249 at(x
, y
, room
->scrsym
);
250 } else if (room
->seen
)
251 at(x
, y
, room
->scrsym
);
260 docorner(int xmin
, int ymax
)
266 if (u
.uswallow
) { /* Can be done more efficiently */
270 seemons(); /* reset old positions */
271 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
272 if (mtmp
->mx
>= xmin
&& mtmp
->my
< ymax
)
274 seemons(); /* force new positions to be shown */
276 for (y
= 0; y
< ymax
; y
++) {
282 for (x
= xmin
; x
< COLNO
; x
++) {
283 if ((room
= &levl
[x
][y
])->new) {
285 at(x
, y
, room
->scrsym
);
286 } else if (room
->seen
)
287 at(x
, y
, room
->scrsym
);
293 if (ymax
> ROWNO
+ 1 && CD
) {
303 curs(u
.ux
, u
.uy
+ 2);
309 if (u
.udispl
&& (Invisible
|| u
.udisx
!= u
.ux
|| u
.udisy
!= u
.uy
))
310 if (!vism_at(u
.udisx
, u
.udisy
))
311 newsym(u
.udisx
, u
.udisy
);
315 } else if (!u
.udispl
|| u
.udisx
!= u
.ux
|| u
.udisy
!= u
.uy
) {
316 atl(u
.ux
, u
.uy
, u
.usym
);
321 levl
[u
.ux
][u
.uy
].seen
= 1;
325 extern struct wseg
*m_atseg
;
328 /* print a position that is visible for @ */
336 if (x
== u
.ux
&& y
== u
.uy
&& (!Invisible
)) {
344 (IS_ROCK(room
->typ
) && levl
[u
.ux
][u
.uy
].typ
== CORR
))
346 if ((mtmp
= m_at(x
, y
)) && !mtmp
->mhide
&&
347 (!mtmp
->minvis
|| See_invisible
)) {
354 } else if ((otmp
= o_at(x
, y
)) && room
->typ
!= POOL
)
355 atl(x
, y
, otmp
->olet
);
356 else if (mtmp
&& (!mtmp
->minvis
|| See_invisible
)) {
357 /* must be a hiding monster, but not hiding right now */
358 /* assume for the moment that long worms do not hide */
360 } else if (g_at(x
, y
) && room
->typ
!= POOL
)
362 else if (!room
->seen
|| room
->scrsym
== ' ') {
363 room
->new = room
->seen
= 1;
371 news0(xchar x
, xchar y
)
381 else if (room
->typ
== POOL
)
383 else if (!Blind
&& (otmp
= o_at(x
, y
)))
385 else if (!Blind
&& g_at(x
, y
))
387 else if (x
== xupstair
&& y
== yupstair
)
389 else if (x
== xdnstair
&& y
== ydnstair
)
391 else if ((ttmp
= t_at(x
, y
)) && ttmp
->tseen
)
397 tmp
= room
->scrsym
; /* %% wrong after killing mimic ! */
413 if (room
->lit
|| cansee(x
, y
) || Blind
)
427 atl(x
, y
, news0(x
, y
));
430 /* used with wand of digging (or pick-axe): fill scrsym and force display */
431 /* also when a POOL evaporates */
433 mnewsym(int x
, int y
)
438 if (!vism_at(x
, y
)) {
440 newscrsym
= news0(x
, y
);
441 if (room
->scrsym
!= newscrsym
) {
442 room
->scrsym
= newscrsym
;
456 if (room
->scrsym
== '.' && !room
->lit
&& !Blind
) {
469 prl(x
- (2 * u
.dx
), y
);
473 prl(x
, y
- (2 * u
.dy
));
492 nosee(x
, u
.uy
- u
.dy
);
494 nosee(u
.ux
- u
.dx
, y
);
510 vism_at(int x
, int y
)
514 return ((x
== u
.ux
&& y
== u
.uy
&& !Invisible
)
517 ? ((Blind
&& Telepat
) || canseemon(mtmp
)) :
523 pobj(struct obj
*obj
)
525 int show
= (!obj
->oinvis
|| See_invisible
) &&
526 cansee(obj
->ox
, obj
->oy
);
529 if (obj
->odx
!= obj
->ox
|| obj
->ody
!= obj
->oy
|| !show
)
530 if (!vism_at(obj
->odx
, obj
->ody
)) {
531 newsym(obj
->odx
, obj
->ody
);
535 if (show
&& !vism_at(obj
->ox
, obj
->oy
)) {
536 atl(obj
->ox
, obj
->oy
, obj
->olet
);
545 unpobj(struct obj
*obj
)
547 if (!vism_at(obj
->ox
, obj
->oy
))
548 newsym(obj
->ox
, obj
->oy
);
554 struct obj
*obj
, *obj2
;
556 for (obj
= fobj
; obj
; obj
= obj2
) {
558 if (obj
->olet
== FOOD_SYM
&& obj
->otyp
>= CORPSE
559 && obj
->age
+ 250 < moves
)
562 for (obj
= invent
; obj
; obj
= obj2
) {
564 if (obj
->olet
== FOOD_SYM
&& obj
->otyp
>= CORPSE
565 && obj
->age
+ 250 < moves
)
575 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
) {
576 if (mtmp
->data
->mlet
== ';')
577 mtmp
->minvis
= (u
.ustuck
!= mtmp
&&
578 levl
[mtmp
->mx
][mtmp
->my
].typ
== POOL
);
582 wormsee(mtmp
->wormno
);
588 pmon(struct monst
*mon
)
590 int show
= (Blind
&& Telepat
) || canseemon(mon
);
593 if (mon
->mdx
!= mon
->mx
|| mon
->mdy
!= mon
->my
|| !show
)
596 if (show
&& !mon
->mdispl
) {
597 atl(mon
->mx
, mon
->my
,
599 || u
.uprops
[PROP(RIN_PROTECTION_FROM_SHAPE_CHANGERS
)].p_flgs
600 ) ? mon
->data
->mlet
: mon
->mappearance
);
608 unpmon(struct monst
*mon
)
611 newsym(mon
->mdx
, mon
->mdy
);
622 if (u
.uswallow
|| u
.ux
== FAR
|| flags
.nscrinh
)
625 for (y
= scrly
; y
<= scrhy
; y
++)
626 for (x
= scrlx
; x
<= scrhx
; x
++)
627 if ((room
= &levl
[x
][y
])->new) {
629 at(x
, y
, room
->scrsym
);
636 /* 100 suffices for bot(); no relation with COLNO */
637 char oldbot
[100], newbot
[100];
642 if (lth
< (int)sizeof(oldbot
)) {
651 char *ob
= oldbot
, *nb
= newbot
;
656 flags
.botl
= flags
.botlx
= 0;
659 "Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Str ",
660 dlevel
, u
.ugold
, u
.uhp
, u
.uhpmax
, u
.uac
);
663 "Level %-2d Hp %3d(%d) Ac %-2d Str ",
664 dlevel
, u
.uhp
, u
.uhpmax
, u
.uac
);
665 #endif /* GOLD_ON_BOTL */
668 strcat(newbot
, "18/**");
670 sprintf(eos(newbot
), "18/%02d", u
.ustr
- 18);
672 sprintf(eos(newbot
), "%-2d ", u
.ustr
);
674 sprintf(eos(newbot
), " Exp %2d/%-5lu ", u
.ulevel
, u
.uexp
);
676 sprintf(eos(newbot
), " Exp %2u ", u
.ulevel
);
677 #endif /* EXP_ON_BOTL */
678 strcat(newbot
, hu_stat
[u
.uhs
]);
680 sprintf(eos(newbot
), " %ld", moves
);
681 if (strlen(newbot
) >= COLNO
) {
685 if (*bp0
!= ' ' || bp0
[1] != ' ' || bp0
[2] != ' ')
689 for (i
= 1; i
< COLNO
; i
++) {
692 putchar(*nb
? *nb
: ' ');
700 strcpy(oldbot
, newbot
);
705 mstatusline(struct monst
*mtmp
)
707 pline("Status of %s: ", monnam(mtmp
));
708 pline("Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Dam %d",
709 mtmp
->data
->mlevel
, mtmp
->mgold
, mtmp
->mhp
, mtmp
->mhpmax
,
710 mtmp
->data
->ac
, (mtmp
->data
->damn
+ 1) * (mtmp
->data
->damd
+ 1));
712 #endif /* WAN_PROBING */
717 if (flags
.toplin
== 1)