From 82fc66da0e9371c2cb5752b231854fc215421249 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 31 Mar 2023 10:59:48 -0700 Subject: [PATCH] wands zapped by monsters Reverse part of commit 4021a63bcf36f1ea78e7c34d43c2e22d9835eca6 "wand/spell/breath killer reason" so that wand of magic missile zapped by a monster isn't ambiguous about who is responsible. --- include/hack.h | 14 +++++++------- src/zap.c | 10 ++++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/include/hack.h b/include/hack.h index b1d26d0f2..13de5e507 100644 --- a/include/hack.h +++ b/include/hack.h @@ -673,17 +673,17 @@ enum getobj_callback_returns { #define BZ_OFS_WAN(otyp) (abs((otyp) - WAN_MAGIC_MISSILE) % 10) #define BZ_OFS_SPE(otyp) (abs((otyp) - SPE_MAGIC_MISSILE) % 10) /* hero shooting a wand */ -#define BZ_U_WAND(bztyp) (0 + (bztyp)) +#define BZ_U_WAND(bztyp) (0 + (bztyp)) /* 0..9 */ /* hero casting a spell */ -#define BZ_U_SPELL(bztyp) (10 + (bztyp)) +#define BZ_U_SPELL(bztyp) (10 + (bztyp)) /* 10..19 */ /* hero breathing as a monster */ -#define BZ_U_BREATH(bztyp) (20 + (bztyp)) -/* monster shooting a wand */ -#define BZ_M_WAND(bztyp) (-0 - (bztyp)) +#define BZ_U_BREATH(bztyp) (20 + (bztyp)) /* 20..29 */ /* monster casting a spell */ -#define BZ_M_SPELL(bztyp) (-10 - (bztyp)) +#define BZ_M_SPELL(bztyp) (-10 - (bztyp)) /* -19..-10 */ /* monster breathing */ -#define BZ_M_BREATH(bztyp) (-20 - (bztyp)) +#define BZ_M_BREATH(bztyp) (-20 - (bztyp)) /* -29..-20 */ +/* monster shooting a wand; note: not -9 to -0 because -0 is ambiguous */ +#define BZ_M_WAND(bztyp) (-30 - (bztyp)) /* -39..-30 */ /* * option setting restrictions diff --git a/src/zap.c b/src/zap.c index 0658c83e9..c6fc893bc 100644 --- a/src/zap.c +++ b/src/zap.c @@ -55,12 +55,10 @@ static void wishcmdassist(int); static const char are_blinded_by_the_flash[] = "are blinded by the flash!"; /* - * FIXME: - * flash_types[0] for wand of magic missile is ambiguous. - * A positive index means zapped/cast/breathed by hero. - * A negative index means zapped/cast/breathed by a monster. - * Since abs(-0)==abs(0), there's no way to tell who zapped a wand of - * magic missile by just checking the index. + * A positive index means zapped/cast/breathed by hero. + * A negative index means zapped/cast/breathed by a monster, with value + * index fixup beyond abs() needed for wand zaps. Wand zaps for monster + * use -39..-30 rather than -9..-0 because -0 is ambiguous (same as 0). */ static const char *const flash_types[] = { "magic missile", /* Wands must be 0-9 */