held artifacts evading your grasp (trunk only)
From a bug report, trying to invoke a wielded artifact after changing alignment resulted in "the <artifact> evades your grasp" but it remained wielded, contradicting the message. This adjusts the message in touch_artifact() if the object is already in inventory, and adds retouch_object() to handle cases where failing to be able to touch ought to force unwearing/unwielding.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* 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. */
|
||||
|
||||
@@ -559,7 +559,12 @@ touch_artifact(obj,mon)
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
@@ -1200,11 +1205,11 @@ static NEARDATA const char invoke_types[] = { ALL_CLASSES, 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);
|
||||
}
|
||||
|
||||
@@ -1596,4 +1601,52 @@ int orc_count;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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*/
|
||||
|
||||
Reference in New Issue
Block a user