* Copyright (c) 1988 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)zap.c 5.3 (Berkeley) 6/1/90";
* This source herein may be modified and/or distributed by anybody who
* so desires, with the following restrictions:
* 1.) No portion of this notice shall be removed.
* 2.) Credit shall not be taken for the creation of this source.
* 3.) This code is not to be traded, sold, or used for personal
extern boolean being_held
, score_only
, detect_monster
;
while (!is_direction(dir
= rgetchar(), &d
)) {
message("direction? ", 0);
if ((wch
= pack_letter("zap with what?", WAND
)) == CANCEL
) {
if (!(wand
= get_letter_object(wch
))) {
message("no such item.", 0);
if (wand
->what_is
!= WAND
) {
message("you can't zap with that", 0);
message("nothing happens", 0);
row
= rogue
.row
; col
= rogue
.col
;
if ((wand
->which_kind
== COLD
) || (wand
->which_kind
== FIRE
)) {
bounce((short) wand
->which_kind
, d
, row
, col
, 0);
monster
= get_zapped_monster(d
, &row
, &col
);
if (wand
->which_kind
== DRAIN_LIFE
) {
zap_monster(monster
, wand
->which_kind
);
get_zapped_monster(dir
, row
, col
)
orow
= *row
; ocol
= *col
;
get_dir_rc(dir
, row
, col
, 0);
if (((*row
== orow
) && (*col
== ocol
)) ||
(dungeon
[*row
][*col
] & (HORWALL
| VERTWALL
)) ||
(dungeon
[*row
][*col
] == NOTHING
)) {
if (dungeon
[*row
][*col
] & MONSTER
) {
if (!imitating(*row
, *col
)) {
return(object_at(&level_monsters
, *row
, *col
));
zap_monster(monster
, kind
)
if (monster
->m_flags
& HASTED
) {
monster
->m_flags
&= (~HASTED
);
monster
->slowed_toggle
= 0;
monster
->m_flags
|= SLOWED
;
if (monster
->m_flags
& SLOWED
) {
monster
->m_flags
&= (~SLOWED
);
monster
->m_flags
|= HASTED
;
monster
->m_flags
|= INVISIBLE
;
if (monster
->m_flags
& HOLDS
) {
nm
= monster
->next_monster
;
tc
= monster
->trail_char
;
(void) gr_monster(monster
, get_rand(0, MONSTERS
-1));
monster
->next_monster
= nm
;
monster
->trail_char
= tc
;
if (!(monster
->m_flags
& IMITATES
)) {
if (monster
->m_flags
& HOLDS
) {
if (monster
->m_flags
& STEALS_ITEM
) {
monster
->drop_percent
= 0;
monster
->m_flags
&= (~(FLIES
| FLITS
| SPECIAL_HIT
| INVISIBLE
|
FLAMES
| IMITATES
| CONFUSES
| SEEKS_GOLD
| HOLDS
));
message("nothing happens", 0);
if (monster
->m_flags
& HOLDS
) {
gr_row_col(&row
, &col
, (FLOOR
| TUNNEL
| STAIRS
| OBJECT
));
mvaddch(monster
->row
, monster
->col
, monster
->trail_char
);
dungeon
[monster
->row
][monster
->col
] &= ~MONSTER
;
monster
->row
= row
; monster
->col
= col
;
dungeon
[row
][col
] |= MONSTER
;
monster
->trail_char
= mvinch(row
, col
);
if (detect_monster
|| rogue_can_see(row
, col
)) {
mvaddch(row
, col
, gmc(monster
));
message("not wizard anymore", 0);
if (get_input_line("wizard's password:", "", buf
, "", 0, 0)) {
if (!strncmp(buf
, "\247\104\126\272\115\243\027", 7)) {
message("Welcome, mighty wizard!", 0);
hp
= rogue
.hp_current
/ 3;
rogue
.hp_current
= (rogue
.hp_current
+ 1) / 2;
lmon
= level_monsters
.next_monster
;
if (get_room_number(lmon
->row
, lmon
->col
) == cur_room
) {
(void) mon_damage(lmon
, hp
);
(void) mon_damage(monster
, hp
);
bounce(ball
, dir
, row
, col
, r
)
short ball
, dir
, row
, col
, r
;
short i
, ch
, new_dir
= -1, damage
;
sprintf(buf
, "the %s bounces", s
);
get_dir_rc(dir
, &orow
, &ocol
, 1);
} while (!( (ocol
<= 0) ||
(dungeon
[orow
][ocol
] == NOTHING
) ||
(dungeon
[orow
][ocol
] & MONSTER
) ||
(dungeon
[orow
][ocol
] & (HORWALL
| VERTWALL
)) ||
((orow
== rogue
.row
) && (ocol
== rogue
.col
))));
get_dir_rc(dir
, &row
, &col
, 1);
} while (!( (col
<= 0) ||
(dungeon
[row
][col
] == NOTHING
) ||
(dungeon
[row
][col
] & MONSTER
) ||
(dungeon
[row
][col
] & (HORWALL
| VERTWALL
)) ||
((row
== rogue
.row
) && (col
== rogue
.col
))));
if (dungeon
[row
][col
] & MONSTER
) {
monster
= object_at(&level_monsters
, row
, col
);
sprintf(buf
, "the %s misses the %s", s
, mon_name(monster
));
if (!(monster
->m_flags
& RUSTS
)) {
if (monster
->m_flags
& FREEZES
) {
damage
= monster
->hp_to_kill
;
} else if (monster
->m_flags
& FLAMES
) {
damage
= (monster
->hp_to_kill
/ 10) + 1;
damage
= get_rand((rogue
.hp_current
/ 3), rogue
.hp_max
);
damage
= (monster
->hp_to_kill
/ 2) + 1;
sprintf(buf
, "the %s hits the %s", s
, mon_name(monster
));
(void) mon_damage(monster
, damage
);
if (!(monster
->m_flags
& FREEZES
)) {
message("the monster is frozen", 0);
monster
->m_flags
|= (ASLEEP
| NAPPING
);
monster
->nap_length
= get_rand(3, 6);
damage
= rogue
.hp_current
/ 4;
sprintf(buf
, "the %s hits the %s", s
, mon_name(monster
));
(void) mon_damage(monster
, damage
);
} else if ((row
== rogue
.row
) && (col
== rogue
.col
)) {
if (rand_percent(10 + (3 * get_armor_class(rogue
.armor
)))) {
sprintf(buf
, "the %s misses", s
);
damage
= get_rand(3, (3 * rogue
.exp
));
damage
= (damage
* 3) / 2;
damage
-= get_armor_class(rogue
.armor
);
sprintf(buf
, "the %s hits", s
);
rogue_damage(damage
, (object
*) 0,
((ball
== FIRE
) ? KFIRE
: HYPOTHERMIA
));
ND
: for (i
= 0; i
< 10; i
++) {
dir
= get_rand(0, DIRS
-1);
get_dir_rc(dir
, &nrow
, &ncol
, 1);
if (((ncol
>= 0) && (ncol
<= DCOLS
-1)) &&
(dungeon
[nrow
][ncol
] != NOTHING
) &&
(!(dungeon
[nrow
][ncol
] & (VERTWALL
| HORWALL
)))) {
bounce(ball
, new_dir
, orow
, ocol
, r
);