]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.read.c
2 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
6 static char rcsid
[] = "$NetBSD: hack.read.c,v 1.3 1995/03/23 08:31:22 cgd Exp $";
11 extern struct monst
*makemon();
12 extern struct obj
*mkobj_at();
16 register struct obj
*scroll
;
17 register boolean confused
= (Confusion
!= 0);
18 register boolean known
= FALSE
;
19 extern struct obj
*some_armor();
21 scroll
= getobj("?", "read");
22 if(!scroll
) return(0);
23 if(!scroll
->dknown
&& Blind
) {
24 pline("Being blind, you cannot read the formula on the scroll.");
28 pline("As you pronounce the formula on it, the scroll disappears.");
30 pline("As you read the scroll, it disappears.");
32 pline("Being confused, you mispronounce the magic words ... ");
34 switch(scroll
->otyp
) {
37 readmail(/* scroll */);
40 case SCR_ENCHANT_ARMOR
:
41 { register struct obj
*otmp
= some_armor();
43 strange_feeling(scroll
,"Your skin glows then fades.");
47 pline("Your %s glows silver for a moment.",
48 objects
[otmp
->otyp
].oc_name
);
52 if(otmp
->spe
> 3 && rn2(otmp
->spe
)) {
53 pline("Your %s glows violently green for a while, then evaporates.",
54 objects
[otmp
->otyp
].oc_name
);
58 pline("Your %s glows green for a moment.",
59 objects
[otmp
->otyp
].oc_name
);
64 case SCR_DESTROY_ARMOR
:
66 register struct obj
*otmp
= some_armor();
68 strange_feeling(scroll
,"Your bones itch.");
71 pline("Your %s glows purple for a moment.",
72 objects
[otmp
->otyp
].oc_name
);
77 pline("Your armor turns to dust and falls to the floor!");
80 pline("Your helmet turns to dust and is blown away!");
83 pline("Your gloves vanish!");
87 strange_feeling(scroll
,"Your skin itches.");
91 case SCR_CONFUSE_MONSTER
:
93 pline("Your hands begin to glow purple.");
94 Confusion
+= rnd(100);
96 pline("Your hands begin to glow blue.");
100 case SCR_SCARE_MONSTER
:
101 { register int ct
= 0;
102 register struct monst
*mtmp
;
104 for(mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
105 if(cansee(mtmp
->mx
,mtmp
->my
)) {
107 mtmp
->mflee
= mtmp
->mfroz
=
115 pline("You hear sad wailing in the distance.");
117 pline("You hear maniacal laughter in the distance.");
121 case SCR_BLANK_PAPER
:
123 pline("You see strange patterns on this scroll.");
125 pline("This scroll seems to be blank.");
127 case SCR_REMOVE_CURSE
:
128 { register struct obj
*obj
;
130 pline("You feel like you need some help.");
132 pline("You feel like someone is helping you.");
133 for(obj
= invent
; obj
; obj
= obj
->nobj
)
135 obj
->cursed
= confused
;
136 if(Punished
&& !confused
) {
140 free((char *) uchain
);
142 uball
->owornmask
&= ~W_BALL
;
143 uchain
= uball
= (struct obj
*) 0;
147 case SCR_CREATE_MONSTER
:
148 { register int cnt
= 1;
150 if(!rn2(73)) cnt
+= rnd(4);
151 if(confused
) cnt
+= 12;
153 (void) makemon(confused
? PM_ACID_BLOB
:
154 (struct permonst
*) 0, u
.ux
, u
.uy
);
157 case SCR_ENCHANT_WEAPON
:
158 if(uwep
&& confused
) {
159 pline("Your %s glows silver for a moment.",
160 objects
[uwep
->otyp
].oc_name
);
163 if(!chwepon(scroll
, 1)) /* tests for !uwep */
166 case SCR_DAMAGE_WEAPON
:
167 if(uwep
&& confused
) {
168 pline("Your %s glows purple for a moment.",
169 objects
[uwep
->otyp
].oc_name
);
172 if(!chwepon(scroll
, -1)) /* tests for !uwep */
177 register int bd
= confused
? 5 : 1;
178 register struct monst
*mtmp
;
180 for(i
= -bd
; i
<= bd
; i
++) for(j
= -bd
; j
<= bd
; j
++)
181 if(mtmp
= m_at(u
.ux
+i
, u
.uy
+j
))
182 (void) tamedog(mtmp
, (struct obj
*) 0);
186 { extern char genocided
[], fut_geno
[];
188 register struct monst
*mtmp
, *mtmp2
;
190 pline("You have found a scroll of genocide!");
195 pline("What monster do you want to genocide (Type the letter)? ");
197 } while(strlen(buf
) != 1 || !monstersym(*buf
));
198 if(!index(fut_geno
, *buf
))
199 charcat(fut_geno
, *buf
);
200 if(!index(genocided
, *buf
))
201 charcat(genocided
, *buf
);
203 pline("Such monsters do not exist in this world.");
206 for(mtmp
= fmon
; mtmp
; mtmp
= mtmp2
){
208 if(mtmp
->data
->mlet
== *buf
)
211 pline("Wiped out all %c's.", *buf
);
213 killer
= "scroll of genocide";
219 if(!Blind
) known
= TRUE
;
222 case SCR_TELEPORTATION
:
227 register int oux
= u
.ux
, ouy
= u
.uy
;
229 if(dist(oux
, ouy
) > 100) known
= TRUE
;
231 register int uroom
= inroom(u
.ux
, u
.uy
);
233 if(uroom
!= inroom(u
.ux
, u
.uy
)) known
= TRUE
;
237 case SCR_GOLD_DETECTION
:
238 /* Unfortunately this code has become slightly less elegant,
239 now that gold and traps no longer are of the same type. */
241 register struct trap
*ttmp
;
244 strange_feeling(scroll
, "Your toes stop itching.");
247 for(ttmp
= ftrap
; ttmp
; ttmp
= ttmp
->ntrap
)
248 if(ttmp
->tx
!= u
.ux
|| ttmp
->ty
!= u
.uy
)
250 /* only under me - no separate display required */
251 pline("Your toes itch!");
255 for(ttmp
= ftrap
; ttmp
; ttmp
= ttmp
->ntrap
)
256 at(ttmp
->tx
, ttmp
->ty
, '$');
258 pline("You feel very greedy!");
261 register struct gold
*gtmp
;
264 strange_feeling(scroll
, "You feel materially poor.");
268 for(gtmp
= fgold
; gtmp
; gtmp
= gtmp
->ngold
)
269 if(gtmp
->gx
!= u
.ux
|| gtmp
->gy
!= u
.uy
)
271 /* only under me - no separate display required */
272 pline("You notice some gold between your feet.");
276 for(gtmp
= fgold
; gtmp
; gtmp
= gtmp
->ngold
)
277 at(gtmp
->gx
, gtmp
->gy
, '$');
279 pline("You feel very greedy, and sense gold!");
286 case SCR_FOOD_DETECTION
:
287 { register ct
= 0, ctu
= 0;
288 register struct obj
*obj
;
289 register char foodsym
= confused
? POTION_SYM
: FOOD_SYM
;
291 for(obj
= fobj
; obj
; obj
= obj
->nobj
)
292 if(obj
->olet
== FOOD_SYM
) {
293 if(obj
->ox
== u
.ux
&& obj
->oy
== u
.uy
) ctu
++;
297 strange_feeling(scroll
,"Your nose twitches.");
301 pline("You smell %s close nearby.",
302 confused
? "something" : "food");
307 for(obj
= fobj
; obj
; obj
= obj
->nobj
)
308 if(obj
->olet
== foodsym
)
309 at(obj
->ox
, obj
->oy
, FOOD_SYM
);
311 pline("Your nose tingles and you smell %s!",
312 confused
? "something" : "food");
321 pline("You identify this as an identify scroll.");
323 pline("This is an identify scroll.");
325 objects
[SCR_IDENTIFY
].oc_name_known
= 1;
328 !ggetobj("identify", identify
, rn2(5) ? 1 : rn2(5))
332 case SCR_MAGIC_MAPPING
:
333 { register struct rm
*lev
;
334 register int num
, zx
, zy
;
337 pline("On this scroll %s a map!",
338 confused
? "was" : "is");
339 for(zy
= 0; zy
< ROWNO
; zy
++)
340 for(zx
= 0; zx
< COLNO
; zx
++) {
341 if(confused
&& rn2(7)) continue;
342 lev
= &(levl
[zx
][zy
]);
343 if((num
= lev
->typ
) == 0)
347 lev
->scrsym
= CORR_SYM
;
352 /* do sth in doors ? */
353 } else if(lev
->seen
) continue;
358 lev
->seen
= lev
->new = 1;
359 if(lev
->scrsym
== ' ' || !lev
->scrsym
)
368 { register int zx
, zy
;
371 for(zx
= 0; zx
< COLNO
; zx
++) for(zy
= 0; zy
< ROWNO
; zy
++)
372 if(!confused
|| rn2(7))
374 levl
[zx
][zy
].seen
= 0;
376 pline("Thinking of Maud you forget everything else.");
381 register struct monst
*mtmp
;
385 pline("The scroll catches fire and you burn your hands.");
386 losehp(1, "scroll of fire");
388 pline("The scroll erupts in a tower of flame!");
390 pline("You are uninjured.");
394 losehp(num
, "scroll of fire");
398 for(mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
) {
399 if(dist(mtmp
->mx
,mtmp
->my
) < 3) {
401 if(index("FY", mtmp
->data
->mlet
))
402 mtmp
->mhp
-= 3*num
; /* this might well kill 'F's */
405 break; /* primitive */
414 pline("You feel guilty.");
417 pline("You are being punished for your misbehaviour!");
419 pline("Your iron ball gets heavier.");
423 Punished
= INTRINSIC
;
424 setworn(mkobj_at(CHAIN_SYM
, u
.ux
, u
.uy
), W_CHAIN
);
425 setworn(mkobj_at(BALL_SYM
, u
.ux
, u
.uy
), W_BALL
);
426 uball
->spe
= 1; /* special ball (see save) */
429 impossible("What weird language is this written in? (%u)",
432 if(!objects
[scroll
->otyp
].oc_name_known
) {
433 if(known
&& !confused
) {
434 objects
[scroll
->otyp
].oc_name_known
= 1;
435 more_experienced(0,10);
436 } else if(!objects
[scroll
->otyp
].oc_uname
)
443 identify(otmp
) /* also called by newmail() */
444 register struct obj
*otmp
;
446 objects
[otmp
->otyp
].oc_name_known
= 1;
447 otmp
->known
= otmp
->dknown
= 1;
457 /* first produce the text (provided he is not blind) */
458 if(Blind
) goto do_it
;
460 if(u
.uswallow
|| !xdnstair
|| levl
[u
.ux
][u
.uy
].typ
== CORR
||
461 !levl
[u
.ux
][u
.uy
].lit
) {
462 pline("It seems even darker in here than before.");
465 pline("It suddenly becomes dark in here.");
468 pline("%s's stomach is lit.", Monnam(u
.ustuck
));
472 pline("Nothing Happens.");
476 pline("The cave lights up around you, then fades.");
479 if(levl
[u
.ux
][u
.uy
].typ
== CORR
) {
480 pline("The corridor lights up around you, then fades.");
482 } else if(levl
[u
.ux
][u
.uy
].lit
) {
483 pline("The light here seems better now.");
486 pline("The room is lit.");
494 if(levl
[u
.ux
][u
.uy
].lit
== on
)
496 if(levl
[u
.ux
][u
.uy
].typ
== DOOR
) {
497 if(IS_ROOM(levl
[u
.ux
][u
.uy
+1].typ
)) zy
= u
.uy
+1;
498 else if(IS_ROOM(levl
[u
.ux
][u
.uy
-1].typ
)) zy
= u
.uy
-1;
500 if(IS_ROOM(levl
[u
.ux
+1][u
.uy
].typ
)) zx
= u
.ux
+1;
501 else if(IS_ROOM(levl
[u
.ux
-1][u
.uy
].typ
)) zx
= u
.ux
-1;
507 for(seelx
= u
.ux
; (num
= levl
[seelx
-1][zy
].typ
) != CORR
&& num
!= 0;
509 for(seehx
= u
.ux
; (num
= levl
[seehx
+1][zy
].typ
) != CORR
&& num
!= 0;
511 for(seely
= u
.uy
; (num
= levl
[zx
][seely
-1].typ
) != CORR
&& num
!= 0;
513 for(seehy
= u
.uy
; (num
= levl
[zx
][seehy
+1].typ
) != CORR
&& num
!= 0;
515 for(zy
= seely
; zy
<= seehy
; zy
++)
516 for(zx
= seelx
; zx
<= seehx
; zx
++) {
517 levl
[zx
][zy
].lit
= on
;
518 if(!Blind
&& dist(zx
,zy
) > 2)
519 if(on
) prl(zx
,zy
); else nosee(zx
,zy
);
525 /* Test whether we may genocide all monsters with symbol ch */
526 monstersym(ch
) /* arnold@ucsfcgl */
529 register struct permonst
*mp
;
530 extern struct permonst pm_eel
;
533 * can't genocide certain monsters
535 if (index("12 &:", ch
))
538 if (ch
== pm_eel
.mlet
)
540 for (mp
= mons
; mp
< &mons
[CMNUM
+2]; mp
++)