From: nethack.rankin Date: Thu, 30 Mar 2006 05:52:28 +0000 (+0000) Subject: shattering monster's weapon stack X-Git-Tag: MOVE2GIT~1076 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f94b832fc9c2b475516db64a4ad167926cf19a14;p=nethack shattering monster's weapon stack Something I encountered while playing slash'em a while back, but relevant to nethack: "Its orcish spears shatter from the force of your blow!". I was using a two-handed weapon (at skilled or expert level) to fight an invisible monster which was wielding a stack of multiple spears (slash'em gives them out in groups of 3 for monsters' starting inventory). After killing it, I found 2 orcish spears along with an invisible corpse of somebody-or-other the Kobold King. The message suggested that the whole spear stack had been destroyed (and the weapon shattering code in hmon_hitmon() clearly expects that to be the case), but only one of them had actually gotten used up. I can't recall whether "shatter" was actually given as singular or plural at the time; nethack handles that aspect correctly. Only object destruction needed tweaking. --- diff --git a/doc/fixes34.4 b/doc/fixes34.4 index ba3bf3b95..47e0d6980 100644 --- a/doc/fixes34.4 +++ b/doc/fixes34.4 @@ -203,6 +203,7 @@ handle antholes more sensibly when ants aren't available cancelled nurses shouldn't say "Relax, this won't hurt a bit" check for hero location in digactualhole() before clearing u.utrap clear any pits that the hero digs in the vault guard's temporary corridor +shattering a monster's weapon didn't work as intended for stack of N>1 Platform- and/or Interface-Specific Fixes diff --git a/include/extern.h b/include/extern.h index f7bc8d887..393be35d5 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1358,6 +1358,7 @@ E int FDECL(breamu, (struct monst *,struct attack *)); E boolean FDECL(linedup, (XCHAR_P,XCHAR_P,XCHAR_P,XCHAR_P)); E boolean FDECL(lined_up, (struct monst *)); E struct obj *FDECL(m_carrying, (struct monst *,int)); +E void FDECL(m_useupall, (struct monst *,struct obj *)); E void FDECL(m_useup, (struct monst *,struct obj *)); E void FDECL(m_throw, (struct monst *,int,int,int,int,int,struct obj *)); E boolean FDECL(hits_bars, (struct obj **,int,int,int,int)); diff --git a/src/mthrowu.c b/src/mthrowu.c index c9b635ded..63b387a77 100644 --- a/src/mthrowu.c +++ b/src/mthrowu.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)mthrowu.c 3.5 2005/06/21 */ +/* SCCS Id: @(#)mthrowu.c 3.5 2006/03/29 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -445,23 +445,32 @@ struct obj *obj; /* missile (or stack providing it) */ } } -/* Remove an item from the monster's inventory and destroy it. */ +/* remove an entire item from a monster's inventory; destroy that item */ +void +m_useupall(mon, obj) +struct monst *mon; +struct obj *obj; +{ + obj_extract_self(obj); + possibly_unwield(mon, FALSE); + if (obj->owornmask) { + mon->misc_worn_check &= ~obj->owornmask; + update_mon_intrinsics(mon, obj, FALSE, FALSE); + } + obfree(obj, (struct obj*) 0); +} + +/* remove one instance of an item from a monster's inventory */ void m_useup(mon, obj) struct monst *mon; struct obj *obj; { if (obj->quan > 1L) { - obj->quan--; - obj->owt = weight(obj); + obj->quan--; + obj->owt = weight(obj); } else { - obj_extract_self(obj); - possibly_unwield(mon, FALSE); - if (obj->owornmask) { - mon->misc_worn_check &= ~obj->owornmask; - update_mon_intrinsics(mon, obj, FALSE, FALSE); - } - obfree(obj, (struct obj*) 0); + m_useupall(mon, obj); } } diff --git a/src/uhitm.c b/src/uhitm.c index a237e6668..6c5245acc 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)uhitm.c 3.5 2005/11/30 */ +/* SCCS Id: @(#)uhitm.c 3.5 2006/03/29 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -662,7 +662,7 @@ int thrown; mon->weapon_check = NEED_WEAPON; pline("%s from the force of your blow!", Yobjnam2(monwep, "shatter")); - m_useup(mon, monwep); + m_useupall(mon, monwep); /* If someone just shattered MY weapon, I'd flee! */ if (rn2(4)) { monflee(mon, d(2,3), TRUE, TRUE);