miscellaneous objects[] macros
Replace FIRST_GEM and LAST_GEM with FIRST_REAL_GEM, LAST_REAL_GEM, FIRST_GLASS_GEM, and LAST_GLASS_GEM and define those along with objects[] rather than separately. Do the latter for FIRST_AMULET and LAST_AMULET too. Also new FIRST_SPELL and LAST_SPELL used to compute MAXSPELLS. (That value looks wrong to me, but this defines it with the same value as before. If it gets fixed, EDITLEVEL will need to be incremented.) This started as just proof of concept that extra information could be collected as objects[] gets initialized at compile time.
This commit is contained in:
@@ -1055,9 +1055,16 @@ dump_enums(void)
|
||||
"monnums", "objects_nums" , "misc_object_nums"
|
||||
};
|
||||
static const struct enum_dump omdump[] = {
|
||||
{ LAST_GEM, "LAST_GEM" },
|
||||
{ NUM_GLASS_GEMS, "NUM_GLASS_GEMS" },
|
||||
{ FIRST_AMULET, "FIRST_AMULET" },
|
||||
{ LAST_AMULET, "LAST_AMULET" },
|
||||
{ FIRST_SPELL, "FIRST_SPELL" },
|
||||
{ LAST_SPELL, "LAST_SPELL" },
|
||||
{ MAXSPELL, "MAXSPELL" },
|
||||
{ FIRST_REAL_GEM, "FIRST_REAL_GEM" },
|
||||
{ LAST_REAL_GEM, "LAST_REAL_GEM" },
|
||||
{ FIRST_GLASS_GEM, "FIRST_GLASS_GEM" },
|
||||
{ LAST_GLASS_GEM, "LAST_GLASS_GEM" },
|
||||
{ NUM_GLASS_GEMS, "NUM_GLASS_GEMS" },
|
||||
};
|
||||
static const struct enum_dump *const ed[NUM_ENUM_DUMPS] = {
|
||||
monsdump, objdump, omdump
|
||||
|
||||
@@ -979,8 +979,9 @@ get_valuables(struct obj *list) /* inventory or container contents */
|
||||
ga.amulets[i].typ = obj->otyp;
|
||||
} else
|
||||
ga.amulets[i].count += obj->quan; /* always adds one */
|
||||
} else if (obj->oclass == GEM_CLASS && obj->otyp < LUCKSTONE) {
|
||||
i = min(obj->otyp, LAST_GEM + 1) - FIRST_GEM;
|
||||
} else if (obj->oclass == GEM_CLASS && obj->otyp <= LAST_GLASS_GEM) {
|
||||
/* last+1: combine all glass gems into one slot */
|
||||
i = min(obj->otyp, LAST_REAL_GEM + 1) - FIRST_REAL_GEM;
|
||||
if (!gg.gems[i].count) {
|
||||
gg.gems[i].count = obj->quan;
|
||||
gg.gems[i].typ = obj->otyp;
|
||||
@@ -1613,7 +1614,8 @@ really_done(int how)
|
||||
|
||||
if (count == 0L)
|
||||
continue;
|
||||
if (objects[typ].oc_class != GEM_CLASS || typ <= LAST_GEM) {
|
||||
if (objects[typ].oc_class != GEM_CLASS
|
||||
|| typ <= LAST_REAL_GEM) {
|
||||
otmp = mksobj(typ, FALSE, FALSE);
|
||||
discover_object(otmp->otyp, TRUE, FALSE);
|
||||
otmp->known = 1; /* for fake amulets */
|
||||
|
||||
@@ -582,7 +582,7 @@ make_corpse(struct monst *mtmp, unsigned int corpseflags)
|
||||
case PM_GLASS_GOLEM:
|
||||
num = d(2, 4); /* very low chance of creating all glass gems */
|
||||
while (num--)
|
||||
obj = mksobj_at((LAST_GEM + rnd(NUM_GLASS_GEMS)),
|
||||
obj = mksobj_at(FIRST_GLASS_GEM + rn2(NUM_GLASS_GEMS),
|
||||
x, y, TRUE, FALSE);
|
||||
free_mgivenname(mtmp);
|
||||
break;
|
||||
|
||||
@@ -501,12 +501,11 @@ ucatchgem(
|
||||
struct monst *mon)
|
||||
{
|
||||
/* won't catch rock or gray stone; catch (then drop) worthless glass */
|
||||
if (gem->otyp <= LAST_GEM + NUM_GLASS_GEMS
|
||||
&& is_unicorn(gy.youmonst.data)) {
|
||||
if (gem->otyp <= LAST_GLASS_GEM && is_unicorn(gy.youmonst.data)) {
|
||||
char *gem_xname = xname(gem),
|
||||
*mon_s_name = s_suffix(mon_nam(mon));
|
||||
|
||||
if (gem->otyp > LAST_GEM) {
|
||||
if (gem->otyp >= FIRST_GLASS_GEM) {
|
||||
You("catch the %s.", gem_xname);
|
||||
You("are not interested in %s junk.", mon_s_name);
|
||||
makeknown(gem->otyp);
|
||||
|
||||
@@ -56,14 +56,14 @@ setgemprobs(d_level* dlev)
|
||||
for (j = 0; j < 9 - lev / 3; j++)
|
||||
objects[first + j].oc_prob = 0;
|
||||
first += j;
|
||||
if (first > LAST_GEM || objects[first].oc_class != GEM_CLASS
|
||||
if (first > LAST_REAL_GEM || objects[first].oc_class != GEM_CLASS
|
||||
|| OBJ_NAME(objects[first]) == (char *) 0) {
|
||||
raw_printf("Not enough gems? - first=%d j=%d LAST_GEM=%d", first, j,
|
||||
LAST_GEM);
|
||||
LAST_REAL_GEM);
|
||||
wait_synch();
|
||||
}
|
||||
for (j = first; j <= LAST_GEM; j++)
|
||||
objects[j].oc_prob = (171 + j - first) / (LAST_GEM + 1 - first);
|
||||
for (j = first; j <= LAST_REAL_GEM; j++)
|
||||
objects[j].oc_prob = (171 + j - first) / (LAST_REAL_GEM + 1 - first);
|
||||
|
||||
/* recompute GEM_CLASS total oc_prob - including rocks/stones */
|
||||
for (j = gb.bases[GEM_CLASS]; j < gb.bases[GEM_CLASS + 1]; j++)
|
||||
|
||||
32
src/objnam.c
32
src/objnam.c
@@ -73,19 +73,21 @@ struct Jitem {
|
||||
&& typ != SAPPHIRE && typ != BLACK_OPAL && typ != EMERALD \
|
||||
&& typ != OPAL)))
|
||||
|
||||
static struct Jitem Japanese_items[] = { { SHORT_SWORD, "wakizashi" },
|
||||
{ BROADSWORD, "ninja-to" },
|
||||
{ FLAIL, "nunchaku" },
|
||||
{ GLAIVE, "naginata" },
|
||||
{ LOCK_PICK, "osaku" },
|
||||
{ WOODEN_HARP, "koto" },
|
||||
{ KNIFE, "shito" },
|
||||
{ PLATE_MAIL, "tanko" },
|
||||
{ HELMET, "kabuto" },
|
||||
{ LEATHER_GLOVES, "yugake" },
|
||||
{ FOOD_RATION, "gunyoki" },
|
||||
{ POT_BOOZE, "sake" },
|
||||
{ 0, "" } };
|
||||
static struct Jitem Japanese_items[] = {
|
||||
{ SHORT_SWORD, "wakizashi" },
|
||||
{ BROADSWORD, "ninja-to" },
|
||||
{ FLAIL, "nunchaku" },
|
||||
{ GLAIVE, "naginata" },
|
||||
{ LOCK_PICK, "osaku" },
|
||||
{ WOODEN_HARP, "koto" },
|
||||
{ KNIFE, "shito" },
|
||||
{ PLATE_MAIL, "tanko" },
|
||||
{ HELMET, "kabuto" },
|
||||
{ LEATHER_GLOVES, "yugake" },
|
||||
{ FOOD_RATION, "gunyoki" },
|
||||
{ POT_BOOZE, "sake" },
|
||||
{ 0, "" }
|
||||
};
|
||||
|
||||
static const char *Japanese_item_name(int i);
|
||||
|
||||
@@ -4264,7 +4266,7 @@ readobjnam_postparse2(struct _readobjnam_data *d)
|
||||
s += 9;
|
||||
if (!strcmpi(s, "glass")) { /* choose random color */
|
||||
/* 9 different kinds */
|
||||
d->typ = LAST_GEM + rnd(NUM_GLASS_GEMS);
|
||||
d->typ = FIRST_GLASS_GEM + rn2(NUM_GLASS_GEMS);
|
||||
if (objects[d->typ].oc_class == GEM_CLASS)
|
||||
return 2; /*goto typfnd;*/
|
||||
else
|
||||
@@ -4292,7 +4294,7 @@ readobjnam_postparse3(struct _readobjnam_data *d)
|
||||
|
||||
/* check real names of gems first */
|
||||
if (!d->oclass && d->actualn) {
|
||||
for (i = gb.bases[GEM_CLASS]; i <= LAST_GEM; i++) {
|
||||
for (i = gb.bases[GEM_CLASS]; i <= LAST_REAL_GEM; i++) {
|
||||
register const char *zn;
|
||||
|
||||
if ((zn = OBJ_NAME(objects[i])) != 0 && !strcmpi(d->actualn, zn)) {
|
||||
|
||||
22
src/shk.c
22
src/shk.c
@@ -2201,32 +2201,32 @@ get_cost(
|
||||
(((int) ubirthday % obj->otyp) >= obj->otyp / 2);
|
||||
|
||||
/* all gems are priced high - real or not */
|
||||
switch (obj->otyp - LAST_GEM) {
|
||||
case 1: /* white */
|
||||
switch (obj->otyp - FIRST_GLASS_GEM) {
|
||||
case 0: /* white */
|
||||
i = pseudorand ? DIAMOND : OPAL;
|
||||
break;
|
||||
case 2: /* blue */
|
||||
case 1: /* blue */
|
||||
i = pseudorand ? SAPPHIRE : AQUAMARINE;
|
||||
break;
|
||||
case 3: /* red */
|
||||
case 2: /* red */
|
||||
i = pseudorand ? RUBY : JASPER;
|
||||
break;
|
||||
case 4: /* yellowish brown */
|
||||
case 3: /* yellowish brown */
|
||||
i = pseudorand ? AMBER : TOPAZ;
|
||||
break;
|
||||
case 5: /* orange */
|
||||
case 4: /* orange */
|
||||
i = pseudorand ? JACINTH : AGATE;
|
||||
break;
|
||||
case 6: /* yellow */
|
||||
case 5: /* yellow */
|
||||
i = pseudorand ? CITRINE : CHRYSOBERYL;
|
||||
break;
|
||||
case 7: /* black */
|
||||
case 6: /* black */
|
||||
i = pseudorand ? BLACK_OPAL : JET;
|
||||
break;
|
||||
case 8: /* green */
|
||||
case 7: /* green */
|
||||
i = pseudorand ? EMERALD : JADE;
|
||||
break;
|
||||
case 9: /* violet */
|
||||
case 8: /* violet */
|
||||
i = pseudorand ? AMETHYST : FLUORITE;
|
||||
break;
|
||||
default:
|
||||
@@ -2458,7 +2458,7 @@ set_cost(register struct obj* obj, register struct monst* shkp)
|
||||
/* different shop keepers give different prices */
|
||||
if (objects[obj->otyp].oc_material == GEMSTONE
|
||||
|| objects[obj->otyp].oc_material == GLASS) {
|
||||
tmp = ((obj->otyp - FIRST_GEM) % (6 - shkp->m_id % 3));
|
||||
tmp = ((obj->otyp - FIRST_REAL_GEM) % (6 - shkp->m_id % 3));
|
||||
tmp = (tmp + 3) * obj->quan;
|
||||
divisor = 1L;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user