comparison rogue5/sticks.c @ 33:f502bf60e6e4

Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
author elwin
date Mon, 24 May 2010 20:10:59 +0000
parents
children 1e1c81fbb533
comparison
equal deleted inserted replaced
32:2dcd75e6a736 33:f502bf60e6e4
1 /*
2 * Functions to implement the various sticks one might find
3 * while wandering around the dungeon.
4 *
5 * @(#)sticks.c 4.39 (Berkeley) 02/05/99
6 *
7 * Rogue: Exploring the Dungeons of Doom
8 * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman
9 * All rights reserved.
10 *
11 * See the file LICENSE.TXT for full copyright and licensing information.
12 */
13
14 #include <curses.h>
15 #include <string.h>
16 #include <ctype.h>
17 #include "rogue.h"
18
19 /*
20 * fix_stick:
21 * Set up a new stick
22 */
23
24 void
25 fix_stick(THING *cur)
26 {
27 if (strcmp(ws_type[cur->o_which], "staff") == 0)
28 strncpy(cur->o_damage,"2x3",sizeof(cur->o_damage));
29 else
30 strncpy(cur->o_damage,"1x1",sizeof(cur->o_damage));
31 strncpy(cur->o_hurldmg,"1x1",sizeof(cur->o_hurldmg));
32
33 switch (cur->o_which)
34 {
35 case WS_LIGHT:
36 cur->o_charges = rnd(10) + 10;
37 otherwise:
38 cur->o_charges = rnd(5) + 3;
39 }
40 }
41
42 /*
43 * do_zap:
44 * Perform a zap with a wand
45 */
46
47 void
48 do_zap(void)
49 {
50 THING *obj, *tp;
51 int y, x;
52 char *name;
53 int monster, oldch;
54 THING bolt;
55
56 if ((obj = get_item("zap with", STICK)) == NULL)
57 return;
58 if (obj->o_type != STICK)
59 {
60 after = FALSE;
61 msg("you can't zap with that!");
62 return;
63 }
64 if (obj->o_charges == 0)
65 {
66 msg("nothing happens");
67 return;
68 }
69 switch (obj->o_which)
70 {
71 case WS_LIGHT:
72 /*
73 * Reddy Kilowat wand. Light up the room
74 */
75 ws_info[WS_LIGHT].oi_know = TRUE;
76 if (proom->r_flags & ISGONE)
77 msg("the corridor glows and then fades");
78 else
79 {
80 proom->r_flags &= ~ISDARK;
81 /*
82 * Light the room and put the player back up
83 */
84 enter_room(&hero);
85 addmsg("the room is lit");
86 if (!terse)
87 addmsg(" by a shimmering %s light", pick_color("blue"));
88 endmsg();
89 }
90 when WS_DRAIN:
91 /*
92 * take away 1/2 of hero's hit points, then take it away
93 * evenly from the monsters in the room (or next to hero
94 * if he is in a passage)
95 */
96 if (pstats.s_hpt < 2)
97 {
98 msg("you are too weak to use it");
99 return;
100 }
101 else
102 drain();
103 when WS_INVIS:
104 case WS_POLYMORPH:
105 case WS_TELAWAY:
106 case WS_TELTO:
107 case WS_CANCEL:
108 y = hero.y;
109 x = hero.x;
110 while (step_ok(winat(y, x)))
111 {
112 y += delta.y;
113 x += delta.x;
114 }
115 if ((tp = moat(y, x)) != NULL)
116 {
117 monster = tp->t_type;
118 if (monster == 'F')
119 player.t_flags &= ~ISHELD;
120 switch (obj->o_which) {
121 case WS_INVIS:
122 tp->t_flags |= ISINVIS;
123 if (cansee(y, x))
124 mvaddch(y, x, tp->t_oldch);
125 break;
126 case WS_POLYMORPH:
127 {
128 THING *pp;
129
130 pp = tp->t_pack;
131 detach(mlist, tp);
132 if (see_monst(tp))
133 mvaddch(y, x, chat(y, x));
134 oldch = tp->t_oldch;
135 delta.y = y;
136 delta.x = x;
137 new_monster(tp, monster = rnd(26) + 'A', &delta);
138 if (see_monst(tp))
139 mvaddch(y, x, monster);
140 tp->t_oldch = oldch;
141 tp->t_pack = pp;
142 ws_info[WS_POLYMORPH].oi_know |= see_monst(tp);
143 break;
144 }
145 case WS_CANCEL:
146 tp->t_flags |= ISCANC;
147 tp->t_flags &= ~(ISINVIS|CANHUH);
148 tp->t_disguise = tp->t_type;
149 if (see_monst(tp))
150 mvaddch(y, x, tp->t_disguise);
151 break;
152 case WS_TELAWAY:
153 case WS_TELTO:
154 {
155 coord new_pos;
156
157 if (obj->o_which == WS_TELAWAY)
158 {
159 do
160 {
161 find_floor(NULL, &new_pos, FALSE, TRUE);
162 } while (ce(new_pos, hero));
163 }
164 else
165 {
166 new_pos.y = hero.y + delta.y;
167 new_pos.x = hero.x + delta.x;
168 }
169 tp->t_dest = &hero;
170 tp->t_flags |= ISRUN;
171 relocate(tp, &new_pos);
172 }
173 }
174 }
175 when WS_MISSILE:
176 ws_info[WS_MISSILE].oi_know = TRUE;
177 bolt.o_type = '*';
178 strncpy(bolt.o_hurldmg,"1x4",sizeof(bolt.o_hurldmg));
179 bolt.o_hplus = 100;
180 bolt.o_dplus = 1;