more monster key use
Let monsters use lock picks and credit cards in addition to keys for
opening doors. And the earlier code to have pets hang on to a key didn't
work as intended. It worked fine if the key was the only object carried,
but the monsters' item dropping code didn't give any special handling to
keys so they'd be dropped too if the pet carried another droppable item.
This eliminates second set of checks for handling some items specially--
dropping now uses the same routine as is used when pet movement decides
whether there's anything to drop.
Also, a couple more door message tweaks. "You see a door open" seems
strange when you watch your pet do the opening. Previously fixed for the
"unlock and open" case, this does the same for opening already unlocked
doors and for giants smashing down doors--it now gives a more specific
message when you see a monster perform the action.
Possible change in play balance: pets capable of picking up the
rogue's Master Key of Thievery or tourist's Platinum Yendorian Express
Card will keep one of them. So a player might accidentally lose one by
leaving it on the floor in a pet's path, or more significantly, the Card
will yield a means of giving magic resistance to a monster who can't wear
a cloak or dragon scales. It's neutral and the most interesting high-end
pets are lawful (hence won't pick it up), so that probably won't have much
impact.
This commit is contained in:
61
src/steal.c
61
src/steal.c
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)steal.c 3.5 2005/07/14 */
|
||||
/* SCCS Id: @(#)steal.c 3.5 2005/10/14 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -573,59 +573,32 @@ struct monst *mon;
|
||||
|
||||
/* release the objects the creature is carrying */
|
||||
void
|
||||
relobj(mtmp,show,is_pet)
|
||||
register struct monst *mtmp;
|
||||
register int show;
|
||||
relobj(mtmp, show, is_pet)
|
||||
struct monst *mtmp;
|
||||
int show;
|
||||
boolean is_pet; /* If true, pet should keep wielded/worn items */
|
||||
{
|
||||
register struct obj *otmp;
|
||||
register int omx = mtmp->mx, omy = mtmp->my;
|
||||
struct obj *keepobj = 0;
|
||||
struct obj *wep = MON_WEP(mtmp);
|
||||
boolean item1 = FALSE, item2 = FALSE;
|
||||
struct obj *otmp;
|
||||
int omx = mtmp->mx, omy = mtmp->my;
|
||||
|
||||
if (!is_pet || mindless(mtmp->data) || is_animal(mtmp->data))
|
||||
item1 = item2 = TRUE;
|
||||
if (!tunnels(mtmp->data) || !needspick(mtmp->data))
|
||||
item1 = TRUE;
|
||||
|
||||
while ((otmp = mtmp->minvent) != 0) {
|
||||
obj_extract_self(otmp);
|
||||
/* special case: pick-axe and unicorn horn are non-worn */
|
||||
/* items that we also want pets to keep 1 of */
|
||||
/* (It is a coincidence that these can also be wielded.) */
|
||||
if (otmp->owornmask || otmp == wep ||
|
||||
((!item1 && otmp->otyp == PICK_AXE) ||
|
||||
(!item2 && otmp->otyp == UNICORN_HORN && !otmp->cursed))) {
|
||||
if (is_pet) { /* dont drop worn/wielded item */
|
||||
if (otmp->otyp == PICK_AXE)
|
||||
item1 = TRUE;
|
||||
if (otmp->otyp == UNICORN_HORN && !otmp->cursed)
|
||||
item2 = TRUE;
|
||||
otmp->nobj = keepobj;
|
||||
keepobj = otmp;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
mdrop_obj(mtmp, otmp, is_pet && flags.verbose);
|
||||
}
|
||||
|
||||
/* put kept objects back */
|
||||
while ((otmp = keepobj) != (struct obj *)0) {
|
||||
keepobj = otmp->nobj;
|
||||
(void) add_to_minv(mtmp, otmp);
|
||||
}
|
||||
#ifndef GOLDOBJ
|
||||
/* handle gold first since droppables() would get stuck on it */
|
||||
if (mtmp->mgold) {
|
||||
register long g = mtmp->mgold;
|
||||
long g = mtmp->mgold;
|
||||
|
||||
(void) mkgold(g, omx, omy);
|
||||
if (is_pet && cansee(omx, omy) && flags.verbose)
|
||||
pline("%s drops %ld gold piece%s.", Monnam(mtmp),
|
||||
g, plur(g));
|
||||
pline("%s drops %ld gold piece%s.", Monnam(mtmp),
|
||||
g, plur(g));
|
||||
mtmp->mgold = 0L;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
while ((otmp = (is_pet ? droppables(mtmp) : mtmp->minvent)) != 0) {
|
||||
obj_extract_self(otmp);
|
||||
mdrop_obj(mtmp, otmp, is_pet && flags.verbose);
|
||||
}
|
||||
|
||||
if (show & cansee(omx, omy))
|
||||
newsym(omx, omy);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user