Mercurial > hg > early-roguelike
annotate rogue5/scrolls.c @ 209:4438569c1b02
Merge the MSVC branch.
author | John "Elwin" Edwards |
---|---|
date | Fri, 27 Nov 2015 08:59:24 -0500 |
parents | f502bf60e6e4 |
children |
rev | line source |
---|---|
33
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
1 /* |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
2 * Read a scroll and let it happen |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
3 * |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
4 * @(#)scrolls.c 4.44 (Berkeley) 02/05/99 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
5 * |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
6 * Rogue: Exploring the Dungeons of Doom |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
7 * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
8 * All rights reserved. |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
9 * |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
10 * See the file LICENSE.TXT for full copyright and licensing information. |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
11 */ |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
12 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
13 #include <curses.h> |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
14 #include <ctype.h> |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
15 #include "rogue.h" |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
16 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
17 /* |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
18 * read_scroll: |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
19 * Read a scroll from the pack and do the appropriate thing |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
20 */ |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
21 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
22 void |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
23 read_scroll(void) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
24 { |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
25 THING *obj; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
26 PLACE *pp; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
27 int y, x; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
28 int ch; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
29 int i; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
30 int discardit = FALSE; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
31 struct room *cur_room; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
32 THING *orig_obj; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
33 coord mp; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
34 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
35 obj = get_item("read", SCROLL); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
36 if (obj == NULL) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
37 return; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
38 if (obj->o_type != SCROLL) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
39 { |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
40 if (!terse) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
41 msg("there is nothing on it to read"); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
42 else |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
43 msg("nothing to read"); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
44 return; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
45 } |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
46 /* |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
47 * Calculate the effect it has on the poor guy. |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
48 */ |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
49 if (obj == cur_weapon) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
50 cur_weapon = NULL; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
51 /* |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
52 * Get rid of the thing |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
53 */ |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
54 discardit = (obj->o_count == 1); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
55 leave_pack(obj, FALSE, FALSE); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
56 orig_obj = obj; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
57 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
58 switch (obj->o_which) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
59 { |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
60 case S_CONFUSE: |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
61 /* |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
62 * Scroll of monster confusion. Give him that power. |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
63 */ |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
64 player.t_flags |= CANHUH; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
65 msg("your hands begin to glow %s", pick_color("red")); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
66 when S_ARMOR: |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
67 if (cur_armor != NULL) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
68 { |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
69 cur_armor->o_arm--; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
70 cur_armor->o_flags &= ~ISCURSED; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
71 msg("your armor glows %s for a moment", pick_color("silver")); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
72 } |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
73 when S_HOLD: |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
74 /* |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
75 * Hold monster scroll. Stop all monsters within two spaces |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
76 * from chasing after the hero. |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
77 */ |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
78 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
79 ch = 0; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
80 for (x = hero.x - 2; x <= hero.x + 2; x++) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
81 if (x >= 0 && x < NUMCOLS) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
82 for (y = hero.y - 2; y <= hero.y + 2; y++) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
83 if (y >= 0 && y <= NUMLINES - 1) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
84 if ((obj = moat(y, x)) != NULL && on(*obj, ISRUN)) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
85 { |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
86 obj->t_flags &= ~ISRUN; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
87 obj->t_flags |= ISHELD; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
88 ch++; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
89 } |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
90 if (ch) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
91 { |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
92 addmsg("the monster"); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
93 if (ch > 1) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
94 addmsg("s around you"); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
95 addmsg(" freeze"); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
96 if (ch == 1) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
97 addmsg("s"); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
98 endmsg(); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
99 scr_info[S_HOLD].oi_know = TRUE; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
100 } |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
101 else |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
102 msg("you feel a strange sense of loss"); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
103 when S_SLEEP: |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
104 /* |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
105 * Scroll which makes you fall asleep |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
106 */ |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
107 scr_info[S_SLEEP].oi_know = TRUE; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin |