2 * Functions to implement the various sticks one might find
3 * while wandering around the dungeon.
5 * @(#)sticks.c 3.14 (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.
20 register struct object
*cur
;
22 if (strcmp(ws_type
[cur
->o_which
], "staff") == 0)
23 strcpy(cur
->o_damage
,"2d3");
25 strcpy(cur
->o_damage
,"1d1");
26 strcpy(cur
->o_hurldmg
,"1d1");
28 cur
->o_charges
= 3 + rnd(5);
34 strcpy(cur
->o_damage
,"1d8");
36 cur
->o_charges
= 10 + rnd(10);
43 register struct linked_list
*item
;
44 register struct object
*obj
;
45 register struct room
*rp
;
46 register struct thing
*tp
;
49 if ((item
= get_item("zap with", STICK
)) == NULL
)
51 obj
= (struct object
*) ldata(item
);
52 if (obj
->o_type
!= STICK
)
54 msg("You can't zap with that!");
58 if (obj
->o_charges
== 0)
60 msg("Nothing happens.");
67 } while (delta
.y
== 0 && delta
.x
== 0);
72 * Reddy Kilowat wand. Light up the room
74 ws_know
[WS_LIGHT
] = TRUE
;
75 if ((rp
= roomin(&hero
)) == NULL
)
76 msg("The corridor glows and then fades");
79 addmsg("The room is lit");
81 addmsg(" by a shimmering blue light.");
83 rp
->r_flags
&= ~ISDARK
;
85 * Light the room and put the player back up
88 mvwaddch(cw
, hero
.y
, hero
.x
, PLAYER
);
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)
98 msg("You are too weak to use it.");
101 else if ((rp
= roomin(&hero
)) == NULL
)
102 drain(hero
.y
-1, hero
.y
+1, hero
.x
-1, hero
.x
+1);
104 drain(rp
->r_pos
.y
, rp
->r_pos
.y
+rp
->r_max
.y
,
105 rp
->r_pos
.x
, rp
->r_pos
.x
+rp
->r_max
.x
);
111 register char monster
, oldch
;
116 while (step_ok(winat(y
, x
)))
121 if (isupper(monster
= mvwinch(mw
, y
, x
)))
123 register char omonst
= monster
;
126 player
.t_flags
&= ~ISHELD
;
127 item
= find_mons(y
, x
);
128 tp
= (struct thing
*) ldata(item
);
129 if (obj
->o_which
== WS_POLYMORPH
)
135 new_monster(item
, monster
= rnd(26) + 'A', &delta
);
136 if (!(tp
->t_flags
& ISRUN
))
137 runto(&delta
, &hero
);
138 if (isupper(mvwinch(cw
, y
, x
)))
139 mvwaddch(cw
, y
, x
, monster
);
141 ws_know
[WS_POLYMORPH
] |= (monster
!= omonst
);
143 else if (obj
->o_which
== WS_CANCEL
)
145 tp
->t_flags
|= ISCANC
;
146 tp
->t_flags
&= ~ISINVIS
;
150 if (obj
->o_which
== WS_TELAWAY
)
155 rnd_pos(&rooms
[rm
], &tp
->t_pos
);
156 } until(winat(tp
->t_pos
.y
, tp
->t_pos
.x
) == FLOOR
);
160 tp
->t_pos
.y
= hero
.y
+ delta
.y
;
161 tp
->t_pos
.x
= hero
.x
+ delta
.x
;
163 if (isupper(mvwinch(cw
, y
, x
)))
164 mvwaddch(cw
, y
, x
, tp
->t_oldch
);
166 tp
->t_flags
|= ISRUN
;
167 mvwaddch(mw
, y
, x
, ' ');
168 mvwaddch(mw
, tp
->t_pos
.y
, tp
->t_pos
.x
, monster
);
169 if (tp
->t_pos
.y
!= y
|| tp
->t_pos
.x
!= x
)
170 tp
->t_oldch
= mvwinch(cw
, tp
->t_pos
.y
, tp
->t_pos
.x
);
176 static struct object bolt
=
178 '*' , {0, 0}, 0, "", "1d4" , 0, 0, 100, 1, 0, 0, 0
181 do_motion(&bolt
, delta
.y
, delta
.x
);
182 if (isupper(mvwinch(mw
, bolt
.o_pos
.y
, bolt
.o_pos
.x
))
183 && !save_throw(VS_MAGIC
, ldata(find_mons(unc(bolt
.o_pos
)))))
184 hit_monster(unc(bolt
.o_pos
), &bolt
);
186 msg("Missile vanishes");
188 msg("The missile vanishes with a puff of smoke");
189 ws_know
[WS_MISSILE
] = TRUE
;
197 ch
= winat(delta
.y
, delta
.x
);
202 strcpy(obj
->o_damage
,"3d8");
207 strcpy(obj
->o_damage
,"1d8");
210 fight(&delta
, ch
, obj
, FALSE
);
217 while (step_ok(winat(y
, x
)))
222 if (isupper(mvwinch(mw
, y
, x
)))
224 item
= find_mons(y
, x
);
225 tp
= (struct thing
*) ldata(item
);
226 if (obj
->o_which
== WS_HASTE_M
)
229 tp
->t_flags
&= ~ISSLOW
;
231 tp
->t_flags
|= ISHASTE
;
235 if (on(*tp
, ISHASTE
))
236 tp
->t_flags
&= ~ISHASTE
;
238 tp
->t_flags
|= ISSLOW
;
243 runto(&delta
, &hero
);
249 register char dirch
, ch
, *name
;
250 register bool bounced
, used
;
252 coord spotpos
[BOLT_LENGTH
];
253 static struct object bolt
=
255 '*' , {0, 0}, 0, "", "6d6" , 0, 0, 100, 0, 0, 0 ,0
259 switch (delta
.y
+ delta
.x
)
262 when
1: case -1: dirch
= (delta
.y
== 0 ? '-' : '|');
263 when
2: case -2: dirch
= '\\';
268 if (obj
->o_which
== WS_ELECT
)
270 else if (obj
->o_which
== WS_FIRE
)
274 for (y
= 0; y
< BOLT_LENGTH
&& !used
; y
++)
276 ch
= winat(pos
.y
, pos
.x
);
289 msg("The bolt bounces");
292 if (!bounced
&& isupper(ch
))
294 if (!save_throw(VS_MAGIC
, ldata(find_mons(unc(pos
)))))
297 hit_monster(unc(pos
), &bolt
);
300 else if (ch
!= 'M' || show(pos
.y
, pos
.x
) == 'M')
303 msg("%s misses", name
);
305 msg("The %s whizzes past the %s", name
, monsters
[ch
-'A'].m_name
);
309 else if (bounced
&& pos
.y
== hero
.y
&& pos
.x
== hero
.x
)
315 msg("The %s hits", name
);
317 msg("You are hit by the %s", name
);
318 if ((pstats
.s_hpt
-= roll(6, 6)) <= 0)
323 msg("The %s whizzes by you", name
);
325 mvwaddch(cw
, pos
.y
, pos
.x
, dirch
);
331 for (x
= 0; x
< y
; x
++)
332 mvwaddch(cw
, spotpos
[x
].y
, spotpos
[x
].x
, show(spotpos
[x
].y
, spotpos
[x
].x
));
333 ws_know
[obj
->o_which
] = TRUE
;
336 msg("What a bizarre schtick!");
343 * Do drain hit points from player shtick
346 drain(ymin
, ymax
, xmin
, xmax
)
347 int ymin
, ymax
, xmin
, xmax
;
349 register int i
, j
, count
;
350 register struct thing
*ick
;
351 register struct linked_list
*item
;
354 * First count how many things we need to spread the hit points among
357 for (i
= ymin
; i
<= ymax
; i
++)
358 for (j
= xmin
; j
<= xmax
; j
++)
359 if (isupper(mvwinch(mw
, i
, j
)))
363 msg("You have a tingling feeling");
366 count
= pstats
.s_hpt
/ count
;
369 * Now zot all of the monsters
371 for (i
= ymin
; i
<= ymax
; i
++)
372 for (j
= xmin
; j
<= xmax
; j
++)
373 if (isupper(mvwinch(mw
, i
, j
)) &&
374 ((item
= find_mons(i
, j
)) != NULL
))
376 ick
= (struct thing
*) ldata(item
);
377 if ((ick
->t_stats
.s_hpt
-= count
) < 1)
378 killed(item
, cansee(i
, j
) && !on(*ick
, ISINVIS
));
383 * charge a wand for wizards.
387 register struct object
*obj
;
391 if (!(obj
->o_flags
& ISKNOW
))
394 sprintf(buf
, " [%d]", obj
->o_charges
);
396 sprintf(buf
, " [%d charges]", obj
->o_charges
);