3 * Read a scroll and let it happen
5 * @(#)scrolls.c 3.5 (Berkeley) 6/15/81
7 * Rogue: Exploring the Dungeons of Doom
8 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
11 * See the file LICENSE.TXT for full copyright and licensing information.
22 register struct object
*obj
;
23 register struct linked_list
*item
;
24 register struct room
*rp
;
26 register char ch
, nch
;
27 register struct linked_list
*titem
;
30 item
= get_item("read", SCROLL
);
33 obj
= (struct object
*) ldata(item
);
34 if (obj
->o_type
!= SCROLL
)
37 msg("There is nothing on it to read");
39 msg("Nothing to read");
42 msg("As you read the scroll, it vanishes.");
44 * Calculate the effect it has on the poor guy.
46 if (obj
== cur_weapon
)
52 * Scroll of monster confusion. Give him that power.
54 msg("Your hands begin to glow red");
55 player
.t_flags
|= CANHUH
;
57 s_know
[S_LIGHT
] = TRUE
;
58 if ((rp
= roomin(&hero
)) == NULL
)
59 msg("The corridor glows and then fades");
62 addmsg("The room is lit");
64 addmsg(" by a shimmering blue light.");
66 rp
->r_flags
&= ~ISDARK
;
68 * Light the room and put the player back up
71 mvwaddch(cw
, hero
.y
, hero
.x
, PLAYER
);
74 if (cur_armor
!= NULL
)
76 msg("Your armor glows faintly for a moment");
78 cur_armor
->o_flags
&= ~ISCURSED
;
82 * Hold monster scroll. Stop all monsters within two spaces
83 * from chasing after the hero.
87 register struct linked_list
*mon
;
89 for (x
= hero
.x
-2; x
<= hero
.x
+2; x
++)
90 for (y
= hero
.y
-2; y
<= hero
.y
+2; y
++)
91 if (y
> 0 && x
> 0 && isupper(mvwinch(mw
, y
, x
)))
92 if ((mon
= find_mons(y
, x
)) != NULL
)
94 register struct thing
*th
;
96 th
= (struct thing
*) ldata(mon
);
97 th
->t_flags
&= ~ISRUN
;
98 th
->t_flags
|= ISHELD
;
103 * Scroll which makes you fall asleep
105 s_know
[S_SLEEP
] = TRUE
;
106 msg("You fall asleep.");
107 no_command
+= 4 + rnd(SLEEPTIME
);
111 * First look in a circle around him, next try his room
116 register bool appear
= 0;
120 * Search for an open place
122 for (y
= hero
.y
-1; y
<= hero
.y
+1; y
++)
123 for (x
= hero
.x
-1; x
<= hero
.x
+1; x
++)
126 * Don't put a monster in top of the player.
128 if (y
== hero
.y
&& x
== hero
.x
)
131 * Or anything else nasty
133 if (step_ok(winat(y
, x
)))
135 if (rnd(++appear
) == 0)
144 titem
= new_item(sizeof (struct thing
));
145 new_monster(titem
, randmonster(FALSE
), &mp
);
148 msg("You hear a faint cry of anguish in the distance.");
152 * Identify, let the rogue figure something out
154 msg("This scroll is an identify scroll");
155 s_know
[S_IDENT
] = TRUE
;
159 * Scroll of magic mapping.
161 s_know
[S_MAP
] = TRUE
;
162 msg("Oh, now this scroll has a map on it.");
163 overwrite(stdscr
, hw
);
165 * Take all the things we want to keep hidden out of the window
167 for (i
= 0; i
< LINES
; i
++)
168 for (j
= 0; j
< COLS
; j
++)
170 switch (nch
= ch
= mvwinch(hw
, i
, j
))
181 if (mvwinch(mw
, i
, j
) != ' ')
183 register struct thing
*it
;
185 it
= (struct thing
*) ldata(find_mons(i
, j
));
186 if ((it
!= NULL
) && (it
->t_oldch
== ' '))
197 * Copy in what he has discovered
201 * And set up for display
206 * Potion of gold detection
212 for (i
= 0; i
< MAXROOMS
; i
++)
214 gtotal
+= rooms
[i
].r_goldval
;
215 if (rooms
[i
].r_goldval
!= 0 &&
216 mvwinch(stdscr
, rooms
[i
].r_gold
.y
, rooms
[i
].r_gold
.x
)
218 mvwaddch(hw
,rooms
[i
].r_gold
.y
,rooms
[i
].r_gold
.x
,GOLD
);
222 s_know
[S_GFIND
] = TRUE
;
224 "You begin to feel greedy and you sense gold.--More--");
226 else msg("You begin to feel a pull downward");
230 * Scroll of teleportation:
231 * Make him dissapear and reappear
235 struct room
*cur_room
;
237 cur_room
= roomin(&hero
);
239 if (cur_room
!= &rooms
[rm
])
240 s_know
[S_TELEP
] = TRUE
;
243 if (cur_weapon
== NULL
)
244 msg("You feel a strange sense of loss.");
247 cur_weapon
->o_flags
&= ~ISCURSED
;
249 cur_weapon
->o_hplus
++;
251 cur_weapon
->o_dplus
++;
252 msg("Your %s glows blue for a moment.", w_names
[cur_weapon
->o_which
]);
256 * A monster will refuse to step on a scare monster scroll
257 * if it is dropped. Thus reading it is a mistake and produces
258 * laughter at the poor rogue's boo boo.
260 msg("You hear maniacal laughter in the distance.");
262 if (cur_armor
!= NULL
)
263 cur_armor
->o_flags
&= ~ISCURSED
;
264 if (cur_weapon
!= NULL
)
265 cur_weapon
->o_flags
&= ~ISCURSED
;
266 if (cur_ring
[LEFT
] != NULL
)
267 cur_ring
[LEFT
]->o_flags
&= ~ISCURSED
;
268 if (cur_ring
[RIGHT
] != NULL
)
269 cur_ring
[RIGHT
]->o_flags
&= ~ISCURSED
;
270 msg("You feel as if somebody is watching over you.");
273 * This scroll aggravates all the monsters on the current
274 * level and sets them running towards the hero
277 msg("You hear a high pitched humming noise.");
279 msg("This scroll seems to be blank.");
281 msg("You have been granted the boon of genocide");
283 s_know
[S_GENOCIDE
] = TRUE
;
285 msg("What a puzzling scroll!");
288 look(TRUE
); /* put the result of the scroll on the screen */
290 if (s_know
[obj
->o_which
] && s_guess
[obj
->o_which
])
292 free(s_guess
[obj
->o_which
]);
293 s_guess
[obj
->o_which
] = NULL
;
295 else if (!s_know
[obj
->o_which
] && askme
&& s_guess
[obj
->o_which
] == NULL
)
297 msg(terse
? "Call it: " : "What do you want to call it? ");
298 if (get_str(buf
, cw
) == NORM
)
300 s_guess
[obj
->o_which
] = malloc((unsigned int) strlen(buf
) + 1);
301 if (s_guess
[obj
->o_which
] != NULL
)
302 strcpy(s_guess
[obj
->o_which
], buf
);
306 * Get rid of the thing
309 if (obj
->o_count
> 1)