|
|
1.1 root 1:
2: /*
3: * Read a scroll and let it happen
4: *
5: * @(#)scrolls.c 3.5 (Berkeley) 6/15/81
6: */
7:
8: #include <curses.h>
9: #include <ctype.h>
10: #include "rogue.h"
11:
12: read_scroll()
13: {
14: register struct object *obj;
15: register struct linked_list *item;
16: register struct room *rp;
17: register int i,j;
18: register char ch, nch;
19: register struct linked_list *titem;
20: char buf[80];
21:
22: item = get_item("read", SCROLL);
23: if (item == NULL)
24: return;
25: obj = (struct object *) ldata(item);
26: if (obj->o_type != SCROLL)
27: {
28: if (!terse)
29: msg("There is nothing on it to read");
30: else
31: msg("Nothing to read");
32: return;
33: }
34: msg("As you read the scroll, it vanishes.");
35: /*
36: * Calculate the effect it has on the poor guy.
37: */
38: if (obj == cur_weapon)
39: cur_weapon = NULL;
40: switch(obj->o_which)
41: {
42: when S_CONFUSE:
43: /*
44: * Scroll of monster confusion. Give him that power.
45: */
46: msg("Your hands begin to glow red");
47: player.t_flags |= CANHUH;
48: when S_LIGHT:
49: s_know[S_LIGHT] = TRUE;
50: if ((rp = roomin(&hero)) == NULL)
51: msg("The corridor glows and then fades");
52: else
53: {
54: addmsg("The room is lit");
55: if (!terse)
56: addmsg(" by a shimmering blue light.");
57: endmsg();
58: rp->r_flags &= ~ISDARK;
59: /*
60: * Light the room and put the player back up
61: */
62: light(&hero);
63: mvwaddch(cw, hero.y, hero.x, PLAYER);
64: }
65: when S_ARMOR:
66: if (cur_armor != NULL)
67: {
68: msg("Your armor glows faintly for a moment");
69: cur_armor->o_ac--;
70: cur_armor->o_flags &= ~ISCURSED;
71: }
72: when S_HOLD:
73: /*
74: * Hold monster scroll. Stop all monsters within two spaces
75: * from chasing after the hero.
76: */
77: {
78: register int x,y;
79: register struct linked_list *mon;
80:
81: for (x = hero.x-2; x <= hero.x+2; x++)
82: for (y = hero.y-2; y <= hero.y+2; y++)
83: if (y > 0 && x > 0 && isupper(mvwinch(mw, y, x)))
84: if ((mon = find_mons(y, x)) != NULL)
85: {
86: register struct thing *th;
87:
88: th = (struct thing *) ldata(mon);
89: th->t_flags &= ~ISRUN;
90: th->t_flags |= ISHELD;
91: }
92: }
93: when S_SLEEP:
94: /*
95: * Scroll which makes you fall asleep
96: */
97: s_know[S_SLEEP] = TRUE;
98: msg("You fall asleep.");
99: no_command += 4 + rnd(SLEEPTIME);
100: when S_CREATE:
101: /*
102: * Create a monster
103: * First look in a circle around him, next try his room
104: * otherwise give up
105: */
106: {
107: register int x, y;
108: register bool appear = 0;
109: coord mp;
110:
111: /*
112: * Search for an open place
113: */
114: for (y = hero.y; y <= hero.y+1; y++)
115: for (x = hero.x; x <= hero.x+1; x++)
116: {
117: /*
118: * Don't put a monster in top of the player.
119: */
120: if (y == hero.y && x == hero.x)
121: continue;
122: /*
123: * Or anything else nasty
124: */
125: if (step_ok(winat(y, x)))
126: {
127: if (rnd(++appear) == 0)
128: {
129: mp.y = y;
130: mp.x = x;
131: }
132: }
133: }
134: if (appear)
135: {
136: titem = new_item(sizeof (struct thing));
137: new_monster(titem, randmonster(FALSE), &mp);
138: }
139: else
140: msg("You hear a faint cry of anguish in the distance.");
141: }
142: when S_IDENT:
143: /*
144: * Identify, let the rogue figure something out
145: */
146: msg("This scroll is an identify scroll");
147: s_know[S_IDENT] = TRUE;
148: whatis();
149: when S_MAP:
150: /*
151: * Scroll of magic mapping.
152: */
153: s_know[S_MAP] = TRUE;
154: msg("Oh, now this scroll has a map on it.");
155: overwrite(stdscr, hw);
156: /*
157: * Take all the things we want to keep hidden out of the window
158: */
159: for (i = 0; i < LINES; i++)
160: for (j = 0; j < COLS; j++)
161: {
162: switch (nch = ch = mvwinch(hw, i, j))
163: {
164: case SECRETDOOR:
165: mvaddch(i, j, nch = DOOR);
166: case '-':
167: case '|':
168: case DOOR:
169: case PASSAGE:
170: case ' ':
171: case STAIRS:
172: if (mvwinch(mw, i, j) != ' ')
173: {
174: register struct thing *it;
175:
176: it = (struct thing *) ldata(find_mons(i, j));
177: if (it->t_oldch == ' ')
178: it->t_oldch = nch;
179: }
180: break;
181: default:
182: nch = ' ';
183: }
184: if (nch != ch)
185: waddch(hw, nch);
186: }
187: /*
188: * Copy in what he has discovered
189: */
190: overlay(cw, hw);
191: /*
192: * And set up for display
193: */
194: overwrite(hw, cw);
195: when S_GFIND:
196: /*
197: * Potion of gold detection
198: */
199: {
200: int gtotal = 0;
201:
202: wclear(hw);
203: for (i = 0; i < MAXROOMS; i++)
204: {
205: gtotal += rooms[i].r_goldval;
206: if (rooms[i].r_goldval != 0 &&
207: mvwinch(stdscr, rooms[i].r_gold.y, rooms[i].r_gold.x)
208: == GOLD)
209: mvwaddch(hw,rooms[i].r_gold.y,rooms[i].r_gold.x,GOLD);
210: }
211: if (gtotal)
212: {
213: s_know[S_GFIND] = TRUE;
214: show_win(hw,
215: "You begin to feel greedy and you sense gold.--More--");
216: }
217: else msg("You begin to feel a pull downward");
218: }
219: when S_TELEP:
220: /*
221: * Scroll of teleportation:
222: * Make him dissapear and reappear
223: */
224: {
225: int rm;
226: struct room *cur_room;
227:
228: cur_room = roomin(&hero);
229: rm = teleport();
230: if (cur_room != &rooms[rm])
231: s_know[S_TELEP] = TRUE;
232: }
233: when S_ENCH:
234: if (cur_weapon == NULL)
235: msg("You feel a strange sense of loss.");
236: else
237: {
238: cur_weapon->o_flags &= ~ISCURSED;
239: if (rnd(100) > 50)
240: cur_weapon->o_hplus++;
241: else
242: cur_weapon->o_dplus++;
243: msg("Your %s glows blue for a moment.", w_names[cur_weapon->o_which]);
244: }
245: when S_SCARE:
246: /*
247: * A monster will refuse to step on a scare monster scroll
248: * if it is dropped. Thus reading it is a mistake and produces
249: * laughter at the poor rogue's boo boo.
250: */
251: msg("You hear maniacal laughter in the distance.");
252: when S_REMOVE:
253: if (cur_armor != NULL)
254: cur_armor->o_flags &= ~ISCURSED;
255: if (cur_weapon != NULL)
256: cur_weapon->o_flags &= ~ISCURSED;
257: if (cur_ring[LEFT] != NULL)
258: cur_ring[LEFT]->o_flags &= ~ISCURSED;
259: if (cur_ring[RIGHT] != NULL)
260: cur_ring[RIGHT]->o_flags &= ~ISCURSED;
261: msg("You feel as if somebody is watching over you.");
262: when S_AGGR:
263: /*
264: * This scroll aggravates all the monsters on the current
265: * level and sets them running towards the hero
266: */
267: aggravate();
268: msg("You hear a high pitched humming noise.");
269: when S_NOP:
270: msg("This scroll seems to be blank.");
271: when S_GENOCIDE:
272: msg("You have been granted the boon of genocide");
273: genocide();
274: s_know[S_GENOCIDE] = TRUE;
275: otherwise:
276: msg("What a puzzling scroll!");
277: return;
278: }
279: look(TRUE); /* put the result of the scroll on the screen */
280: status();
281: if (s_know[obj->o_which] && s_guess[obj->o_which])
282: {
283: cfree(s_guess[obj->o_which]);
284: s_guess[obj->o_which] = NULL;
285: }
286: else if (!s_know[obj->o_which] && askme && s_guess[obj->o_which] == NULL)
287: {
288: msg(terse ? "Call it: " : "What do you want to call it? ");
289: if (get_str(buf, cw) == NORM)
290: {
291: s_guess[obj->o_which] = malloc((unsigned int) strlen(buf) + 1);
292: strcpy(s_guess[obj->o_which], buf);
293: }
294: }
295: /*
296: * Get rid of the thing
297: */
298: inpack--;
299: if (obj->o_count > 1)
300: obj->o_count--;
301: else
302: {
303: detach(pack, item);
304: discard(item);
305: }
306: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.