From bd3244835e08813368e2caddf9fcc569dbc05c63 Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 8 Oct 2015 02:19:58 -0700 Subject: [PATCH] spell of protection Another item from the "A few bugs" mail. Casting spell of protection when previous casting(s) hadn't timed out yet miscalculated the new AC boost. At low levels--when this spell probably gets its most use--the bug wasn't noticeable. (At high levels when someone might cast it a whole bunch of times in succession, the effect could be noticed but was probably just assumed to be working as intended. Its behavior is somewhat convoluted.) --- doc/fixes36.0 | 2 ++ src/spell.c | 49 ++++++++++++++++++++++++++----------------------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/doc/fixes36.0 b/doc/fixes36.0 index b998d2c35..3c1e14a1b 100644 --- a/doc/fixes36.0 +++ b/doc/fixes36.0 @@ -924,6 +924,8 @@ you shouldn't see Sting glow light blue if you're blind when jumping, bumping into something is noisy flesh golems hit by electricity healed by wrong amount fleeing monsters couldn't use stairs that lead to different dungeon branch +casting spell of protection when previous casting(s) hadn't time out yet + miscalculated the new AC increment Platform- and/or Interface-Specific Fixes diff --git a/src/spell.c b/src/spell.c index d8c7a1b32..877fb255a 100644 --- a/src/spell.c +++ b/src/spell.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 spell.c $NHDT-Date: 1434421353 2015/06/16 02:22:33 $ $NHDT-Branch: master $:$NHDT-Revision: 1.63 $ */ +/* NetHack 3.6 spell.c $NHDT-Date: 1444295991 2015/10/08 09:19:51 $ $NHDT-Branch: master $:$NHDT-Revision: 1.64 $ */ /* Copyright (c) M. Stephenson 1988 */ /* NetHack may be freely redistributed. See license for details. */ @@ -720,10 +720,10 @@ int booktype; STATIC_OVL void cast_protection() { - int loglev = 0; - int l = u.ulevel; - int natac = u.uac - u.uspellprot; - int gain; + int l = u.ulevel, loglev = 0, + gain, natac = u.uac + u.uspellprot; + /* note: u.uspellprot is subtracted when find_ac() factors it into u.uac, + so adding here factors it back out (3.4.3,3.5 had this backwards) */ /* loglev=log2(u.ulevel)+1 (1..5) */ while (l) { @@ -752,7 +752,8 @@ cast_protection() * 16-30 0 0, 5, 9, 11, 13, 14, 15 * 16-30 -10 0, 5, 8, 9, 10 */ - gain = loglev - (int) u.uspellprot / (4 - min(3, (10 - natac) / 10)); + natac = (10 - natac) / 10; /* convert to positive and scale down */ + gain = loglev - (int) u.uspellprot / (4 - min(3, natac)); if (gain > 0) { if (!Blind) { @@ -763,28 +764,30 @@ cast_protection() pline_The("%s haze around you becomes more dense.", hgolden); } else { rmtyp = levl[u.ux][u.uy].typ; - atmosphere = - u.uswallow - ? ((u.ustuck->data == &mons[PM_FOG_CLOUD]) - ? "mist" - : is_whirly(u.ustuck->data) - ? "maelstrom" - : is_animal(u.ustuck->data) ? "maw" - : "ooze") - : u.uinwater ? "water" : (rmtyp == CLOUD) - ? "cloud" - : IS_TREE(rmtyp) - ? "vegitation" - : IS_STWALL(rmtyp) - ? "stone" - : "air"; + atmosphere = u.uswallow + ? ((u.ustuck->data == &mons[PM_FOG_CLOUD]) + ? "mist" + : is_whirly(u.ustuck->data) + ? "maelstrom" + : is_animal(u.ustuck->data) + ? "maw" + : "ooze") + : (u.uinwater + ? "water" + : (rmtyp == CLOUD) + ? "cloud" + : IS_TREE(rmtyp) + ? "vegitation" + : IS_STWALL(rmtyp) + ? "stone" + : "air"); pline_The("%s around you begins to shimmer with %s haze.", atmosphere, an(hgolden)); } } u.uspellprot += gain; - u.uspmtime = - P_SKILL(spell_skilltype(SPE_PROTECTION)) == P_EXPERT ? 20 : 10; + u.uspmtime = (P_SKILL(spell_skilltype(SPE_PROTECTION)) == P_EXPERT) + ? 20 : 10; if (!u.usptime) u.usptime = u.uspmtime; find_ac();