+/* $NetBSD: zap.c,v 1.9 2008/01/14 03:50:03 dholland Exp $ */
+
/*
- * Copyright (c) 1988 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Timothy C. Stoehr.
* 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
+ * 3. 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.
*
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-/*static char sccsid[] = "from: @(#)zap.c 5.3 (Berkeley) 6/1/90";*/
-static char rcsid[] = "$Id: zap.c,v 1.2 1993/08/01 18:52:07 mycroft Exp $";
+#if 0
+static char sccsid[] = "@(#)zap.c 8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: zap.c,v 1.9 2008/01/14 03:50:03 dholland Exp $");
+#endif
#endif /* not lint */
/*
#include "rogue.h"
-boolean wizard = 0;
+static object *get_zapped_monster(short, short *, short *);
+static void tele_away(object *);
+static void wdrain_life(object *);
+static void zap_monster(object *, unsigned short);
-extern boolean being_held, score_only, detect_monster;
-extern short cur_room;
+boolean wizard = 0;
-zapp()
+void
+zapp(void)
{
short wch;
boolean first_miss = 1;
while (!is_direction(dir = rgetchar(), &d)) {
sound_bell();
if (first_miss) {
- message("direction? ", 0);
+ messagef(0, "direction? ");
first_miss = 0;
}
}
check_message();
if (!(wand = get_letter_object(wch))) {
- message("no such item.", 0);
+ messagef(0, "no such item.");
return;
}
if (wand->what_is != WAND) {
- message("you can't zap with that", 0);
+ messagef(0, "you can't zap with that");
return;
}
if (wand->class <= 0) {
- message("nothing happens", 0);
+ messagef(0, "nothing happens");
} else {
wand->class--;
row = rogue.row; col = rogue.col;
if ((wand->which_kind == COLD) || (wand->which_kind == FIRE)) {
- bounce((short) wand->which_kind, d, row, col, 0);
+ bounce((short)wand->which_kind, d, row, col, 0);
} else {
monster = get_zapped_monster(d, &row, &col);
if (wand->which_kind == DRAIN_LIFE) {
}
}
}
- (void) reg_move();
+ (void)reg_move();
}
-object *
-get_zapped_monster(dir, row, col)
-short dir;
-short *row, *col;
+static object *
+get_zapped_monster(short dir, short *row, short *col)
{
short orow, ocol;
}
}
-zap_monster(monster, kind)
-object *monster;
-unsigned short kind;
+static void
+zap_monster(object *monster, unsigned short kind)
{
short row, col;
object *nm;
}
nm = monster->next_monster;
tc = monster->trail_char;
- (void) gr_monster(monster, get_rand(0, MONSTERS-1));
+ (void)gr_monster(monster, get_rand(0, MONSTERS-1));
monster->row = row;
monster->col = col;
monster->next_monster = nm;
FLAMES | IMITATES | CONFUSES | SEEKS_GOLD | HOLDS));
break;
case DO_NOTHING:
- message("nothing happens", 0);
+ messagef(0, "nothing happens");
break;
}
}
-tele_away(monster)
-object *monster;
+static void
+tele_away(object *monster)
{
short row, col;
}
}
-wizardize()
+void
+wizardize(void)
{
char buf[100];
if (wizard) {
wizard = 0;
- message("not wizard anymore", 0);
+ messagef(0, "not wizard anymore");
} else {
- if (get_input_line("wizard's password:", "", buf, "", 0, 0)) {
- (void) xxx(1);
+ if (get_input_line("wizard's password:", "", buf, sizeof(buf),
+ "", 0, 0)) {
+ (void)xxx(1);
xxxx(buf, strlen(buf));
if (!strncmp(buf, "\247\104\126\272\115\243\027", 7)) {
wizard = 1;
score_only = 1;
- message("Welcome, mighty wizard!", 0);
+ messagef(0, "Welcome, mighty wizard!");
} else {
- message("sorry", 0);
+ messagef(0, "sorry");
}
}
}
}
-wdrain_life(monster)
-object *monster;
+static void
+wdrain_life(object *monster)
{
short hp;
object *lmon, *nm;
nm = lmon->next_monster;
if (get_room_number(lmon->row, lmon->col) == cur_room) {
wake_up(lmon);
- (void) mon_damage(lmon, hp);
+ (void)mon_damage(lmon, hp);
}
lmon = nm;
}
} else {
if (monster) {
wake_up(monster);
- (void) mon_damage(monster, hp);
+ (void)mon_damage(monster, hp);
}
}
print_stats(STAT_HP);
relight();
}
-bounce(ball, dir, row, col, r)
-short ball, dir, row, col, r;
+void
+bounce(short ball, short dir, short row, short col, short r)
{
short orow, ocol;
- char buf[DCOLS], *s;
+ const char *s;
short i, ch, new_dir = -1, damage;
static short btime;
s = "ice";
}
if (r > 1) {
- sprintf(buf, "the %s bounces", s);
- message(buf, 0);
+ messagef(0, "the %s bounces", s);
}
orow = row;
ocol = col;
wake_up(monster);
if (rand_percent(33)) {
- sprintf(buf, "the %s misses the %s", s, mon_name(monster));
- message(buf, 0);
+ messagef(0, "the %s misses the %s", s,
+ mon_name(monster));
goto ND;
}
if (ball == FIRE) {
} else {
damage = (monster->hp_to_kill / 2) + 1;
}
- sprintf(buf, "the %s hits the %s", s, mon_name(monster));
- message(buf, 0);
- (void) mon_damage(monster, damage);
+ messagef(0, "the %s hits the %s", s,
+ mon_name(monster));
+ (void)mon_damage(monster, damage);
} else {
damage = -1;
if (!(monster->m_flags & FREEZES)) {
if (rand_percent(33)) {
- message("the monster is frozen", 0);
+ messagef(0, "the monster is frozen");
monster->m_flags |= (ASLEEP | NAPPING);
monster->nap_length = get_rand(3, 6);
} else {
damage = -2;
}
if (damage != -1) {
- sprintf(buf, "the %s hits the %s", s, mon_name(monster));
- message(buf, 0);
- (void) mon_damage(monster, damage);
+ messagef(0, "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);
- message(buf, 0);
+ messagef(0, "the %s misses", s);
goto ND;
} else {
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,
+ rogue_damage(damage, NULL,
((ball == FIRE) ? KFIRE : HYPOTHERMIA));
- message(buf, 0);
+ messagef(0, "the %s hits", s);
}
} else {
short nrow, ncol;