From eb9d19497dca0360a3e79066034036e4c2982133 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Fri, 26 May 2006 03:31:57 +0000 Subject: [PATCH] enlightment for protection and magic cancellation (trunk only) The bug report about losing/regaining the Protection intrinsic reminded me of a couple of things. First, as an intrinsic, Protection seems to be completely useless and we ought to redo it. Second, periodically people in the newsgroup have complained about how it's nearly impossible to figure out the important--possibly crucial--armor attribute of magic cancellation. Wearing a cloak greatly increases characters' survival rates, but beyond that, magic cancellation is just spoiler fodder. This doesn't do much about Protection other than to change "you are protected" into "you have a defense bonus" similar to how the attributes conferred by rings of increase damage and increase accuracy are handled. For magic cancellation, it adds new feedback: You are protected. -- mc factor 3 You are guarded. -- mc factor 2 You are warded. -- mc factor 1 (with no extra feedback for mc factor 0, the normal naked state. The mc 3 case might cause some confusion over the changed meaning of a previously existing item, but I think it'll be ok and not need re-wording.) --- doc/fixes35.0 | 1 + src/cmd.c | 68 ++++++++++++++++++++++++++++----------------------- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/doc/fixes35.0 b/doc/fixes35.0 index 038d9ff41..4d1c28bd4 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -207,6 +207,7 @@ digging can activate or disarm some types of traps some monsters can eat tins in addition to corpses to cure some ailments add Roderick Schertler's pickup_thrown patch add ability to sort the list when viewing known spells with '+' command +describe magic cancellation from worn armor in enlightment/end-of-game feedback Platform- and/or Interface-Specific New Features diff --git a/src/cmd.c b/src/cmd.c index 76028a6e2..2388a0421 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -985,7 +985,7 @@ char *ps; putstr(en_win, 0, buf); } -/* format increased damage or chance to hit */ +/* format increased chance to hit or damage or defense (Protection) */ static char * enlght_combatinc(inctyp, incamt, final, outbuf) const char *inctyp; @@ -994,31 +994,30 @@ char *outbuf; { char numbuf[24]; const char *modif, *bonus; + boolean invrt; + int absamt; - if (final -#ifdef WIZARD - || wizard -#endif - ) { - Sprintf(numbuf, "%s%d", - (incamt > 0) ? "+" : "", incamt); - modif = (const char *) numbuf; - } else { - int absamt = abs(incamt); + absamt = abs(incamt); + /* Protection amount is typically larger than damage or to-hit; + reduce magnitude by a third in order to stretch modifier ranges + (small:1..5, moderate:6..10, large:11..19, huge:20+) */ + if (!strcmp(inctyp, "defense")) absamt = (absamt * 2) / 3; + + if (absamt <= 3) modif = "small"; + else if (absamt <= 6) modif = "moderate"; + else if (absamt <= 12) modif = "large"; + else modif = "huge"; - if (absamt <= 3) modif = "small"; - else if (absamt <= 6) modif = "moderate"; - else if (absamt <= 12) modif = "large"; - else modif = "huge"; - } bonus = (incamt > 0) ? "bonus" : "penalty"; - /* "bonus to hit" vs "damage bonus" */ - if (!strcmp(inctyp, "damage")) { - const char *ctmp = inctyp; - inctyp = bonus; - bonus = ctmp; - } - Sprintf(outbuf, "%s %s %s", an(modif), bonus, inctyp); + /* "bonus " (to hit) vs " bonus" (damage, defense) */ + invrt = strcmp(inctyp, "to hit") ? TRUE : FALSE; + + Sprintf(outbuf, "%s %s %s", an(modif), + invrt ? inctyp : bonus, invrt ? bonus : inctyp); + if (final || wizard) + Sprintf(eos(outbuf), " (%s%d)", + (incamt > 0) ? "+" : "", incamt); + return outbuf; } @@ -1026,7 +1025,7 @@ void enlightenment(final) int final; /* 0 => still in progress; 1 => over, survived; 2 => dead */ { - int ltmp; + int ltmp, armpro; char buf[BUFSZ]; en_win = create_nhwindow(NHW_MENU); @@ -1221,12 +1220,14 @@ int final; /* 0 => still in progress; 1 => over, survived; 2 => dead */ } /*** Physical attributes ***/ + if (Regeneration) + enl_msg("You regenerate", "", "d", "",from_what(REGENERATION)); + if (Slow_digestion) + you_have("slower digestion",from_what(SLOW_DIGESTION)); if (u.uhitinc) you_have(enlght_combatinc("to hit", u.uhitinc, final, buf),""); if (u.udaminc) you_have(enlght_combatinc("damage", u.udaminc, final, buf),""); - if (Slow_digestion) you_have("slower digestion",from_what(SLOW_DIGESTION)); - if (Regeneration) enl_msg("You regenerate", "", "d", "",from_what(REGENERATION)); if (u.uspellprot || Protection) { int prot = 0; @@ -1234,11 +1235,16 @@ int final; /* 0 => still in progress; 1 => over, survived; 2 => dead */ if(uright && uright->otyp == RIN_PROTECTION) prot += uright->spe; if (HProtection & INTRINSIC) prot += u.ublessed; prot += u.uspellprot; - - if (prot < 0) - you_are("ineffectively protected",""); - else - you_are("protected",""); + you_have(enlght_combatinc("defense", prot, final, buf), ""); + } + if ((armpro = magic_negation(&youmonst)) > 0) { + /* magic cancellation factor, conferred by worn armor */ + static const char * const mc_types[] = { + "" /*ordinary*/, "warded", "guarded", "protected", + }; + /* sanity check */ + if (armpro >= SIZE(mc_types)) armpro = SIZE(mc_types) - 1; + you_are(mc_types[armpro],""); } if (Protection_from_shape_changers) you_are("protected from shape changers",""); -- 2.40.0