Browse Source

Dehardcode number of glass gems

NetHack-3.7
Pasi Kallinen 3 months ago
parent
commit
f84538aa8c
  1. 3
      src/mon.c
  2. 2
      src/mthrowu.c
  3. 2
      src/objnam.c
  4. 17
      util/makedefs.c

3
src/mon.c

@ -572,7 +572,8 @@ 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(9)), x, y, TRUE, FALSE);
obj = mksobj_at((LAST_GEM + rnd(NUM_GLASS_GEMS)),
x, y, TRUE, FALSE);
free_mgivenname(mtmp);
break;
case PM_CLAY_GOLEM:

2
src/mthrowu.c

@ -556,7 +556,7 @@ m_throw(
nomul(0);
if (singleobj->oclass == GEM_CLASS
&& singleobj->otyp <= LAST_GEM + 9 /* 9 glass colors */
&& singleobj->otyp <= LAST_GEM + NUM_GLASS_GEMS
&& is_unicorn(g.youmonst.data)) {
if (singleobj->otyp > LAST_GEM) {
You("catch the %s.", xname(singleobj));

2
src/objnam.c

@ -3956,7 +3956,7 @@ readobjnam_postparse2(struct _readobjnam_data *d)
s += 9;
if (!strcmpi(s, "glass")) { /* choose random color */
/* 9 different kinds */
d->typ = LAST_GEM + rnd(9);
d->typ = LAST_GEM + rnd(NUM_GLASS_GEMS);
if (objects[d->typ].oc_class == GEM_CLASS)
return 2; /*goto typfnd;*/
else

17
util/makedefs.c

@ -2018,6 +2018,8 @@ do_objs(void)
int prefix = 0;
char class = '\0';
boolean sumerr = FALSE;
int n_glass_gems = 0;
int start_glass_gems = 0;
filename[0] = '\0';
#ifdef FILE_PREFIX
@ -2091,6 +2093,14 @@ do_objs(void)
if (objects[i].oc_material == GLASS) {
Fprintf(ofp, "/* #define\t%s\t%d */\n", objnam, i);
prefix = -1;
if (!n_glass_gems)
start_glass_gems = i;
if (i != n_glass_gems + start_glass_gems) {
Fprintf(stderr, "glass gems not sequential\n");
(void) fflush(stderr);
sumerr = TRUE;
}
n_glass_gems++;
break;
}
/*FALLTHRU*/
@ -2112,15 +2122,20 @@ do_objs(void)
prefix = 0;
sum += objects[i].oc_prob;
if (sumerr)
break;
}
/* check last set of probabilities */
if (sum && sum != 1000) {
if (!sumerr && sum && sum != 1000) {
Fprintf(stderr, "prob error for class %d (%d%%)", class, sum);
(void) fflush(stderr);
sumerr = TRUE;
}
Fprintf(ofp, "\n");
Fprintf(ofp, "#define\tNUM_GLASS_GEMS\t%d\n", n_glass_gems);
Fprintf(ofp, "#define\tLAST_GEM\t(JADE)\n");
Fprintf(ofp, "#define\tMAXSPELL\t%d\n", nspell + 1);
Fprintf(ofp, "#define\tNUM_OBJECTS\t%d\n", i);

Loading…
Cancel
Save