From 174182f0e421f91f770e6e2a8f5ebaa8ba16744d Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Thu, 10 May 2007 03:03:46 +0000 Subject: [PATCH] Sunsword vs shades, take II (trunk only) From the newsgroup: Sunsword is ineffective against shades. It gets a special bonus of double damage vs undead, but since it's not made of silver it was only doing 1 point of damage against shades. Make the bonus-vs-undead attribute override the silver-required criterion. (No comparable handling for flimsy weapons against thick-skinned critters this time.) --- doc/fixes35.0 | 1 + include/extern.h | 1 + src/artifact.c | 22 +++++++++++++++++++++- src/uhitm.c | 2 +- src/weapon.c | 4 ++-- 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/doc/fixes35.0 b/doc/fixes35.0 index 92b113992..e11fac9c4 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -227,6 +227,7 @@ explosion while engulfed only affects engulfer and hero, not adjacent monsters eliminate case-sensitivity when converting words from singular to plural and vice versa, so some failing wishes like "Gauntlets of Power" now work breath attack directed at self by poly'd hero always hits +override non-silver vs shades for artifacts which deal extra damage to undead Platform- and/or Interface-Specific Fixes diff --git a/include/extern.h b/include/extern.h index bfd9aac5c..8136fa86f 100644 --- a/include/extern.h +++ b/include/extern.h @@ -64,6 +64,7 @@ E boolean FDECL(arti_immune, (struct obj *,int)); E boolean FDECL(spec_ability, (struct obj *,unsigned long)); E boolean FDECL(confers_luck, (struct obj *)); 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 *)); diff --git a/src/artifact.c b/src/artifact.c index b10f88928..aa3355f4c 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)artifact.c 3.5 2007/03/05 */ +/* SCCS Id: @(#)artifact.c 3.5 2007/05/09 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -275,6 +275,26 @@ struct obj *obj; return FALSE; } +/* decide whether this obj is effective when attacking against shades; + does not consider the bonus for blessed objects versus undead */ +boolean +shade_glare(obj) +struct obj *obj; +{ + const struct artifact *arti; + + /* any silver object is effective */ + if (objects[obj->otyp].oc_material == SILVER) return TRUE; + /* non-silver artifacts with bonus against undead also are effective */ + arti = get_artifact(obj); + if (arti && (arti->spfx & SPFX_DFLAG2) && arti->mtype == M2_UNDEAD) + return TRUE; + /* [if there was anything with special bonus against noncorporeals, + it would be effective too] */ + /* otherwise, harmless to shades */ + return FALSE; +} + boolean restrict_name(otmp, name) /* returns 1 if name is restricted for otmp->otyp */ register struct obj *otmp; diff --git a/src/uhitm.c b/src/uhitm.c index d804cd187..62b1371fa 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -611,7 +611,7 @@ int thrown; /* HMON_xxx (0 => hand-to-hand, other => ranged) */ (is_ammo(obj) && (thrown != HMON_THROWN || !ammo_and_launcher(obj, uwep)))) { /* then do only 1-2 points of damage */ - if (mdat == &mons[PM_SHADE] && obj->otyp != SILVER_ARROW) + if (mdat == &mons[PM_SHADE] && !shade_glare(obj)) tmp = 0; else tmp = rnd(2); diff --git a/src/weapon.c b/src/weapon.c index a3e46ca71..4893f3fbc 100644 --- a/src/weapon.c +++ b/src/weapon.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)weapon.c 3.5 2007/02/09 */ +/* SCCS Id: @(#)weapon.c 3.5 2007/05/09 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -294,7 +294,7 @@ struct monst *mon; if (objects[otyp].oc_material <= LEATHER && thick_skinned(ptr)) /* thick skinned/scaled creatures don't feel it */ tmp = 0; - if (ptr == &mons[PM_SHADE] && objects[otyp].oc_material != SILVER) + if (ptr == &mons[PM_SHADE] && !shade_glare(otmp)) tmp = 0; /* "very heavy iron ball"; weight increase is in increments of 160 */