mode--with save file deletion--and require confirmation ala 'X'
command to make deferred switch into explore mode
stethoscope applied to hiding mimic will bring it out of hiding
+rephrase "<artifact> evades your grasp" message if artifact is already held
+artifacts which subsequently evade your grasp/control after already being
+ worn or wielded become unworn/unwielded
Platform- and/or Interface-Specific Fixes
E long FDECL(arti_cost, (struct obj *));
E struct obj *FDECL(what_gives, (long *));
E void FDECL(Sting_effects, (int));
+E int FDECL(retouch_object, (struct obj **,BOOLEAN_P));
/* ### attrib.c ### */
obj = getobj(class_list, "use or apply");
if(!obj) return 0;
- if (obj->oartifact && !touch_artifact(obj, &youmonst))
+ if (!retouch_object(&obj, FALSE))
return 1; /* evading your grasp costs a turn; just be
grateful that you don't drop it as well */
-/* SCCS Id: @(#)artifact.c 3.5 2006/06/08 */
+/* SCCS Id: @(#)artifact.c 3.5 2007/03/05 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
/* can pick it up unless you're totally non-synch'd with the artifact */
if (badclass && badalign && self_willed) {
- if (yours) pline("%s your grasp!", Tobjnam(obj, "evade"));
+ if (yours) {
+ if (obj->where != OBJ_INVENT)
+ pline("%s your grasp!", Tobjnam(obj, "evade"));
+ else
+ pline("%s beyond your control!", Tobjnam(obj, "are"));
+ }
return 0;
}
int
doinvoke()
{
- register struct obj *obj;
+ struct obj *obj;
obj = getobj(invoke_types, "invoke");
if (!obj) return 0;
- if (obj->oartifact && !touch_artifact(obj, &youmonst)) return 1;
+ if (!retouch_object(&obj, FALSE)) return 1;
return arti_invoke(obj);
}
}
}
+/* called when hero is wielding/applying/invoking a carried item, or
+ after undergoing a transformation (alignment change, lycanthropy)
+ which might affect item access */
+int
+retouch_object(objp, loseit)
+struct obj **objp; /* might be destroyed or unintentionally dropped */
+boolean loseit; /* whether to drop it if hero can longer touch it */
+{
+ struct obj *obj = *objp;
+
+ if (touch_artifact(obj, &youmonst)) {
+ /* nothing to do if hero can successfully handle this object */
+ if (!(objects[obj->otyp].oc_material == SILVER &&
+ (u.ulycn >= LOW_PM || hates_silver(youmonst.data))))
+ return 1;
+ /* we didn't get "<obj> evades your grasp" message; give alt message */
+ You_cant("handle %s anymore!", thesimpleoname(obj));
+ }
+
+ /* removing a worn item might result in loss of levitation,
+ dropping the hero onto a polymorph trap or into water or
+ lava and potentially dropping or destroying the item */
+ if (obj->owornmask) {
+ struct obj *otmp;
+
+ remove_worn_item(obj, FALSE);
+ for (otmp = invent; otmp; otmp = otmp->nobj)
+ if (otmp == obj) break;
+ if (!otmp) *objp = obj = 0;
+ }
+
+ /* if we still have it and caller wants us to drop it, do so now */
+ if (loseit && obj) {
+ if (Levitation) {
+ freeinv(obj);
+ hitfloor(obj);
+ } else {
+ /* dropx gives a message iff item lands on an altar */
+ if (!IS_ALTAR(levl[u.ux][u.uy].typ))
+ pline("%s to the %s.",
+ Tobjnam(obj, "drop"), surface(u.ux, u.uy));
+ dropx(obj);
+ }
+ *objp = obj = 0; /* no longer in inventory */
+ }
+ return 0;
+}
+
/*artifact.c*/
break;
}
- if (catch_lycanthropy && defends(AD_WERE, uwep)) {
- if (!touch_artifact(uwep, &youmonst)) {
- dropx(uwep);
- uwepgone();
- }
+ if (catch_lycanthropy) {
+ if (u.twoweap) (void)retouch_object(&uswapwep, TRUE);
+ if (uwep) (void)retouch_object(&uwep, TRUE);
}
return;
int
doeat() /* generic "eat" command funtion (see cmd.c) */
{
- register struct obj *otmp;
+ struct obj *otmp;
int basenutrit; /* nutrition of full item */
boolean dont_start = FALSE, nodelicious = FALSE;
* mails, players who polymorph back to human in the middle of their
* metallic meal, etc....
*/
- if (otmp->oartifact && !touch_artifact(otmp, &youmonst)) {
+ if (!(carried(otmp) ? retouch_object(&otmp, FALSE) :
+ touch_artifact(otmp, &youmonst))) {
return 1;
} else if (!is_edible(otmp)) {
You("cannot eat that!");
-/* SCCS Id: @(#)mhitu.c 3.5 2006/08/07 */
+/* SCCS Id: @(#)mhitu.c 3.5 2007/03/09 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
You_feel("feverish.");
exercise(A_CON, FALSE);
u.ulycn = monsndx(mdat);
+ if (u.twoweap) (void)retouch_object(&uswapwep, TRUE);
+ if (uwep) (void)retouch_object(&uwep, TRUE);
}
break;
case AD_SGLD:
} else if (wep->otyp == CORPSE && cant_wield_corpse(wep)) {
/* hero must have been life-saved to get here; use a turn */
res++; /* corpse won't be wielded */
- } else if (uarms && bimanual(wep))
+ } else if (uarms && bimanual(wep)) {
You("cannot wield a two-handed %s while wearing a shield.",
is_sword(wep) ? "sword" :
wep->otyp == BATTLE_AXE ? "axe" : "weapon");
- else if (wep->oartifact && !touch_artifact(wep, &youmonst)) {
+ } else if (!retouch_object(&wep, FALSE)) {
res++; /* takes a turn even though it doesn't get wielded */
} else {
/* Weapon WILL be wielded after this point */