]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.read.c
1 /* $NetBSD: hack.read.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.read.c,v 1.8 2003/04/02 18:36:39 jsm Exp $");
77 boolean confused
= (Confusion
!= 0);
78 boolean known
= FALSE
;
80 scroll
= getobj("?", "read");
83 if (!scroll
->dknown
&& Blind
) {
84 pline("Being blind, you cannot read the formula on the scroll.");
88 pline("As you pronounce the formula on it, the scroll disappears.");
90 pline("As you read the scroll, it disappears.");
92 pline("Being confused, you mispronounce the magic words ... ");
94 switch (scroll
->otyp
) {
97 readmail( /* scroll */ );
100 case SCR_ENCHANT_ARMOR
:
102 struct obj
*otmp
= some_armor();
104 strange_feeling(scroll
, "Your skin glows then fades.");
108 pline("Your %s glows silver for a moment.",
109 objects
[otmp
->otyp
].oc_name
);
113 if (otmp
->spe
> 3 && rn2(otmp
->spe
)) {
114 pline("Your %s glows violently green for a while, then evaporates.",
115 objects
[otmp
->otyp
].oc_name
);
119 pline("Your %s glows green for a moment.",
120 objects
[otmp
->otyp
].oc_name
);
125 case SCR_DESTROY_ARMOR
:
127 struct obj
*otmp
= some_armor();
129 strange_feeling(scroll
, "Your bones itch.");
132 pline("Your %s glows purple for a moment.",
133 objects
[otmp
->otyp
].oc_name
);
138 pline("Your armor turns to dust and falls to the floor!");
141 pline("Your helmet turns to dust and is blown away!");
144 pline("Your gloves vanish!");
148 strange_feeling(scroll
, "Your skin itches.");
152 case SCR_CONFUSE_MONSTER
:
154 pline("Your hands begin to glow purple.");
155 Confusion
+= rnd(100);
157 pline("Your hands begin to glow blue.");
161 case SCR_SCARE_MONSTER
:
166 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
167 if (cansee(mtmp
->mx
, mtmp
->my
)) {
169 mtmp
->mflee
= mtmp
->mfroz
=
177 pline("You hear sad wailing in the distance.");
179 pline("You hear maniacal laughter in the distance.");
183 case SCR_BLANK_PAPER
:
185 pline("You see strange patterns on this scroll.");
187 pline("This scroll seems to be blank.");
189 case SCR_REMOVE_CURSE
:
193 pline("You feel like you need some help.");
195 pline("You feel like someone is helping you.");
196 for (obj
= invent
; obj
; obj
= obj
->nobj
)
198 obj
->cursed
= confused
;
199 if (Punished
&& !confused
) {
203 free((char *) uchain
);
205 uball
->owornmask
&= ~W_BALL
;
206 uchain
= uball
= (struct obj
*) 0;
210 case SCR_CREATE_MONSTER
:
219 (void) makemon(confused
? PM_ACID_BLOB
:
220 (struct permonst
*) 0, u
.ux
, u
.uy
);
223 case SCR_ENCHANT_WEAPON
:
224 if (uwep
&& confused
) {
225 pline("Your %s glows silver for a moment.",
226 objects
[uwep
->otyp
].oc_name
);
228 } else if (!chwepon(scroll
, 1)) /* tests for !uwep */
231 case SCR_DAMAGE_WEAPON
:
232 if (uwep
&& confused
) {
233 pline("Your %s glows purple for a moment.",
234 objects
[uwep
->otyp
].oc_name
);
236 } else if (!chwepon(scroll
, -1)) /* tests for !uwep */
242 int bd
= confused
? 5 : 1;
245 for (i
= -bd
; i
<= bd
; i
++)
246 for (j
= -bd
; j
<= bd
; j
++)
247 if ((mtmp
= m_at(u
.ux
+ i
, u
.uy
+ j
)) != NULL
)
248 (void) tamedog(mtmp
, (struct obj
*) 0);
254 struct monst
*mtmp
, *mtmp2
;
256 pline("You have found a scroll of genocide!");
262 pline("What monster do you want to genocide (Type the letter)? ");
264 } while (strlen(buf
) != 1 || !monstersym(*buf
));
265 if (!strchr(fut_geno
, *buf
))
266 charcat(fut_geno
, *buf
);
267 if (!strchr(genocided
, *buf
))
268 charcat(genocided
, *buf
);
270 pline("Such monsters do not exist in this world.");
273 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp2
) {
275 if (mtmp
->data
->mlet
== *buf
)
278 pline("Wiped out all %c's.", *buf
);
279 if (*buf
== u
.usym
) {
280 killer
= "scroll of genocide";
290 case SCR_TELEPORTATION
:
295 int oux
= u
.ux
, ouy
= u
.uy
;
297 if (dist(oux
, ouy
) > 100)
300 int uroom
= inroom(u
.ux
, u
.uy
);
302 if (uroom
!= inroom(u
.ux
, u
.uy
))
307 case SCR_GOLD_DETECTION
:
309 * Unfortunately this code has become slightly less elegant,
310 * now that gold and traps no longer are of the same type.
316 strange_feeling(scroll
, "Your toes stop itching.");
319 for (ttmp
= ftrap
; ttmp
; ttmp
= ttmp
->ntrap
)
320 if (ttmp
->tx
!= u
.ux
|| ttmp
->ty
!= u
.uy
)
323 * only under me - no separate display
326 pline("Your toes itch!");
330 for (ttmp
= ftrap
; ttmp
; ttmp
= ttmp
->ntrap
)
331 at(ttmp
->tx
, ttmp
->ty
, '$');
333 pline("You feel very greedy!");
339 strange_feeling(scroll
, "You feel materially poor.");
343 for (gtmp
= fgold
; gtmp
; gtmp
= gtmp
->ngold
)
344 if (gtmp
->gx
!= u
.ux
|| gtmp
->gy
!= u
.uy
)
347 * only under me - no separate display
350 pline("You notice some gold between your feet.");
354 for (gtmp
= fgold
; gtmp
; gtmp
= gtmp
->ngold
)
355 at(gtmp
->gx
, gtmp
->gy
, '$');
357 pline("You feel very greedy, and sense gold!");
364 case SCR_FOOD_DETECTION
:
368 char foodsym
= confused
? POTION_SYM
: FOOD_SYM
;
370 for (obj
= fobj
; obj
; obj
= obj
->nobj
)
371 if (obj
->olet
== FOOD_SYM
) {
372 if (obj
->ox
== u
.ux
&& obj
->oy
== u
.uy
)
378 strange_feeling(scroll
, "Your nose twitches.");
382 pline("You smell %s close nearby.",
383 confused
? "something" : "food");
388 for (obj
= fobj
; obj
; obj
= obj
->nobj
)
389 if (obj
->olet
== foodsym
)
390 at(obj
->ox
, obj
->oy
, FOOD_SYM
);
392 pline("Your nose tingles and you smell %s!",
393 confused
? "something" : "food");
402 pline("You identify this as an identify scroll.");
404 pline("This is an identify scroll.");
406 objects
[SCR_IDENTIFY
].oc_name_known
= 1;
409 !ggetobj("identify", identify
, rn2(5) ? 1 : rn2(5))
413 case SCR_MAGIC_MAPPING
:
419 pline("On this scroll %s a map!",
420 confused
? "was" : "is");
421 for (zy
= 0; zy
< ROWNO
; zy
++)
422 for (zx
= 0; zx
< COLNO
; zx
++) {
423 if (confused
&& rn2(7))
425 lev
= &(levl
[zx
][zy
]);
426 if ((num
= lev
->typ
) == 0)
430 lev
->scrsym
= CORR_SYM
;
431 } else if (num
== SDOOR
) {
434 /* do sth in doors ? */
435 } else if (lev
->seen
)
441 lev
->seen
= lev
->new = 1;
442 if (lev
->scrsym
== ' ' || !lev
->scrsym
)
455 for (zx
= 0; zx
< COLNO
; zx
++)
456 for (zy
= 0; zy
< ROWNO
; zy
++)
457 if (!confused
|| rn2(7))
459 levl
[zx
][zy
].seen
= 0;
461 pline("Thinking of Maud you forget everything else.");
471 pline("The scroll catches fire and you burn your hands.");
472 losehp(1, "scroll of fire");
474 pline("The scroll erupts in a tower of flame!");
476 pline("You are uninjured.");
480 losehp(num
, "scroll of fire");
483 num
= (2 * num
+ 1) / 3;
484 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
) {
485 if (dist(mtmp
->mx
, mtmp
->my
) < 3) {
487 if (strchr("FY", mtmp
->data
->mlet
))
488 mtmp
->mhp
-= 3 * num
; /* this might well kill
492 break; /* primitive */
501 pline("You feel guilty.");
504 pline("You are being punished for your misbehaviour!");
506 pline("Your iron ball gets heavier.");
510 Punished
= INTRINSIC
;
511 setworn(mkobj_at(CHAIN_SYM
, u
.ux
, u
.uy
), W_CHAIN
);
512 setworn(mkobj_at(BALL_SYM
, u
.ux
, u
.uy
), W_BALL
);
513 uball
->spe
= 1; /* special ball (see save) */
516 impossible("What weird language is this written in? (%u)",
519 if (!objects
[scroll
->otyp
].oc_name_known
) {
520 if (known
&& !confused
) {
521 objects
[scroll
->otyp
].oc_name_known
= 1;
522 more_experienced(0, 10);
523 } else if (!objects
[scroll
->otyp
].oc_uname
)
531 identify(otmp
) /* also called by newmail() */
534 objects
[otmp
->otyp
].oc_name_known
= 1;
535 otmp
->known
= otmp
->dknown
= 1;
548 /* first produce the text (provided he is not blind) */
552 if (u
.uswallow
|| !xdnstair
|| levl
[u
.ux
][u
.uy
].typ
== CORR
||
553 !levl
[u
.ux
][u
.uy
].lit
) {
554 pline("It seems even darker in here than before.");
557 pline("It suddenly becomes dark in here.");
560 pline("%s's stomach is lit.", Monnam(u
.ustuck
));
564 pline("Nothing Happens.");
568 pline("The cave lights up around you, then fades.");
571 if (levl
[u
.ux
][u
.uy
].typ
== CORR
) {
572 pline("The corridor lights up around you, then fades.");
574 } else if (levl
[u
.ux
][u
.uy
].lit
) {
575 pline("The light here seems better now.");
578 pline("The room is lit.");
586 if (levl
[u
.ux
][u
.uy
].lit
== on
)
588 if (levl
[u
.ux
][u
.uy
].typ
== DOOR
) {
589 if (IS_ROOM(levl
[u
.ux
][u
.uy
+ 1].typ
))
591 else if (IS_ROOM(levl
[u
.ux
][u
.uy
- 1].typ
))
595 if (IS_ROOM(levl
[u
.ux
+ 1][u
.uy
].typ
))
597 else if (IS_ROOM(levl
[u
.ux
- 1][u
.uy
].typ
))
605 for (seelx
= u
.ux
; (num
= levl
[seelx
- 1][zy
].typ
) != CORR
&& num
!= 0;
607 for (seehx
= u
.ux
; (num
= levl
[seehx
+ 1][zy
].typ
) != CORR
&& num
!= 0;
609 for (seely
= u
.uy
; (num
= levl
[zx
][seely
- 1].typ
) != CORR
&& num
!= 0;
611 for (seehy
= u
.uy
; (num
= levl
[zx
][seehy
+ 1].typ
) != CORR
&& num
!= 0;
613 for (zy
= seely
; zy
<= seehy
; zy
++)
614 for (zx
= seelx
; zx
<= seehx
; zx
++) {
615 levl
[zx
][zy
].lit
= on
;
616 if (!Blind
&& dist(zx
, zy
) > 2) {
628 /* Test whether we may genocide all monsters with symbol ch */
630 monstersym(ch
) /* arnold@ucsfcgl */
633 const struct permonst
*mp
;
636 * can't genocide certain monsters
638 if (strchr("12 &:", ch
))
641 if (ch
== pm_eel
.mlet
)
643 for (mp
= mons
; mp
< &mons
[CMNUM
+ 2]; mp
++)