Unify finding a queen bee

This commit is contained in:
Pasi Kallinen
2020-02-08 17:35:52 +02:00
parent c585c65042
commit 0323eecbfe
3 changed files with 20 additions and 17 deletions

View File

@@ -1554,6 +1554,7 @@ E boolean FDECL(monhaskey, (struct monst *, BOOLEAN_P));
E void FDECL(mon_regen, (struct monst *, BOOLEAN_P));
E int FDECL(dochugw, (struct monst *));
E boolean FDECL(onscary, (int, int, struct monst *));
E struct monst *FDECL(find_pmmonst, (int));
E int FDECL(bee_eat_jelly, (struct monst *, struct obj *));
E void FDECL(monflee, (struct monst *, int, BOOLEAN_P, BOOLEAN_P));
E void FDECL(mon_yells, (struct monst *, const char *));

View File

@@ -755,17 +755,10 @@ register struct obj *obj;
return POISON;
if (obj->otyp == LUMP_OF_ROYAL_JELLY
&& mon->data == &mons[PM_KILLER_BEE]) {
struct monst *mtmp = 0;
struct monst *mtmp = find_pmmonst(PM_QUEEN_BEE);
/* if there's a queen bee on the level, don't eat royal jelly;
if there isn't, do eat it and grow into a queen */
if ((g.mvitals[PM_QUEEN_BEE].mvflags & G_GENOD) == 0)
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
if (DEADMONSTER(mtmp))
continue;
if (mtmp->data == &mons[PM_QUEEN_BEE])
break;
}
return !mtmp ? DOGFOOD : TABU;
}
if (!carni && !herbi)

View File

@@ -252,6 +252,23 @@ struct monst *mon;
}
}
struct monst *
find_pmmonst(pm)
int pm;
{
struct monst *mtmp = 0;
if ((g.mvitals[pm].mvflags & G_GENOD) == 0)
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
if (DEADMONSTER(mtmp))
continue;
if (mtmp->data == &mons[pm])
break;
}
return mtmp;
}
/* killer bee 'mon' is on a spot containing lump of royal jelly 'obj' and
will eat it if there is no queen bee on the level; return 1: mon died,
0: mon ate jelly and lived; -1: mon didn't eat jelly to use its move */
@@ -261,16 +278,8 @@ struct monst *mon;
struct obj *obj;
{
int m_delay;
struct monst *mtmp = 0;
struct monst *mtmp = find_pmmonst(PM_QUEEN_BEE);
/* find a queen bee */
if ((g.mvitals[PM_QUEEN_BEE].mvflags & G_GENOD) == 0)
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
if (DEADMONSTER(mtmp))
continue;
if (mtmp->data == &mons[PM_QUEEN_BEE])
break;
}
/* if there's no queen on the level, eat the royal jelly and become one */
if (!mtmp) {
m_delay = obj->blessed ? 3 : !obj->cursed ? 5 : 7;