From: nethack.rankin Date: Thu, 7 Apr 2011 18:10:47 +0000 (+0000) Subject: Protection groundwork/artifact tweaks (trunk only) X-Git-Tag: MOVE2GIT~226 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=33d9b7131157bf54188c2cee1c8d0a78cbede9fe;p=nethack Protection groundwork/artifact tweaks (trunk only) This is mostly groundwork prior to making the Protection intrinsic become more meaningful. The Mitre of Holiness (priest quest artifact) and the Tsurugi of Muramasa (samurai quest artifact) will now confer Protection when worn/wielded (though at present that effectively does nothing). While in there, this also changes the Eye of the Aethiopica (wizard quest artifact), the Eyes of the Overworld (monk quest artifact), and the Sceptre of Might (caveman quest artifact) so that they need to be worn/wielded rather than just carried in order for them to confer magic resistance. That way they're a little less attractive for wishing by other roles and a little more likely to be actively used by their own roles (not an issues for the Eyes, I'm sure). This change actually works to the player's advantage, since it means that monsters who successfully steal those items won't instantly obtain magic resistance in the process. This adds protects() as a predicate routine to check an item for conferring Protection. In order to do that, it renames the existing protects() routine to defends_when_carried(), because that predicate is actually a variant of defends() for items which aren't worn or wielded. --- diff --git a/doc/fixes35.0 b/doc/fixes35.0 index f1095ecde..b96003082 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -350,6 +350,9 @@ teleport control and polymorph control are ineffective while hero is stunned don't report "fried to a crisp" for disintegration from divine wrath spellcasting monsters' spell selection became less likely to choose harder spells as their level got higher (including Wizard's "double trouble") +Eye of the Aethiopica, Eyes of the Overworld, and Sceptre of Might must be + worn or wielded rather than just carried to convey magic resistance +Mitre of Holiness and Tsurugi of Muramasa convey Protection when worn/wielded Platform- and/or Interface-Specific Fixes diff --git a/include/artifact.h b/include/artifact.h index a963840d5..0fbdc9a42 100644 --- a/include/artifact.h +++ b/include/artifact.h @@ -1,41 +1,40 @@ /* NetHack 3.5 artifact.h $Date$ $Revision$ */ -/* SCCS Id: @(#)artifact.h 3.5 1995/05/31 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ #ifndef ARTIFACT_H #define ARTIFACT_H -#define SPFX_NONE 0x0000000L /* no special effects, just a bonus */ -#define SPFX_NOGEN 0x0000001L /* item is special, bequeathed by gods */ -#define SPFX_RESTR 0x0000002L /* item is restricted - can't be named */ -#define SPFX_INTEL 0x0000004L /* item is self-willed - intelligent */ -#define SPFX_SPEAK 0x0000008L /* item can speak (not implemented) */ -#define SPFX_SEEK 0x0000010L /* item helps you search for things */ -#define SPFX_WARN 0x0000020L /* item warns you of danger */ -#define SPFX_ATTK 0x0000040L /* item has a special attack (attk) */ -#define SPFX_DEFN 0x0000080L /* item has a special defence (defn) */ -#define SPFX_DRLI 0x0000100L /* drains a level from monsters */ -#define SPFX_SEARCH 0x0000200L /* helps searching */ -#define SPFX_BEHEAD 0x0000400L /* beheads monsters */ -#define SPFX_HALRES 0x0000800L /* blocks hallucinations */ -#define SPFX_ESP 0x0001000L /* ESP (like amulet of ESP) */ -#define SPFX_STLTH 0x0002000L /* Stealth */ -#define SPFX_REGEN 0x0004000L /* Regeneration */ -#define SPFX_EREGEN 0x0008000L /* Energy Regeneration */ -#define SPFX_HSPDAM 0x0010000L /* 1/2 spell damage (on player) in combat */ -#define SPFX_HPHDAM 0x0020000L /* 1/2 physical damage (on player) in combat */ -#define SPFX_TCTRL 0x0040000L /* Teleportation Control */ -#define SPFX_LUCK 0x0080000L /* Increase Luck (like Luckstone) */ -#define SPFX_DMONS 0x0100000L /* attack bonus on one monster type */ -#define SPFX_DCLAS 0x0200000L /* attack bonus on monsters w/ symbol mtype */ -#define SPFX_DFLAG1 0x0400000L /* attack bonus on monsters w/ mflags1 flag */ -#define SPFX_DFLAG2 0x0800000L /* attack bonus on monsters w/ mflags2 flag */ -#define SPFX_DALIGN 0x1000000L /* attack bonus on non-aligned monsters */ -#define SPFX_DBONUS 0x1F00000L /* attack bonus mask */ -#define SPFX_XRAY 0x2000000L /* gives X-RAY vision to player */ -#define SPFX_REFLECT 0x4000000L /* Reflection */ - +#define SPFX_NONE 0x00000000L /* no special effects, just a bonus */ +#define SPFX_NOGEN 0x00000001L /* item is special, bequeathed by gods */ +#define SPFX_RESTR 0x00000002L /* item is restricted - can't be named */ +#define SPFX_INTEL 0x00000004L /* item is self-willed - intelligent */ +#define SPFX_SPEAK 0x00000008L /* item can speak (not implemented) */ +#define SPFX_SEEK 0x00000010L /* item helps you search for things */ +#define SPFX_WARN 0x00000020L /* item warns you of danger */ +#define SPFX_ATTK 0x00000040L /* item has a special attack (attk) */ +#define SPFX_DEFN 0x00000080L /* item has a special defence (defn) */ +#define SPFX_DRLI 0x00000100L /* drains a level from monsters */ +#define SPFX_SEARCH 0x00000200L /* helps searching */ +#define SPFX_BEHEAD 0x00000400L /* beheads monsters */ +#define SPFX_HALRES 0x00000800L /* blocks hallucinations */ +#define SPFX_ESP 0x00001000L /* ESP (like amulet of ESP) */ +#define SPFX_STLTH 0x00002000L /* Stealth */ +#define SPFX_REGEN 0x00004000L /* Regeneration */ +#define SPFX_EREGEN 0x00008000L /* Energy Regeneration */ +#define SPFX_HSPDAM 0x00010000L /* 1/2 spell damage (on player) in combat */ +#define SPFX_HPHDAM 0x00020000L /* 1/2 physical damage (on player) in combat */ +#define SPFX_TCTRL 0x00040000L /* Teleportation Control */ +#define SPFX_LUCK 0x00080000L /* Increase Luck (like Luckstone) */ +#define SPFX_DMONS 0x00100000L /* attack bonus on one monster type */ +#define SPFX_DCLAS 0x00200000L /* attack bonus on monsters w/ symbol mtype */ +#define SPFX_DFLAG1 0x00400000L /* attack bonus on monsters w/ mflags1 flag */ +#define SPFX_DFLAG2 0x00800000L /* attack bonus on monsters w/ mflags2 flag */ +#define SPFX_DALIGN 0x01000000L /* attack bonus on non-aligned monsters */ +#define SPFX_DBONUS 0x01F00000L /* attack bonus mask */ +#define SPFX_XRAY 0x02000000L /* gives X-RAY vision to player */ +#define SPFX_REFLECT 0x04000000L /* Reflection */ +#define SPFX_PROTECT 0x08000000L /* Protection */ struct artifact { short otyp; diff --git a/include/artilist.h b/include/artilist.h index dc42facce..0996b1fe0 100644 --- a/include/artilist.h +++ b/include/artilist.h @@ -1,5 +1,4 @@ /* NetHack 3.5 artilist.h $Date$ $Revision$ */ -/* SCCS Id: @(#)artilist.h 3.5 2003/02/12 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -166,7 +165,7 @@ A("The Heart of Ahriman", LUCKSTONE, A("The Sceptre of Might", MACE, (SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL|SPFX_DALIGN), 0, 0, - PHYS(5,0), NO_DFNS, CARY(AD_MAGM), + PHYS(5,0), DFNS(AD_MAGM), NO_CARY, CONFLICT, A_LAWFUL, PM_CAVEMAN, NON_PM, 2500L ), #if 0 /* OBSOLETE */ @@ -189,11 +188,12 @@ A("The Magic Mirror of Merlin", MIRROR, A("The Eyes of the Overworld", LENSES, (SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL|SPFX_XRAY), 0, 0, - NO_ATTK, NO_DFNS, CARY(AD_MAGM), + NO_ATTK, DFNS(AD_MAGM), NO_CARY, ENLIGHTENING, A_NEUTRAL, PM_MONK, NON_PM, 2500L ), A("The Mitre of Holiness", HELM_OF_BRILLIANCE, - (SPFX_NOGEN|SPFX_RESTR|SPFX_DFLAG2|SPFX_INTEL), 0, M2_UNDEAD, + (SPFX_NOGEN|SPFX_RESTR|SPFX_DFLAG2|SPFX_INTEL|SPFX_PROTECT), + 0, M2_UNDEAD, NO_ATTK, NO_DFNS, CARY(AD_FIRE), ENERGY_BOOST, A_LAWFUL, PM_PRIEST, NON_PM, 2000L ), @@ -209,7 +209,8 @@ A("The Master Key of Thievery", SKELETON_KEY, UNTRAP, A_CHAOTIC, PM_ROGUE, NON_PM, 3500L ), A("The Tsurugi of Muramasa", TSURUGI, - (SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL|SPFX_BEHEAD|SPFX_LUCK), 0, 0, + (SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL|SPFX_BEHEAD|SPFX_LUCK|SPFX_PROTECT), + 0, 0, PHYS(0,8), NO_DFNS, NO_CARY, 0, A_LAWFUL, PM_SAMURAI, NON_PM, 4500L ), @@ -229,7 +230,7 @@ A("The Orb of Fate", CRYSTAL_BALL, A("The Eye of the Aethiopica", AMULET_OF_ESP, (SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL), (SPFX_EREGEN|SPFX_HSPDAM), 0, - NO_ATTK, NO_DFNS, CARY(AD_MAGM), + NO_ATTK, DFNS(AD_MAGM), NO_CARY, CREATE_PORTAL, A_NEUTRAL, PM_WIZARD, NON_PM, 4000L ), /* diff --git a/include/extern.h b/include/extern.h index 780876469..943366b8b 100644 --- a/include/extern.h +++ b/include/extern.h @@ -67,7 +67,8 @@ E boolean FDECL(arti_reflects, (struct obj *)); E boolean FDECL(shade_glare, (struct obj *)); E boolean FDECL(restrict_name, (struct obj *,const char *)); E boolean FDECL(defends, (int,struct obj *)); -E boolean FDECL(protects, (int,struct obj *)); +E boolean FDECL(defends_when_carried, (int,struct obj *)); +E boolean FDECL(protects, (struct obj *,BOOLEAN_P)); E void FDECL(set_artifact_intrinsic, (struct obj *,BOOLEAN_P,long)); E int FDECL(touch_artifact, (struct obj *,struct monst *)); E int FDECL(spec_abon, (struct obj *,struct monst *)); diff --git a/src/artifact.c b/src/artifact.c index 4c5cce391..a20682ac3 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -1,5 +1,4 @@ /* NetHack 3.5 artifact.c $Date$ $Revision$ */ -/* SCCS Id: @(#)artifact.c 3.5 2008/02/19 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -407,7 +406,7 @@ register struct obj *otmp; /* used for monsters */ boolean -protects(adtyp, otmp) +defends_when_carried(adtyp, otmp) int adtyp; struct obj *otmp; { @@ -418,6 +417,22 @@ struct obj *otmp; return FALSE; } +/* determine whether an item confers Protection */ +boolean +protects(otmp, is_worn) +struct obj *otmp; +boolean is_worn; +{ + const struct artifact *arti; + + if (is_worn && objects[otmp->oclass].oc_oprop == PROTECTION) + return TRUE; + arti = get_artifact(otmp); + if (!arti) return FALSE; + return (arti->cspfx & SPFX_PROTECT) != 0 || + (is_worn && (arti->spfx & SPFX_PROTECT) != 0); +} + /* * a potential artifact has just been worn/wielded/picked-up or * unworn/unwielded/dropped. Pickup/drop only set/reset the W_ART mask. @@ -548,6 +563,10 @@ long wp_mask; if (on) EReflecting |= wp_mask; else EReflecting &= ~wp_mask; } + if (spfx & SPFX_PROTECT) { + if (on) EProtection |= wp_mask; + else EProtection &= ~wp_mask; + } if(wp_mask == W_ART && !on && oart->inv_prop) { /* might have to turn off invoked power too */ diff --git a/src/mondata.c b/src/mondata.c index d2f5b03ab..e4203297c 100644 --- a/src/mondata.c +++ b/src/mondata.c @@ -113,7 +113,7 @@ struct monst *mon; for ( ; o; o = o->nobj) if (((o->owornmask & slotmask) != 0L && objects[o->otyp].oc_oprop == ANTIMAGIC) || - (o->oartifact && protects(AD_MAGM, o))) + (o->oartifact && defends_when_carried(AD_MAGM, o))) return TRUE; return FALSE; } @@ -150,7 +150,7 @@ struct monst *mon; for ( ; o; o = o->nobj) if (((o->owornmask & slotmask) != 0L && objects[o->otyp].oc_oprop == BLINDED) || - (o->oartifact && protects(AD_BLND, o))) + (o->oartifact && defends_when_carried(AD_BLND, o))) return TRUE; return FALSE; } diff --git a/src/trap.c b/src/trap.c index 51cf074d7..8ef4a10df 100644 --- a/src/trap.c +++ b/src/trap.c @@ -1231,7 +1231,7 @@ glovecheck: (void) rust_dmg(uarmg, "gauntlets", 1, TRUE, &youmonst); also increases the effect */ for (otmp = invent; otmp; otmp = otmp->nobj) if (otmp->oartifact && !is_quest_artifact(otmp) && - protects(AD_MAGM, otmp)) break; + defends_when_carried(AD_MAGM, otmp)) break; if (otmp) dmgval2 += rnd(4); if (Passes_walls) dmgval2 = (dmgval2 + 3) / 4; @@ -2399,7 +2399,8 @@ glovecheck: target = which_armor(mtmp, W_ARMG); otmp->oartifact == ART_MAGICBANE) dmgval2 += rnd(4); for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) - if (otmp->oartifact && protects(AD_MAGM, otmp)) + if (otmp->oartifact && + defends_when_carried(AD_MAGM, otmp)) break; if (otmp) dmgval2 += rnd(4); if (passes_walls(mptr)) dmgval2 = (dmgval2 + 3) / 4;