1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.read.c - version 1.0.3 */
3 /* $FreeBSD: src/games/hack/hack.read.c,v 1.6 1999/11/16 10:26:37 marcel Exp $ */
4 /* $DragonFly: src/games/hack/hack.read.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */
8 static bool monstersym(char);
14 boolean confused
= (Confusion
!= 0);
15 boolean known
= FALSE
;
17 scroll
= getobj("?", "read");
18 if(!scroll
) return(0);
19 if(!scroll
->dknown
&& Blind
) {
20 pline("Being blind, you cannot read the formula on the scroll.");
24 pline("As you pronounce the formula on it, the scroll disappears.");
26 pline("As you read the scroll, it disappears.");
28 pline("Being confused, you mispronounce the magic words ... ");
30 switch(scroll
->otyp
) {
33 readmail(/* scroll */);
36 case SCR_ENCHANT_ARMOR
:
37 { struct obj
*otmp
= some_armor();
39 strange_feeling(scroll
,"Your skin glows then fades.");
43 pline("Your %s glows silver for a moment.",
44 objects
[otmp
->otyp
].oc_name
);
48 if(otmp
->spe
> 3 && rn2(otmp
->spe
)) {
49 pline("Your %s glows violently green for a while, then evaporates.",
50 objects
[otmp
->otyp
].oc_name
);
54 pline("Your %s glows green for a moment.",
55 objects
[otmp
->otyp
].oc_name
);
60 case SCR_DESTROY_ARMOR
:
62 struct obj
*otmp
= some_armor();
64 strange_feeling(scroll
,"Your bones itch.");
67 pline("Your %s glows purple for a moment.",
68 objects
[otmp
->otyp
].oc_name
);
73 pline("Your armor turns to dust and falls to the floor!");
76 pline("Your helmet turns to dust and is blown away!");
79 pline("Your gloves vanish!");
83 strange_feeling(scroll
,"Your skin itches.");
87 case SCR_CONFUSE_MONSTER
:
89 pline("Your hands begin to glow purple.");
90 Confusion
+= rnd(100);
92 pline("Your hands begin to glow blue.");
96 case SCR_SCARE_MONSTER
:
100 for(mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
101 if(cansee(mtmp
->mx
,mtmp
->my
)) {
103 mtmp
->mflee
= mtmp
->mfroz
=
111 pline("You hear sad wailing in the distance.");
113 pline("You hear maniacal laughter in the distance.");
117 case SCR_BLANK_PAPER
:
119 pline("You see strange patterns on this scroll.");
121 pline("This scroll seems to be blank.");
123 case SCR_REMOVE_CURSE
:
126 pline("You feel like you need some help.");
128 pline("You feel like someone is helping you.");
129 for(obj
= invent
; obj
; obj
= obj
->nobj
)
131 obj
->cursed
= confused
;
132 if(Punished
&& !confused
) {
136 free((char *) uchain
);
138 uball
->owornmask
&= ~W_BALL
;
139 uchain
= uball
= (struct obj
*) 0;
143 case SCR_CREATE_MONSTER
:
146 if(!rn2(73)) cnt
+= rnd(4);
147 if(confused
) cnt
+= 12;
149 makemon(confused
? PM_ACID_BLOB
:
150 (struct permonst
*) 0, u
.ux
, u
.uy
);
153 case SCR_ENCHANT_WEAPON
:
154 if(uwep
&& confused
) {
155 pline("Your %s glows silver for a moment.",
156 objects
[uwep
->otyp
].oc_name
);
159 if(!chwepon(scroll
, 1)) /* tests for !uwep */
162 case SCR_DAMAGE_WEAPON
:
163 if(uwep
&& confused
) {
164 pline("Your %s glows purple for a moment.",
165 objects
[uwep
->otyp
].oc_name
);
168 if(!chwepon(scroll
, -1)) /* tests for !uwep */
173 int bd
= confused
? 5 : 1;
176 for(i
= -bd
; i
<= bd
; i
++) for(j
= -bd
; j
<= bd
; j
++)
177 if((mtmp
= m_at(u
.ux
+i
, u
.uy
+j
)))
178 tamedog(mtmp
, (struct obj
*) 0);
184 struct monst
*mtmp
, *mtmp2
;
186 pline("You have found a scroll of genocide!");
191 pline("What monster do you want to genocide (Type the letter)? ");
193 } while(strlen(buf
) != 1 || !monstersym(*buf
));
194 if(!index(fut_geno
, *buf
))
195 charcat(fut_geno
, *buf
);
196 if(!index(genocided
, *buf
))
197 charcat(genocided
, *buf
);
199 pline("Such monsters do not exist in this world.");
202 for(mtmp
= fmon
; mtmp
; mtmp
= mtmp2
){
204 if(mtmp
->data
->mlet
== *buf
)
207 pline("Wiped out all %c's.", *buf
);
209 killer
= "scroll of genocide";
215 if(!Blind
) known
= TRUE
;
218 case SCR_TELEPORTATION
:
223 int oux
= u
.ux
, ouy
= u
.uy
;
225 if(dist(oux
, ouy
) > 100) known
= TRUE
;
227 int uroom
= inroom(u
.ux
, u
.uy
);
229 if(uroom
!= inroom(u
.ux
, u
.uy
)) known
= TRUE
;
233 case SCR_GOLD_DETECTION
:
234 /* Unfortunately this code has become slightly less elegant,
235 now that gold and traps no longer are of the same type. */
240 strange_feeling(scroll
, "Your toes stop itching.");
243 for(ttmp
= ftrap
; ttmp
; ttmp
= ttmp
->ntrap
)
244 if(ttmp
->tx
!= u
.ux
|| ttmp
->ty
!= u
.uy
)
246 /* only under me - no separate display required */
247 pline("Your toes itch!");
251 for(ttmp
= ftrap
; ttmp
; ttmp
= ttmp
->ntrap
)
252 at(ttmp
->tx
, ttmp
->ty
, '$');
254 pline("You feel very greedy!");
260 strange_feeling(scroll
, "You feel materially poor.");
264 for(gtmp
= fgold
; gtmp
; gtmp
= gtmp
->ngold
)
265 if(gtmp
->gx
!= u
.ux
|| gtmp
->gy
!= u
.uy
)
267 /* only under me - no separate display required */
268 pline("You notice some gold between your feet.");
272 for(gtmp
= fgold
; gtmp
; gtmp
= gtmp
->ngold
)
273 at(gtmp
->gx
, gtmp
->gy
, '$');
275 pline("You feel very greedy, and sense gold!");
282 case SCR_FOOD_DETECTION
:
283 { int ct
= 0, ctu
= 0;
285 char foodsym
= confused
? POTION_SYM
: FOOD_SYM
;
287 for(obj
= fobj
; obj
; obj
= obj
->nobj
)
288 if(obj
->olet
== FOOD_SYM
) {
289 if(obj
->ox
== u
.ux
&& obj
->oy
== u
.uy
) ctu
++;
293 strange_feeling(scroll
,"Your nose twitches.");
297 pline("You smell %s close nearby.",
298 confused
? "something" : "food");
303 for(obj
= fobj
; obj
; obj
= obj
->nobj
)
304 if(obj
->olet
== foodsym
)
305 at(obj
->ox
, obj
->oy
, FOOD_SYM
);
307 pline("Your nose tingles and you smell %s!",
308 confused
? "something" : "food");
317 pline("You identify this as an identify scroll.");
319 pline("This is an identify scroll.");
321 objects
[SCR_IDENTIFY
].oc_name_known
= 1;
324 !ggetobj("identify", identify
, rn2(5) ? 1 : rn2(5))
328 case SCR_MAGIC_MAPPING
:
333 pline("On this scroll %s a map!",
334 confused
? "was" : "is");
335 for(zy
= 0; zy
< ROWNO
; zy
++)
336 for(zx
= 0; zx
< COLNO
; zx
++) {
337 if(confused
&& rn2(7)) continue;
338 lev
= &(levl
[zx
][zy
]);
339 if((num
= lev
->typ
) == 0)
343 lev
->scrsym
= CORR_SYM
;
348 /* do sth in doors ? */
349 } else if(lev
->seen
) continue;
354 lev
->seen
= lev
->new = 1;
355 if(lev
->scrsym
== ' ' || !lev
->scrsym
)
367 for(zx
= 0; zx
< COLNO
; zx
++) for(zy
= 0; zy
< ROWNO
; zy
++)
368 if(!confused
|| rn2(7))
370 levl
[zx
][zy
].seen
= 0;
372 pline("Thinking of Maud you forget everything else.");
381 pline("The scroll catches fire and you burn your hands.");
382 losehp(1, "scroll of fire");
384 pline("The scroll erupts in a tower of flame!");
386 pline("You are uninjured.");
390 losehp(num
, "scroll of fire");
394 for(mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
) {
395 if(dist(mtmp
->mx
,mtmp
->my
) < 3) {
397 if(index("FY", mtmp
->data
->mlet
))
398 mtmp
->mhp
-= 3*num
; /* this might well kill 'F's */
401 break; /* primitive */
410 pline("You feel guilty.");
413 pline("You are being punished for your misbehaviour!");
415 pline("Your iron ball gets heavier.");
419 Punished
= INTRINSIC
;
420 setworn(mkobj_at(CHAIN_SYM
, u
.ux
, u
.uy
), W_CHAIN
);
421 setworn(mkobj_at(BALL_SYM
, u
.ux
, u
.uy
), W_BALL
);
422 uball
->spe
= 1; /* special ball (see save) */
425 impossible("What weird language is this written in? (%u)",
428 if(!objects
[scroll
->otyp
].oc_name_known
) {
429 if(known
&& !confused
) {
430 objects
[scroll
->otyp
].oc_name_known
= 1;
431 more_experienced(0,10);
432 } else if(!objects
[scroll
->otyp
].oc_uname
)
440 identify(struct obj
*otmp
) /* also called by newmail() */
442 objects
[otmp
->otyp
].oc_name_known
= 1;
443 otmp
->known
= otmp
->dknown
= 1;
453 /* first produce the text (provided he is not blind) */
454 if(Blind
) goto do_it
;
456 if(u
.uswallow
|| !xdnstair
|| levl
[u
.ux
][u
.uy
].typ
== CORR
||
457 !levl
[u
.ux
][u
.uy
].lit
) {
458 pline("It seems even darker in here than before.");
461 pline("It suddenly becomes dark in here.");
464 pline("%s's stomach is lit.", Monnam(u
.ustuck
));
468 pline("Nothing Happens.");
472 pline("The cave lights up around you, then fades.");
475 if(levl
[u
.ux
][u
.uy
].typ
== CORR
) {
476 pline("The corridor lights up around you, then fades.");
478 } else if(levl
[u
.ux
][u
.uy
].lit
) {
479 pline("The light here seems better now.");
482 pline("The room is lit.");
490 if(levl
[u
.ux
][u
.uy
].lit
== on
)
492 if(levl
[u
.ux
][u
.uy
].typ
== DOOR
) {
493 if(IS_ROOM(levl
[u
.ux
][u
.uy
+1].typ
)) zy
= u
.uy
+1;
494 else if(IS_ROOM(levl
[u
.ux
][u
.uy
-1].typ
)) zy
= u
.uy
-1;
496 if(IS_ROOM(levl
[u
.ux
+1][u
.uy
].typ
)) zx
= u
.ux
+1;
497 else if(IS_ROOM(levl
[u
.ux
-1][u
.uy
].typ
)) zx
= u
.ux
-1;
503 for(seelx
= u
.ux
; (num
= levl
[seelx
-1][zy
].typ
) != CORR
&& num
!= 0;
505 for(seehx
= u
.ux
; (num
= levl
[seehx
+1][zy
].typ
) != CORR
&& num
!= 0;
507 for(seely
= u
.uy
; (num
= levl
[zx
][seely
-1].typ
) != CORR
&& num
!= 0;
509 for(seehy
= u
.uy
; (num
= levl
[zx
][seehy
+1].typ
) != CORR
&& num
!= 0;
511 for(zy
= seely
; zy
<= seehy
; zy
++)
512 for(zx
= seelx
; zx
<= seehx
; zx
++) {
513 levl
[zx
][zy
].lit
= on
;
514 if(!Blind
&& dist(zx
,zy
) > 2) {
515 if(on
) prl(zx
,zy
); else nosee(zx
,zy
);
522 /* Test whether we may genocide all monsters with symbol ch */
524 monstersym(char ch
) /* arnold@ucsfcgl */
529 * can't genocide certain monsters
531 if (index("12 &:", ch
))
534 if (ch
== pm_eel
.mlet
)
536 for (mp
= mons
; mp
< &mons
[CMNUM
+2]; mp
++)