GOLDOBJ pickup handling (trunk only)

For GOLDOBJ configuration, relax the 52 object limit for inventory
when gold uses the special $ slot instead of a letter.  Takes care of an
old buglist entry from the beta testers.  [It will need to be revisited
if we ever implement multiple coin types that can't all fit in one slot.]

     Also for GOLDOBJ, prevents nymphs and monkeys from stealing coins,
since allowing that made their steal-item attack be a complete superset
of leprechaun's steal-gold attack.
This commit is contained in:
nethack.rankin
2007-06-16 02:22:01 +00:00
parent e753fb50f2
commit 2ad3afee05
10 changed files with 37 additions and 26 deletions

View File

@@ -31,6 +31,8 @@ internals: use Is_box rather than explicitly checking what it checks
fix some unreachable messages (either make then reachable or remove them)
can quiver coins when GOLDOBJ is defined
make #loot behave same for GOLDOBJ as for !GOLDOBJ
for GOLDOBJ, can pick gold up into $ when all 52 letters are in use, and
can pick non-gold up into unused letter when gold uses one of 52 slots
grammar, spelling and other typos
keep various delayed killers separate to avoid mixed up messages
don't place randomly-placed aquatic monsters in lava on special levels

View File

@@ -798,7 +798,7 @@ E int NDECL(near_capacity);
E int FDECL(calc_capacity, (int));
E int NDECL(max_capacity);
E boolean FDECL(check_capacity, (const char *));
E int NDECL(inv_cnt);
E int FDECL(inv_cnt, (BOOLEAN_P));
#ifdef GOLDOBJ
E long FDECL(money_cnt, (struct obj *));
#endif

View File

@@ -341,7 +341,7 @@ register struct obj *otmp;
if (carried(otmp)) {
freeinv(otmp);
if (inv_cnt() >= 52) {
if (inv_cnt(FALSE) >= 52) {
sellobj_state(SELL_DONTSELL);
dropy(otmp);
sellobj_state(SELL_NORMAL);

View File

@@ -2479,13 +2479,14 @@ const char *str;
}
int
inv_cnt()
inv_cnt(incl_gold)
boolean incl_gold; /* only meaningful for GOLDOBJ config */
{
register struct obj *otmp = invent;
register int ct = 0;
while(otmp){
ct++;
if (incl_gold || otmp->invlet != GOLD_SYM) ct++;
otmp = otmp->nobj;
}
return(ct);
@@ -2500,13 +2501,13 @@ long
money_cnt(otmp)
struct obj *otmp;
{
while(otmp) {
/* Must change when silver & copper is implemented: */
if (otmp->oclass == COIN_CLASS) return otmp->quan;
otmp = otmp->nobj;
}
return 0;
while (otmp) {
/* Must change when silver & copper is implemented: */
if (otmp->oclass == COIN_CLASS) return otmp->quan;
otmp = otmp->nobj;
}
return 0L;
}
#endif
#endif /* GOLDOBJ */
/*hack.c*/

View File

@@ -420,7 +420,7 @@ const char *drop_fmt, *drop_arg, *hold_msg;
if (drop_arg) drop_arg = strcpy(buf, drop_arg);
obj = addinv(obj);
if (inv_cnt() > 52
if (inv_cnt(FALSE) > 52
|| ((obj->otyp != LOADSTONE || !obj->cursed)
&& near_capacity() > prev_encumbr)) {
if (drop_fmt) pline(drop_fmt, drop_arg);
@@ -2932,7 +2932,7 @@ doorganize() /* inventory organizer by Del Lamb */
for (let = 'A'; let <= 'Z'; ) alphabet[ix++] = let++;
alphabet[ix] = '\0';
/* for floating inv letters, truncate list after the first open slot */
if (!flags.invlet_constant && (ix = inv_cnt()) < 52)
if (!flags.invlet_constant && (ix = inv_cnt(FALSE)) < 52)
alphabet[ix + (splitting ? 0 : 1)] = '\0';
/* blank out all the letters currently in use in the inventory */
@@ -3025,7 +3025,7 @@ doorganize() /* inventory organizer by Del Lamb */
if (merged(&otmp, &obj)) {
obj = otmp;
extract_nobj(obj, &invent);
} else if (inv_cnt() >= 52) {
} else if (inv_cnt(FALSE) >= 52) {
(void) merged(&splitting, &obj); /* undo split */
/* "knapsack cannot accommodate any more items" */
Your("pack is too full.");

View File

@@ -1168,7 +1168,8 @@ boolean telekinesis;
availability of open inventory slot iff not already carrying one */
if (obj->otyp == LOADSTONE ||
(obj->otyp == BOULDER && throws_rocks(youmonst.data))) {
if (inv_cnt() < 52 || !carrying(obj->otyp) || merge_choice(invent, obj))
if (inv_cnt(FALSE) < 52 || !carrying(obj->otyp) ||
merge_choice(invent, obj))
return 1; /* lift regardless of current situation */
/* if we reach here, we're out of slots and already have at least
one of these, so treat this one more like a normal item */
@@ -1180,11 +1181,10 @@ boolean telekinesis;
*cnt_p = carry_count(obj, container, *cnt_p, telekinesis, &old_wt, &new_wt);
if (*cnt_p < 1L) {
result = -1; /* nothing lifted */
} else if (
#ifndef GOLDOBJ
obj->oclass != COIN_CLASS &&
#endif
inv_cnt() >= 52 && !merge_choice(invent, obj)) {
} else if (obj->oclass != COIN_CLASS &&
/* [exception for gold coins will have to change
if silver/copper ones ever get implemented] */
inv_cnt(FALSE) >= 52 && !merge_choice(invent, obj)) {
Your("knapsack cannot accommodate any more items.");
result = -1; /* nothing lifted */
} else {
@@ -1625,7 +1625,7 @@ reverse_loot()
if (!rn2(3)) {
/* n objects: 1/(n+1) chance per object plus 1/(n+1) to fall off end */
for (n = inv_cnt(), otmp = invent; otmp; --n, otmp = otmp->nobj)
for (n = inv_cnt(TRUE), otmp = invent; otmp; --n, otmp = otmp->nobj)
if (!rn2(n + 1)) {
prinv("You find old loot:", otmp, 0L);
return TRUE;

View File

@@ -146,7 +146,7 @@ long amount;
if (mongold->quan > amount) mongold = splitobj(mongold, amount);
obj_extract_self(mongold);
if (!merge_choice(invent, mongold) && inv_cnt() >= 52) {
if (!merge_choice(invent, mongold) && inv_cnt(FALSE) >= 52) {
You("have no room for the money!");
dropy(mongold);
} else {

View File

@@ -263,6 +263,7 @@ boolean unchain_ball; /* whether to unpunish or just unwield */
/* Returns 1 when something was stolen (or at least, when N should flee now)
* Returns -1 if the monster died in the attempt
* Avoid stealing the object stealoid
* GOLDOBJ: nymphs and monkeys won't steal coins
*/
int
steal(mtmp, objnambuf)
@@ -282,7 +283,7 @@ char *objnambuf;
so this will cause it to be removed now */
if (occupation) (void) maybe_finished_meal(FALSE);
if (!invent || (inv_cnt() == 1 && uskin)) {
if (!invent || (inv_cnt(FALSE) == 1 && uskin)) {
nothing_to_steal:
/* Not even a thousand men in armor can strip a naked man. */
if(Blind)
@@ -308,6 +309,9 @@ nothing_to_steal:
tmp = 0;
for(otmp = invent; otmp; otmp = otmp->nobj)
if ((!uarm || otmp != uarmc) && otmp != uskin
#ifdef GOLDOBJ
&& otmp->oclass != COIN_CLASS
#endif
#ifdef INVISIBLE_OBJECTS
&& (!otmp->oinvis || perceives(mtmp->data))
#endif
@@ -318,6 +322,9 @@ nothing_to_steal:
tmp = rn2(tmp);
for(otmp = invent; otmp; otmp = otmp->nobj)
if ((!uarm || otmp != uarmc) && otmp != uskin
#ifdef GOLDOBJ
&& otmp->oclass != COIN_CLASS
#endif
#ifdef INVISIBLE_OBJECTS
&& (!otmp->oinvis || perceives(mtmp->data))
#endif
@@ -375,7 +382,7 @@ gotobj:
/* the fewer items you have, the less likely the thief
is going to stick around to try again (0) instead of
running away (1) */
return !rn2(inv_cnt() / 5 + 2);
return !rn2(inv_cnt(FALSE) / 5 + 2);
}
}

View File

@@ -3160,7 +3160,7 @@ STATIC_OVL boolean
emergency_disrobe(lostsome)
boolean *lostsome;
{
int invc = inv_cnt();
int invc = inv_cnt(TRUE);
while (near_capacity() > (Punished ? UNENCUMBERED : SLT_ENCUMBER)) {
register struct obj *obj, *otmp = (struct obj *)0;

View File

@@ -1478,7 +1478,8 @@ register struct attack *mattk;
struct obj *mongold = findgold(mdef->minvent);
if (mongold) {
obj_extract_self(mongold);
if (merge_choice(invent, mongold) || inv_cnt() < 52) {
if (merge_choice(invent, mongold) ||
inv_cnt(FALSE) < 52) {
addinv(mongold);
Your("purse feels heavier.");
} else {