more #U1233 - specifying mon class instead type for polyself (trunk only)

Another item from the Dec'04 report sent in by <email deleted>.  When prompted for a type of monster to polymorph
into, giving a monster class description like "dog or other canine" (or
single letter like 'd'), triggered "I've never heard of such monsters".
Instead of adjusting the message, this chooses a member from the class.

     I put this into the fixes file as a new feature.
This commit is contained in:
nethack.rankin
2007-04-10 03:39:52 +00:00
parent a8913c2366
commit 4777c898f8
5 changed files with 55 additions and 3 deletions

View File

@@ -1415,6 +1415,37 @@ int spc;
return(&mons[first]);
}
/* like mkclass(), but excludes difficulty considerations; used when
player with polycontrol picks a class instead of a specific type;
genocided types are avoided but extinct ones are acceptable */
int
mkclass_poly(class)
int class;
{
register int first, last, num = 0;
for (first = LOW_PM; first < SPECIAL_PM; first++)
if (mons[first].mlet == class) break;
if (first == SPECIAL_PM) return NON_PM;
for (last = first;
last < SPECIAL_PM && mons[last].mlet == class; last++)
if (!(mvitals[last].mvflags & G_GENOD) &&
!(mons[last].geno & (G_NOGEN|G_UNIQ)) &&
!is_placeholder(&mons[last]))
num += mons[last].geno & G_FREQ;
if (!num) return NON_PM;
for (num = rnd(num); num > 0; first++)
if (!(mvitals[first].mvflags & G_GENOD) &&
!(mons[first].geno & (G_NOGEN|G_UNIQ)) &&
!is_placeholder(&mons[first]))
num -= mons[first].geno & G_FREQ;
first--; /* correct an off-by-one error */
return first;
}
int
adj_lev(ptr) /* adjust strength of monsters based on u.uz and u.ulevel */
register struct permonst *ptr;