]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.read.c
1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.read.c - version 1.0.3 */
6 extern struct monst
*makemon();
7 extern struct obj
*mkobj_at();
11 register struct obj
*scroll
;
12 register boolean confused
= (Confusion
!= 0);
13 register boolean known
= FALSE
;
14 extern struct obj
*some_armor();
16 scroll
= getobj("?", "read");
17 if(!scroll
) return(0);
18 if(!scroll
->dknown
&& Blind
) {
19 pline("Being blind, you cannot read the formula on the scroll.");
23 pline("As you pronounce the formula on it, the scroll disappears.");
25 pline("As you read the scroll, it disappears.");
27 pline("Being confused, you mispronounce the magic words ... ");
29 switch(scroll
->otyp
) {
32 readmail(/* scroll */);
35 case SCR_ENCHANT_ARMOR
:
36 { register struct obj
*otmp
= some_armor();
38 strange_feeling(scroll
,"Your skin glows then fades.");
42 pline("Your %s glows silver for a moment.",
43 objects
[otmp
->otyp
].oc_name
);
47 if(otmp
->spe
> 3 && rn2(otmp
->spe
)) {
48 pline("Your %s glows violently green for a while, then evaporates.",
49 objects
[otmp
->otyp
].oc_name
);
53 pline("Your %s glows green for a moment.",
54 objects
[otmp
->otyp
].oc_name
);
59 case SCR_DESTROY_ARMOR
:
61 register struct obj
*otmp
= some_armor();
63 strange_feeling(scroll
,"Your bones itch.");
66 pline("Your %s glows purple for a moment.",
67 objects
[otmp
->otyp
].oc_name
);
72 pline("Your armor turns to dust and falls to the floor!");
75 pline("Your helmet turns to dust and is blown away!");
78 pline("Your gloves vanish!");
82 strange_feeling(scroll
,"Your skin itches.");
86 case SCR_CONFUSE_MONSTER
:
88 pline("Your hands begin to glow purple.");
89 Confusion
+= rnd(100);
91 pline("Your hands begin to glow blue.");
95 case SCR_SCARE_MONSTER
:
96 { register int ct
= 0;
97 register struct monst
*mtmp
;
99 for(mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
100 if(cansee(mtmp
->mx
,mtmp
->my
)) {
102 mtmp
->mflee
= mtmp
->mfroz
=
110 pline("You hear sad wailing in the distance.");
112 pline("You hear maniacal laughter in the distance.");
116 case SCR_BLANK_PAPER
:
118 pline("You see strange patterns on this scroll.");
120 pline("This scroll seems to be blank.");
122 case SCR_REMOVE_CURSE
:
123 { register struct obj
*obj
;
125 pline("You feel like you need some help.");
127 pline("You feel like someone is helping you.");
128 for(obj
= invent
; obj
; obj
= obj
->nobj
)
130 obj
->cursed
= confused
;
131 if(Punished
&& !confused
) {
135 free((char *) uchain
);
137 uball
->owornmask
&= ~W_BALL
;
138 uchain
= uball
= (struct obj
*) 0;
142 case SCR_CREATE_MONSTER
:
143 { register int cnt
= 1;
145 if(!rn2(73)) cnt
+= rnd(4);
146 if(confused
) cnt
+= 12;
148 (void) makemon(confused
? PM_ACID_BLOB
:
149 (struct permonst
*) 0, u
.ux
, u
.uy
);
152 case SCR_ENCHANT_WEAPON
:
153 if(uwep
&& confused
) {
154 pline("Your %s glows silver for a moment.",
155 objects
[uwep
->otyp
].oc_name
);
158 if(!chwepon(scroll
, 1)) /* tests for !uwep */
161 case SCR_DAMAGE_WEAPON
:
162 if(uwep
&& confused
) {
163 pline("Your %s glows purple for a moment.",
164 objects
[uwep
->otyp
].oc_name
);
167 if(!chwepon(scroll
, -1)) /* tests for !uwep */
172 register int bd
= confused
? 5 : 1;
173 register struct monst
*mtmp
;
175 for(i
= -bd
; i
<= bd
; i
++) for(j
= -bd
; j
<= bd
; j
++)
176 if(mtmp
= m_at(u
.ux
+i
, u
.uy
+j
))
177 (void) tamedog(mtmp
, (struct obj
*) 0);
181 { extern char genocided
[], fut_geno
[];
183 register struct monst
*mtmp
, *mtmp2
;
185 pline("You have found a scroll of genocide!");
190 pline("What monster do you want to genocide (Type the letter)? ");
192 } while(strlen(buf
) != 1 || !monstersym(*buf
));
193 if(!index(fut_geno
, *buf
))
194 charcat(fut_geno
, *buf
);
195 if(!index(genocided
, *buf
))
196 charcat(genocided
, *buf
);
198 pline("Such monsters do not exist in this world.");
201 for(mtmp
= fmon
; mtmp
; mtmp
= mtmp2
){
203 if(mtmp
->data
->mlet
== *buf
)
206 pline("Wiped out all %c's.", *buf
);
208 killer
= "scroll of genocide";
214 if(!Blind
) known
= TRUE
;
217 case SCR_TELEPORTATION
:
222 register int oux
= u
.ux
, ouy
= u
.uy
;
224 if(dist(oux
, ouy
) > 100) known
= TRUE
;
226 register int uroom
= inroom(u
.ux
, u
.uy
);
228 if(uroom
!= inroom(u
.ux
, u
.uy
)) known
= TRUE
;
232 case SCR_GOLD_DETECTION
:
233 /* Unfortunately this code has become slightly less elegant,
234 now that gold and traps no longer are of the same type. */
236 register struct trap
*ttmp
;
239 strange_feeling(scroll
, "Your toes stop itching.");
242 for(ttmp
= ftrap
; ttmp
; ttmp
= ttmp
->ntrap
)
243 if(ttmp
->tx
!= u
.ux
|| ttmp
->ty
!= u
.uy
)
245 /* only under me - no separate display required */
246 pline("Your toes itch!");
250 for(ttmp
= ftrap
; ttmp
; ttmp
= ttmp
->ntrap
)
251 at(ttmp
->tx
, ttmp
->ty
, '$');
253 pline("You feel very greedy!");
256 register struct gold
*gtmp
;
259 strange_feeling(scroll
, "You feel materially poor.");
263 for(gtmp
= fgold
; gtmp
; gtmp
= gtmp
->ngold
)
264 if(gtmp
->gx
!= u
.ux
|| gtmp
->gy
!= u
.uy
)
266 /* only under me - no separate display required */
267 pline("You notice some gold between your feet.");
271 for(gtmp
= fgold
; gtmp
; gtmp
= gtmp
->ngold
)
272 at(gtmp
->gx
, gtmp
->gy
, '$');
274 pline("You feel very greedy, and sense gold!");
281 case SCR_FOOD_DETECTION
:
282 { register ct
= 0, ctu
= 0;
283 register struct obj
*obj
;
284 register char foodsym
= confused
? POTION_SYM
: FOOD_SYM
;
286 for(obj
= fobj
; obj
; obj
= obj
->nobj
)
287 if(obj
->olet
== FOOD_SYM
) {
288 if(obj
->ox
== u
.ux
&& obj
->oy
== u
.uy
) ctu
++;
292 strange_feeling(scroll
,"Your nose twitches.");
296 pline("You smell %s close nearby.",
297 confused
? "something" : "food");
302 for(obj
= fobj
; obj
; obj
= obj
->nobj
)
303 if(obj
->olet
== foodsym
)
304 at(obj
->ox
, obj
->oy
, FOOD_SYM
);
306 pline("Your nose tingles and you smell %s!",
307 confused
? "something" : "food");
316 pline("You identify this as an identify scroll.");
318 pline("This is an identify scroll.");
320 objects
[SCR_IDENTIFY
].oc_name_known
= 1;
323 !ggetobj("identify", identify
, rn2(5) ? 1 : rn2(5))
327 case SCR_MAGIC_MAPPING
:
328 { register struct rm
*lev
;
329 register int num
, zx
, zy
;
332 pline("On this scroll %s a map!",
333 confused
? "was" : "is");
334 for(zy
= 0; zy
< ROWNO
; zy
++)
335 for(zx
= 0; zx
< COLNO
; zx
++) {
336 if(confused
&& rn2(7)) continue;
337 lev
= &(levl
[zx
][zy
]);
338 if((num
= lev
->typ
) == 0)
342 lev
->scrsym
= CORR_SYM
;
347 /* do sth in doors ? */
348 } else if(lev
->seen
) continue;
353 lev
->seen
= lev
->new = 1;
354 if(lev
->scrsym
== ' ' || !lev
->scrsym
)
363 { register int zx
, zy
;
366 for(zx
= 0; zx
< COLNO
; zx
++) for(zy
= 0; zy
< ROWNO
; zy
++)
367 if(!confused
|| rn2(7))
369 levl
[zx
][zy
].seen
= 0;
371 pline("Thinking of Maud you forget everything else.");
376 register struct monst
*mtmp
;
380 pline("The scroll catches fire and you burn your hands.");
381 losehp(1, "scroll of fire");
383 pline("The scroll erupts in a tower of flame!");
385 pline("You are uninjured.");
389 losehp(num
, "scroll of fire");
393 for(mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
) {
394 if(dist(mtmp
->mx
,mtmp
->my
) < 3) {
396 if(index("FY", mtmp
->data
->mlet
))
397 mtmp
->mhp
-= 3*num
; /* this might well kill 'F's */
400 break; /* primitive */
409 pline("You feel guilty.");
412 pline("You are being punished for your misbehaviour!");
414 pline("Your iron ball gets heavier.");
418 Punished
= INTRINSIC
;
419 setworn(mkobj_at(CHAIN_SYM
, u
.ux
, u
.uy
), W_CHAIN
);
420 setworn(mkobj_at(BALL_SYM
, u
.ux
, u
.uy
), W_BALL
);
421 uball
->spe
= 1; /* special ball (see save) */
424 impossible("What weird language is this written in? (%u)",
427 if(!objects
[scroll
->otyp
].oc_name_known
) {
428 if(known
&& !confused
) {
429 objects
[scroll
->otyp
].oc_name_known
= 1;
430 more_experienced(0,10);
431 } else if(!objects
[scroll
->otyp
].oc_uname
)
438 identify(otmp
) /* also called by newmail() */
439 register struct obj
*otmp
;
441 objects
[otmp
->otyp
].oc_name_known
= 1;
442 otmp
->known
= otmp
->dknown
= 1;
452 /* first produce the text (provided he is not blind) */
453 if(Blind
) goto do_it
;
455 if(u
.uswallow
|| !xdnstair
|| levl
[u
.ux
][u
.uy
].typ
== CORR
||
456 !levl
[u
.ux
][u
.uy
].lit
) {
457 pline("It seems even darker in here than before.");
460 pline("It suddenly becomes dark in here.");
463 pline("%s's stomach is lit.", Monnam(u
.ustuck
));
467 pline("Nothing Happens.");
471 pline("The cave lights up around you, then fades.");
474 if(levl
[u
.ux
][u
.uy
].typ
== CORR
) {
475 pline("The corridor lights up around you, then fades.");
477 } else if(levl
[u
.ux
][u
.uy
].lit
) {
478 pline("The light here seems better now.");
481 pline("The room is lit.");
489 if(levl
[u
.ux
][u
.uy
].lit
== on
)
491 if(levl
[u
.ux
][u
.uy
].typ
== DOOR
) {
492 if(IS_ROOM(levl
[u
.ux
][u
.uy
+1].typ
)) zy
= u
.uy
+1;
493 else if(IS_ROOM(levl
[u
.ux
][u
.uy
-1].typ
)) zy
= u
.uy
-1;
495 if(IS_ROOM(levl
[u
.ux
+1][u
.uy
].typ
)) zx
= u
.ux
+1;
496 else if(IS_ROOM(levl
[u
.ux
-1][u
.uy
].typ
)) zx
= u
.ux
-1;
502 for(seelx
= u
.ux
; (num
= levl
[seelx
-1][zy
].typ
) != CORR
&& num
!= 0;
504 for(seehx
= u
.ux
; (num
= levl
[seehx
+1][zy
].typ
) != CORR
&& num
!= 0;
506 for(seely
= u
.uy
; (num
= levl
[zx
][seely
-1].typ
) != CORR
&& num
!= 0;
508 for(seehy
= u
.uy
; (num
= levl
[zx
][seehy
+1].typ
) != CORR
&& num
!= 0;
510 for(zy
= seely
; zy
<= seehy
; zy
++)
511 for(zx
= seelx
; zx
<= seehx
; zx
++) {
512 levl
[zx
][zy
].lit
= on
;
513 if(!Blind
&& dist(zx
,zy
) > 2)
514 if(on
) prl(zx
,zy
); else nosee(zx
,zy
);
520 /* Test whether we may genocide all monsters with symbol ch */
521 monstersym(ch
) /* arnold@ucsfcgl */
524 register struct permonst
*mp
;
525 extern struct permonst pm_eel
;
528 * can't genocide certain monsters
530 if (index("12 &:", ch
))
533 if (ch
== pm_eel
.mlet
)
535 for (mp
= mons
; mp
< &mons
[CMNUM
+2]; mp
++)