WIZKIT inventory overflow (trunk only)

Wizard mode's $WIZKIT can specify an unlimited number of items to
add to starting inventory and they'd be put there without regard to the
number of slots in use, potentially resulting in an arbitrary number of
'#' slot items.  Cap at 52 slots, same as when picking up, and put any
excess items at the hero's feet.  It's slightly tricky because the level
hasn't been created yet at the time the wizkit gets processed.
This commit is contained in:
nethack.rankin
2007-06-16 04:18:14 +00:00
parent 2ad3afee05
commit d1387f2b6b
5 changed files with 35 additions and 9 deletions

View File

@@ -250,6 +250,7 @@ sometimes when hero is forced to buy an unpaid shop item its price changed
monster could attack with a polearm even after attempt to wield that failed
sometimes got "you trip over it" after intervening messages following the
one which described "it"
wizard mode: WIZKIT wishes could overflow inventory's 52 slots
Platform- and/or Interface-Specific Fixes

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)dungeon.h 3.5 1999/07/02 */
/* SCCS Id: @(#)dungeon.h 3.5 2007/06/15 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -142,6 +142,7 @@ typedef struct branch {
#define MIGR_SSTAIRS 7 /* dungeon branch */
#define MIGR_PORTAL 8 /* magic portal */
#define MIGR_NEAR_PLAYER 9 /* mon: followers; obj: trap door */
#define MIGR_AT_HERO 10 /* wizkit overflow */
#define MIGR_NOBREAK 1024 /* bitmask: don't break on delivery */
/* level information (saved via ledger number) */

View File

@@ -524,14 +524,12 @@ newgame()
mklev();
u_on_upstairs();
#ifdef WIZARD
if (wizard) obj_delivery(FALSE); /* finish wizkit */
#endif
vision_reset(); /* set up internals for level (after mklev) */
check_special_room(FALSE);
/* Move the monster from under you or else
* makedog() will fail when it calls makemon().
* - ucsfcgl!kneller
*/
if(MON_AT(u.ux, u.uy)) mnexto(m_at(u.ux, u.uy));
(void) makedog();
docrt();

View File

@@ -1430,7 +1430,7 @@ boolean near_hero;
register struct obj *otmp, *otmp2;
register int nx, ny;
long where;
boolean nobreak;
boolean nobreak, noscatter = FALSE;
for (otmp = migrating_objs; otmp; otmp = otmp2) {
otmp2 = otmp->nobj;
@@ -1453,6 +1453,7 @@ boolean near_hero;
break;
case MIGR_SSTAIRS: nx = sstairs.sx, ny = sstairs.sy;
break;
case MIGR_AT_HERO: noscatter = TRUE; /*FALLTHRU*/
case MIGR_NEAR_PLAYER: nx = u.ux, ny = u.uy;
break;
default:
@@ -1471,7 +1472,7 @@ boolean near_hero;
}
}
stackobj(otmp);
(void)scatter(nx, ny, rnd(2), 0, otmp);
if (!noscatter) (void)scatter(nx, ny, rnd(2), 0, otmp);
} else { /* random location */
/* set dummy coordinates because there's no
current position for rloco() to update */

View File

@@ -127,6 +127,7 @@ boolean nethack_thinks_it_is_open; /* Does NetHack think it's open? */
#define WIZKIT_MAX 128
static char wizkit[WIZKIT_MAX];
STATIC_DCL FILE *NDECL(fopen_wizkit_file);
STATIC_DCL void FDECL(wizkit_addinv, (struct obj *));
#endif
#ifdef AMIGA
@@ -2409,6 +2410,30 @@ fopen_wizkit_file()
return (FILE *)0;
}
/* add to hero's inventory if there's room, otherwise put item on floor */
STATIC_DCL void
wizkit_addinv(obj)
struct obj *obj;
{
if (!obj || obj == &zeroobj) return;
/* subset of starting inventory pre-ID */
obj->dknown = 1;
if (Role_if(PM_PRIEST)) obj->bknown = 1;
/* same criteria as lift_object()'s check for available inventory slot */
if (obj->oclass != COIN_CLASS &&
inv_cnt(FALSE) >= 52 && !merge_choice(invent, obj)) {
/* inventory overflow; can't just place & stack object since
hero isn't in position yet, so schedule for arrival later */
add_to_migration(obj);
obj->ox = 0; /* index of main dungeon */
obj->oy = 1; /* starting level number */
obj->owornmask = (long)(MIGR_AT_HERO|MIGR_NOBREAK);
} else {
(void)addinv(obj);
}
}
void
read_wizkit()
{
@@ -2432,7 +2457,7 @@ read_wizkit()
otmp = readobjnam(buf, (struct obj *)0);
if (otmp) {
if (otmp != &zeroobj)
otmp = addinv(otmp);
wizkit_addinv(otmp);
} else {
/* .60 limits output line width to 79 chars */
raw_printf("Bad wizkit item: \"%.60s\"", buf);