1 /* $NetBSD: hack.pri.c,v 1.8 2003/04/02 18:36:39 jsm Exp $ */
4 * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
12 * - Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
15 * - Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * - Neither the name of the Stichting Centrum voor Wiskunde en
20 * Informatica, nor the names of its contributors may be used to endorse or
21 * promote products derived from this software without specific prior
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
25 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
27 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
28 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 * Copyright (c) 1982 Jay Fenlason <hack@gnu.org>
39 * All rights reserved.
41 * Redistribution and use in source and binary forms, with or without
42 * modification, are permitted provided that the following conditions
44 * 1. Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer.
46 * 2. Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in the
48 * documentation and/or other materials provided with the distribution.
49 * 3. The name of the author may not be used to endorse or promote products
50 * derived from this software without specific prior written permission.
52 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
53 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
54 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
55 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
56 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
57 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
58 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
59 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
60 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
61 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64 #include <sys/cdefs.h>
66 __RCSID("$NetBSD: hack.pri.c,v 1.8 2003/04/02 18:36:39 jsm Exp $");
71 xchar scrlx
, scrhx
, scrly
, scrhy
; /* corners of new area on
81 curs(u
.ux
- 1, u
.uy
+ 1);
82 fputs("/-\\", stdout
);
84 curs(u
.ux
- 1, u
.uy
+ 2);
87 curs(u
.ux
- 1, u
.uy
+ 3);
88 fputs("\\-/", stdout
);
100 panic(const char *fmt
, ...)
106 exit(1); /* avoid loops - this should never happen */
108 puts(" Suddenly, the dungeon collapses.");
109 fputs(" ERROR: ", stdout
);
115 abort(); /* generate core dump */
118 more(); /* contains a fflush() */
126 struct rm
*crm
= &levl
[x
][y
];
128 if (x
< 0 || x
> COLNO
- 1 || y
< 0 || y
> ROWNO
- 1) {
129 impossible("atl(%d,%d,%c)", x
, y
, ch
);
132 if (crm
->seen
&& crm
->scrsym
== ch
)
154 * call: (x,y) - display (-1,0) - close (leave last symbol) (-1,-1)- close
155 * (undo last symbol) (-1,let)-open: initialize symbol (-2,let)-change let
162 static schar prevx
, prevy
;
164 if ((int) x
== -2) { /* change let call */
168 if ((int) x
== -1 && (int) y
>= 0) { /* open or close call */
173 if (prevx
>= 0 && cansee(prevx
, prevy
)) {
175 prl(prevx
, prevy
); /* in case there was a monster */
176 at(prevx
, prevy
, levl
[prevx
][prevy
].scrsym
);
178 if (x
>= 0) { /* normal call */
183 } else { /* close call */
189 /* like the previous, but the symbols are first erased on completion */
196 static coord tc
[COLNO
]; /* but watch reflecting beams! */
199 if (y
> 0) { /* open call */
204 /* close call (do not distinguish y==0 and y==-1) */
209 at(xx
, yy
, levl
[xx
][yy
].scrsym
);
211 cnt
= let
= 0; /* superfluous */
214 if ((int) x
== -2) { /* change let call */
226 panic("Tmp_at overflow?");
227 levl
[x
][y
].new = 0; /* prevent pline-nscr erasing --- */
234 error("Hack needs a screen of size at least %d by %d.\n",
244 /* if xchar is unsigned, lint will complain about if(x < 0) */
245 if (x
< 0 || x
> COLNO
- 1 || y
< 0 || y
> ROWNO
- 1) {
246 impossible("At gets 0%o at %d %d.", ch
, x
, y
);
251 impossible("At gets null at %d %d.", x
, y
);
264 at(u
.ux
, u
.uy
, u
.usym
);
288 * Some ridiculous code to get display of @ and monsters (almost)
292 levl
[(u
.udisx
= u
.ux
)][(u
.udisy
= u
.uy
)].scrsym
= u
.usym
;
293 levl
[u
.udisx
][u
.udisy
].seen
= 1;
298 seemons(); /* reset old positions */
299 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
301 seemons(); /* force new positions to be shown */
303 * This nonsense should disappear soon
304 * ---------------------------------
307 for (y
= 0; y
< ROWNO
; y
++)
308 for (x
= 0; x
< COLNO
; x
++)
309 if ((room
= &levl
[x
][y
])->new) {
311 at(x
, y
, room
->scrsym
);
312 } else if (room
->seen
)
313 at(x
, y
, room
->scrsym
);
329 if (u
.uswallow
) { /* Can be done more efficiently */
333 seemons(); /* reset old positions */
334 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
335 if (mtmp
->mx
>= xmin
&& mtmp
->my
< ymax
)
337 seemons(); /* force new positions to be shown */
339 for (y
= 0; y
< ymax
; y
++) {
345 for (x
= xmin
; x
< COLNO
; x
++) {
346 if ((room
= &levl
[x
][y
])->new) {
348 at(x
, y
, room
->scrsym
);
349 } else if (room
->seen
)
350 at(x
, y
, room
->scrsym
);
356 if (ymax
> ROWNO
+ 1 && CD
) {
366 curs(u
.ux
, u
.uy
+ 2);
372 if (u
.udispl
&& (Invisible
|| u
.udisx
!= u
.ux
|| u
.udisy
!= u
.uy
))
373 /* if(! levl[u.udisx][u.udisy].new) */
374 if (!vism_at(u
.udisx
, u
.udisy
))
375 newsym(u
.udisx
, u
.udisy
);
379 } else if (!u
.udispl
|| u
.udisx
!= u
.ux
|| u
.udisy
!= u
.uy
) {
380 atl(u
.ux
, u
.uy
, u
.usym
);
385 levl
[u
.ux
][u
.uy
].seen
= 1;
389 #include "def.wseg.h"
392 /* print a position that is visible for @ */
400 if (x
== u
.ux
&& y
== u
.uy
&& (!Invisible
)) {
408 (IS_ROCK(room
->typ
) && levl
[u
.ux
][u
.uy
].typ
== CORR
))
410 if ((mtmp
= m_at(x
, y
)) && !mtmp
->mhide
&&
411 (!mtmp
->minvis
|| See_invisible
)) {
418 } else if ((otmp
= o_at(x
, y
)) && room
->typ
!= POOL
)
419 atl(x
, y
, otmp
->olet
);
420 else if (mtmp
&& (!mtmp
->minvis
|| See_invisible
)) {
421 /* must be a hiding monster, but not hiding right now */
422 /* assume for the moment that long worms do not hide */
424 } else if (g_at(x
, y
) && room
->typ
!= POOL
)
426 else if (!room
->seen
|| room
->scrsym
== ' ') {
427 room
->new = room
->seen
= 1;
446 else if (room
->typ
== POOL
)
448 else if (!Blind
&& (otmp
= o_at(x
, y
)))
450 else if (!Blind
&& g_at(x
, y
))
452 else if (x
== xupstair
&& y
== yupstair
)
454 else if (x
== xdnstair
&& y
== ydnstair
)
456 else if ((ttmp
= t_at(x
, y
)) && ttmp
->tseen
)
462 tmp
= room
->scrsym
; /* %% wrong after killing
479 if (room
->lit
|| cansee(x
, y
) || Blind
)
499 atl(x
, y
, news0(x
, y
));
502 /* used with wand of digging (or pick-axe): fill scrsym and force display */
503 /* also when a POOL evaporates */
511 if (!vism_at(x
, y
)) {
513 newscrsym
= news0(x
, y
);
514 if (room
->scrsym
!= newscrsym
) {
515 room
->scrsym
= newscrsym
;
530 if (room
->scrsym
== '.' && !room
->lit
&& !Blind
) {
544 prl(x
- (2 * u
.dx
), y
);
548 prl(x
, y
- (2 * u
.dy
));
568 nosee(x
, u
.uy
- u
.dy
);
570 nosee(u
.ux
- u
.dx
, y
);
591 return ((x
== u
.ux
&& y
== u
.uy
&& !Invisible
)
594 ? ((Blind
&& Telepat
) || canseemon(mtmp
)) :
603 int show
= (!obj
->oinvis
|| See_invisible
) &&
604 cansee(obj
->ox
, obj
->oy
);
606 if (obj
->odx
!= obj
->ox
|| obj
->ody
!= obj
->oy
|| !show
)
607 if (!vism_at(obj
->odx
, obj
->ody
)) {
608 newsym(obj
->odx
, obj
->ody
);
612 if (show
&& !vism_at(obj
->ox
, obj
->oy
)) {
613 atl(obj
->ox
, obj
->oy
, obj
->olet
);
626 * if(obj->odispl){ if(!vism_at(obj->odx, obj->ody)) newsym(obj->odx,
627 * obj->ody); obj->odispl = 0; }
629 if (!vism_at(obj
->ox
, obj
->oy
))
630 newsym(obj
->ox
, obj
->oy
);
636 struct obj
*obj
, *obj2
;
637 for (obj
= fobj
; obj
; obj
= obj2
) {
639 if (obj
->olet
== FOOD_SYM
&& obj
->otyp
>= CORPSE
640 && obj
->age
+ 250 < moves
)
643 for (obj
= invent
; obj
; obj
= obj2
) {
645 if (obj
->olet
== FOOD_SYM
&& obj
->otyp
>= CORPSE
646 && obj
->age
+ 250 < moves
)
655 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
) {
656 if (mtmp
->data
->mlet
== ';')
657 mtmp
->minvis
= (u
.ustuck
!= mtmp
&&
658 levl
[mtmp
->mx
][mtmp
->my
].typ
== POOL
);
662 wormsee(mtmp
->wormno
);
671 int show
= (Blind
&& Telepat
) || canseemon(mon
);
673 if (mon
->mdx
!= mon
->mx
|| mon
->mdy
!= mon
->my
|| !show
)
676 if (show
&& !mon
->mdispl
) {
677 atl(mon
->mx
, mon
->my
,
679 || u
.uprops
[PROP(RIN_PROTECTION_FROM_SHAPE_CHANGERS
)].p_flgs
680 ) ? mon
->data
->mlet
: mon
->mappearance
);
692 newsym(mon
->mdx
, mon
->mdy
);
703 if (u
.uswallow
|| u
.ux
== FAR
|| flags
.nscrinh
)
706 for (y
= scrly
; y
<= scrhy
; y
++)
707 for (x
= scrlx
; x
<= scrhx
; x
++)
708 if ((room
= &levl
[x
][y
])->new) {
710 at(x
, y
, room
->scrsym
);
717 /* 100 suffices for bot(); no relation with COLNO */
718 char oldbot
[100], newbot
[100];
723 if (lth
< sizeof(oldbot
)) {
732 char *ob
= oldbot
, *nb
= newbot
;
736 flags
.botl
= flags
.botlx
= 0;
738 (void) sprintf(newbot
,
739 "Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Str ",
740 dlevel
, u
.ugold
, u
.uhp
, u
.uhpmax
, u
.uac
);
742 (void) sprintf(newbot
,
743 "Level %-2d Hp %3d(%d) Ac %-2d Str ",
744 dlevel
, u
.uhp
, u
.uhpmax
, u
.uac
);
745 #endif /* GOLD_ON_BOTL */
748 (void) strcat(newbot
, "18/**");
750 (void) sprintf(eos(newbot
), "18/%02d", u
.ustr
- 18);
752 (void) sprintf(eos(newbot
), "%-2d ", u
.ustr
);
754 (void) sprintf(eos(newbot
), " Exp %2d/%-5lu ", u
.ulevel
, u
.uexp
);
756 (void) sprintf(eos(newbot
), " Exp %2u ", u
.ulevel
);
757 #endif /* EXP_ON_BOTL */
758 (void) strcat(newbot
, hu_stat
[u
.uhs
]);
760 (void) sprintf(eos(newbot
), " %ld", moves
);
761 if (strlen(newbot
) >= COLNO
) {
765 if (*bp0
!= ' ' || bp0
[1] != ' ' || bp0
[2] != ' ')
769 for (i
= 1; i
< COLNO
; i
++) {
772 (void) putchar(*nb
? *nb
: ' ');
780 (void) strcpy(oldbot
, newbot
);
788 pline("Status of %s: ", monnam(mtmp
));
789 pline("Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Dam %d",
790 mtmp
->data
->mlevel
, mtmp
->mgold
, mtmp
->mhp
, mtmp
->mhpmax
,
791 mtmp
->data
->ac
, (mtmp
->data
->damn
+ 1) * (mtmp
->data
->damd
+ 1));
793 #endif /* WAN_PROBING */
798 if (flags
.toplin
== 1)