obj_no_longer_held consistency

Call obj_no_longer_held whenever an object hits the floor, no matter what
previously held it.  Also handle stoning of prior holder.
This commit is contained in:
cohrs
2002-02-09 21:55:45 +00:00
parent 38d84ba3c8
commit 316a94d50f
7 changed files with 30 additions and 17 deletions
-1
View File
@@ -2178,7 +2178,6 @@ struct obj *obj;
/* to floor near you */ /* to floor near you */
You("yank %s %s to the %s!", s_suffix(mon_nam(mtmp)), You("yank %s %s to the %s!", s_suffix(mon_nam(mtmp)),
onambuf, surface(u.ux, u.uy)); onambuf, surface(u.ux, u.uy));
obj_no_longer_held(otmp);
place_object(otmp, u.ux, u.uy); place_object(otmp, u.ux, u.uy);
stackobj(otmp); stackobj(otmp);
break; break;
+3 -2
View File
@@ -126,11 +126,12 @@ struct obj *cont;
while ((otmp = invent) != 0) { while ((otmp = invent) != 0) {
obj_extract_self(otmp); obj_extract_self(otmp);
obj_no_longer_held(otmp);
otmp->owornmask = 0; otmp->owornmask = 0;
/* lamps don't go out when dropped */ /* lamps don't go out when dropped */
if ((cont || artifact_light(otmp)) && obj_is_burning(otmp)) /* smother in statue */ if ((cont || artifact_light(otmp)) && obj_is_burning(otmp))
end_burn(otmp, otmp->otyp != MAGIC_LAMP && !artifact_light(otmp)); end_burn(otmp, TRUE); /* smother in statue */
if(otmp->otyp == SLIME_MOLD) goodfruit(otmp->spe); if(otmp->otyp == SLIME_MOLD) goodfruit(otmp->spe);
+15 -13
View File
@@ -531,7 +531,6 @@ register struct obj *obj;
if (!u.uswallow && flooreffects(obj,u.ux,u.uy,"drop")) return; if (!u.uswallow && flooreffects(obj,u.ux,u.uy,"drop")) return;
/* uswallow check done by GAN 01/29/87 */ /* uswallow check done by GAN 01/29/87 */
obj_no_longer_held(obj);
if(u.uswallow) { if(u.uswallow) {
boolean could_petrify; boolean could_petrify;
if (obj != uball) { /* mon doesn't pick up ball */ if (obj != uball) { /* mon doesn't pick up ball */
@@ -557,25 +556,28 @@ register struct obj *obj;
} }
} }
/* things that must change when not held; recurse into containers.
Called for both player and monsters */
void void
obj_no_longer_held(obj) /* things that must change when not held; recurse into containers */ obj_no_longer_held(obj)
struct obj *obj; struct obj *obj;
{ {
if (!obj) { if (!obj) {
return; return;
} else if ((Is_container(obj) || obj->otyp == STATUE) && obj->cobj) { } else if ((Is_container(obj) || obj->otyp == STATUE) && obj->cobj) {
struct obj *contents; struct obj *contents;
for(contents=obj->cobj; contents; contents=contents->nobj) for(contents=obj->cobj; contents; contents=contents->nobj)
obj_no_longer_held(contents); obj_no_longer_held(contents);
} }
switch(obj->otyp) { switch(obj->otyp) {
case CRYSKNIFE: case CRYSKNIFE:
/* KMH -- Fixed crysknives have only 10% chance of reverting */ /* KMH -- Fixed crysknives have only 10% chance of reverting */
if (!obj->oerodeproof || !rn2(10)) { /* only changes when not held by player or monster */
obj->otyp = WORM_TOOTH; if (!obj->oerodeproof || !rn2(10)) {
obj->oerodeproof = 0; obj->otyp = WORM_TOOTH;
} obj->oerodeproof = 0;
break; }
break;
} }
} }
+3
View File
@@ -1082,6 +1082,7 @@ int x, y;
if (otmp->where != OBJ_FREE) if (otmp->where != OBJ_FREE)
panic("place_object: obj not free"); panic("place_object: obj not free");
obj_no_longer_held(otmp);
if (otmp->otyp == BOULDER) block_point(x,y); /* vision */ if (otmp->otyp == BOULDER) block_point(x,y); /* vision */
/* obj goes under boulders */ /* obj goes under boulders */
@@ -1393,6 +1394,8 @@ add_to_container(container, obj)
if (obj->where != OBJ_FREE) if (obj->where != OBJ_FREE)
panic("add_to_container: obj not free"); panic("add_to_container: obj not free");
if (container->where != OBJ_INVENT && container->where != OBJ_MINVENT)
obj_no_longer_held(obj);
/* merge if possible */ /* merge if possible */
for (otmp = container->cobj; otmp; otmp = otmp->nobj) for (otmp = container->cobj; otmp; otmp = otmp->nobj)
+1
View File
@@ -1488,6 +1488,7 @@ register struct monst *mdef;
/* some objects may end up outside the statue */ /* some objects may end up outside the statue */
while ((obj = mdef->minvent) != 0) { while ((obj = mdef->minvent) != 0) {
obj_extract_self(obj); obj_extract_self(obj);
obj_no_longer_held(obj);
if (obj->owornmask & W_WEP) if (obj->owornmask & W_WEP)
setmnotwielded(mdef,obj); setmnotwielded(mdef,obj);
obj->owornmask = 0L; obj->owornmask = 0L;
-1
View File
@@ -1823,7 +1823,6 @@ skipmsg:
case 1: /* onto floor beneath mon */ case 1: /* onto floor beneath mon */
pline("%s yanks %s from your %s!", Monnam(mtmp), pline("%s yanks %s from your %s!", Monnam(mtmp),
the_weapon, hand); the_weapon, hand);
obj_no_longer_held(obj);
place_object(obj, mtmp->mx, mtmp->my); place_object(obj, mtmp->mx, mtmp->my);
break; break;
case 2: /* onto floor beneath you */ case 2: /* onto floor beneath you */
+8
View File
@@ -4037,6 +4037,10 @@ retry:
u.uconduct.wishes++; u.uconduct.wishes++;
if (otmp != &zeroobj) { if (otmp != &zeroobj) {
/* place_object looses these */
boolean crysknife = (otmp->otyp == CRYSKNIFE);
int oerode = otmp->oerodeproof;
/* in case touching this object turns out to be fatal */ /* in case touching this object turns out to be fatal */
place_object(otmp, u.ux, u.uy); place_object(otmp, u.ux, u.uy);
@@ -4045,6 +4049,10 @@ retry:
dropy(otmp); /* now put it back again :-) */ dropy(otmp); /* now put it back again :-) */
} else { } else {
obj_extract_self(otmp); obj_extract_self(otmp);
if (crysknife) {
otmp->otyp = CRYSKNIFE;
otmp->oerodeproof = oerode;
}
/* The(aobjnam()) is safe since otmp is unidentified -dlc */ /* The(aobjnam()) is safe since otmp is unidentified -dlc */
(void) hold_another_object(otmp, u.uswallow ? (void) hold_another_object(otmp, u.uswallow ?
"Oops! %s out of your reach!" : "Oops! %s out of your reach!" :