fix #H7159 - orc hero can start with lembas wafers

Orc heroes get an extra food item ("to compensate for generally
inferior equipment") and it could randomly be lembas wafers (or
cram rations), and Ranger heroes always started with cram rations
even when they're orcs.  Fixing the latter was simple, but the
normal race-based substitutions weren't applied to randomly
generated items, so the fix for the former required a bit of code
reorganization in ini_inv().

Elf heroes already get lembas instead of cram; do the reverse for
dwarves (although I don't think this case can happen--no role gets
lembas wafers and only orcs and always-human tourists get random
food); give orc heroes tripe instead of either lembas or cram.
This commit is contained in:
PatR
2018-05-19 11:47:15 -07:00
parent e9f1e03271
commit 98099863ff
2 changed files with 24 additions and 12 deletions

View File

@@ -16,6 +16,7 @@ numeric hilite_status values didn't allow negative numbers (needed for AC);
change them to accept leading '-', also accept unary '+' as a no-op
permanent inventory window was updated too soon when a scroll of charging
was used to [re]charge an item, not reflecting the item's change(s)
for starting inventory, don't give an orc hero lembas wafers or cram rations
Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 u_init.c $NHDT-Date: 1503960969 2017/08/28 22:56:09 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.40 $ */
/* NetHack 3.6 u_init.c $NHDT-Date: 1526755625 2018/05/19 18:47:05 $ $NHDT-Branch: NetHack-3.6.2 $:$NHDT-Revision: 1.42 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2017. */
/* NetHack may be freely redistributed. See license for details. */
@@ -219,11 +219,14 @@ static struct inv_sub {
{ PM_ORC, SMALL_SHIELD, ORCISH_SHIELD },
{ PM_ORC, RING_MAIL, ORCISH_RING_MAIL },
{ PM_ORC, CHAIN_MAIL, ORCISH_CHAIN_MAIL },
{ PM_ORC, CRAM_RATION, TRIPE_RATION },
{ PM_ORC, LEMBAS_WAFER, TRIPE_RATION },
{ PM_DWARF, SPEAR, DWARVISH_SPEAR },
{ PM_DWARF, SHORT_SWORD, DWARVISH_SHORT_SWORD },
{ PM_DWARF, HELMET, DWARVISH_IRON_HELM },
/* { PM_DWARF, SMALL_SHIELD, DWARVISH_ROUNDSHIELD }, */
/* { PM_DWARF, PICK_AXE, DWARVISH_MATTOCK }, */
{ PM_DWARF, LEMBAS_WAFER, CRAM_RATION },
{ PM_GNOME, BOW, CROSSBOW },
{ PM_GNOME, ARROW, CROSSBOW_BOLT },
{ NON_PM, STRANGE_OBJECT, STRANGE_OBJECT }
@@ -972,17 +975,8 @@ register struct trobj *trop;
int otyp, i;
while (trop->trclass) {
if (trop->trotyp != UNDEF_TYP) {
otyp = (int) trop->trotyp;
if (urace.malenum != PM_HUMAN) {
/* substitute specific items for generic ones */
for (i = 0; inv_subs[i].race_pm != NON_PM; ++i)
if (inv_subs[i].race_pm == urace.malenum
&& otyp == inv_subs[i].item_otyp) {
otyp = inv_subs[i].subs_otyp;
break;
}
}
otyp = (int) trop->trotyp;
if (otyp != UNDEF_TYP) {
obj = mksobj(otyp, TRUE, FALSE);
} else { /* UNDEF_TYP */
static NEARDATA short nocreate = STRANGE_OBJECT;
@@ -1057,6 +1051,23 @@ register struct trobj *trop;
nocreate4 = otyp;
}
if (urace.malenum != PM_HUMAN) {
/* substitute race-specific items; this used to be in
the 'if (otyp != UNDEF_TYP) { }' block above, but then
substitutions didn't occur for randomly generated items
(particularly food) which have racial substitutes */
for (i = 0; inv_subs[i].race_pm != NON_PM; ++i)
if (inv_subs[i].race_pm == urace.malenum
&& otyp == inv_subs[i].item_otyp) {
debugpline3("ini_inv: substituting %s for %s%s",
OBJ_NAME(objects[inv_subs[i].subs_otyp]),
(trop->trotyp == UNDEF_TYP) ? "random " : "",
OBJ_NAME(objects[otyp]));
otyp = obj->otyp = inv_subs[i].subs_otyp;
break;
}
}
/* nudist gets no armor */
if (u.uroleplay.nudist && obj->oclass == ARMOR_CLASS) {
dealloc_obj(obj);