adjust wish for cockatrice corpse
Wishing is powerful, so if you cannot safely handle a cockatrice corpse, then have a wish for one result in the corpse materializing on the floor rather than in your inventory. Resolves #1320
This commit is contained in:
@@ -2363,6 +2363,7 @@ extern int loot_mon(struct monst *, int *, boolean *) NO_NNARGS;
|
|||||||
extern int dotip(void);
|
extern int dotip(void);
|
||||||
extern struct autopickup_exception *check_autopickup_exceptions(struct obj *) NONNULLARG1;
|
extern struct autopickup_exception *check_autopickup_exceptions(struct obj *) NONNULLARG1;
|
||||||
extern boolean autopick_testobj(struct obj *, boolean) NONNULLARG1;
|
extern boolean autopick_testobj(struct obj *, boolean) NONNULLARG1;
|
||||||
|
extern boolean u_safe_from_fatal_corpse(struct obj *obj) NONNULLARG1;
|
||||||
|
|
||||||
/* ### pline.c ### */
|
/* ### pline.c ### */
|
||||||
|
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ struct obj {
|
|||||||
* 1 for others (format as "next boulder") */
|
* 1 for others (format as "next boulder") */
|
||||||
int usecount; /* overloaded for various things that tally */
|
int usecount; /* overloaded for various things that tally */
|
||||||
#define spestudied usecount /* # of times a spellbook has been studied */
|
#define spestudied usecount /* # of times a spellbook has been studied */
|
||||||
|
#define wishedfor usecount /* flag for hold_another_object() if from wish */
|
||||||
unsigned oeaten; /* nutrition left in food, if partly eaten */
|
unsigned oeaten; /* nutrition left in food, if partly eaten */
|
||||||
long age; /* creation date */
|
long age; /* creation date */
|
||||||
long owornmask; /* bit mask indicating which equipment slot(s) an
|
long owornmask; /* bit mask indicating which equipment slot(s) an
|
||||||
|
|||||||
@@ -1230,6 +1230,12 @@ hold_another_object(
|
|||||||
dropped, avoid perminv update when temporarily adding it */
|
dropped, avoid perminv update when temporarily adding it */
|
||||||
obj = addinv_core0(obj, (struct obj *) 0, FALSE);
|
obj = addinv_core0(obj, (struct obj *) 0, FALSE);
|
||||||
goto drop_it;
|
goto drop_it;
|
||||||
|
} else if (obj->otyp == CORPSE
|
||||||
|
&& !u_safe_from_fatal_corpse(obj)
|
||||||
|
&& obj->wishedfor) {
|
||||||
|
obj->wishedfor = 0;
|
||||||
|
obj = addinv_core0(obj, (struct obj *) 0, FALSE);
|
||||||
|
goto drop_it;
|
||||||
} else {
|
} else {
|
||||||
long oquan = obj->quan;
|
long oquan = obj->quan;
|
||||||
int prev_encumbr = near_capacity(); /* before addinv() */
|
int prev_encumbr = near_capacity(); /* before addinv() */
|
||||||
|
|||||||
+10
-2
@@ -261,12 +261,20 @@ query_classes(
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean
|
||||||
|
u_safe_from_fatal_corpse(struct obj *obj)
|
||||||
|
{
|
||||||
|
if (uarmg || obj->otyp != CORPSE
|
||||||
|
|| !touch_petrifies(&mons[obj->corpsenm]) || Stone_resistance)
|
||||||
|
return TRUE;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* check whether hero is bare-handedly touching a cockatrice corpse */
|
/* check whether hero is bare-handedly touching a cockatrice corpse */
|
||||||
staticfn boolean
|
staticfn boolean
|
||||||
fatal_corpse_mistake(struct obj *obj, boolean remotely)
|
fatal_corpse_mistake(struct obj *obj, boolean remotely)
|
||||||
{
|
{
|
||||||
if (uarmg || remotely || obj->otyp != CORPSE
|
if (u_safe_from_fatal_corpse(obj) || remotely)
|
||||||
|| !touch_petrifies(&mons[obj->corpsenm]) || Stone_resistance)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM)) {
|
if (poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM)) {
|
||||||
|
|||||||
@@ -6189,14 +6189,22 @@ makewish(void)
|
|||||||
/* TODO? maybe generate a second event describing what was received since
|
/* TODO? maybe generate a second event describing what was received since
|
||||||
these just echo player's request rather than show actual result */
|
these just echo player's request rather than show actual result */
|
||||||
|
|
||||||
const char *verb = ((Is_airlevel(&u.uz) || u.uinwater) ? "slip" : "drop"),
|
if (otmp->otyp == CORPSE && !u_safe_from_fatal_corpse(otmp))
|
||||||
|
otmp->wishedfor = 1;
|
||||||
|
|
||||||
|
const char *verb = ((Is_airlevel(&u.uz) || u.uinwater)
|
||||||
|
? "slip"
|
||||||
|
: (otmp->otyp == CORPSE && otmp->wishedfor)
|
||||||
|
? "materialize" : "drop"),
|
||||||
*oops_msg = (u.uswallow
|
*oops_msg = (u.uswallow
|
||||||
? "Oops! %s out of your reach!"
|
? "Oops! %s out of your reach!"
|
||||||
: (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)
|
: (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)
|
||||||
|| levl[u.ux][u.uy].typ < IRONBARS
|
|| levl[u.ux][u.uy].typ < IRONBARS
|
||||||
|| levl[u.ux][u.uy].typ >= ICE)
|
|| levl[u.ux][u.uy].typ >= ICE)
|
||||||
? "Oops! %s away from you!"
|
? "Oops! %s away from you!"
|
||||||
: "Oops! %s to the floor!");
|
: !(otmp->otyp == CORPSE && otmp->wishedfor)
|
||||||
|
? "Oops! %s to the floor!"
|
||||||
|
: "Careful! %s on the floor!");
|
||||||
|
|
||||||
/* The(aobjnam()) is safe since otmp is unidentified -dlc */
|
/* The(aobjnam()) is safe since otmp is unidentified -dlc */
|
||||||
(void) hold_another_object(otmp, oops_msg, The(aobjnam(otmp, verb)),
|
(void) hold_another_object(otmp, oops_msg, The(aobjnam(otmp, verb)),
|
||||||
|
|||||||
Reference in New Issue
Block a user