E int FDECL(mon_has_amulet, (struct monst *));
E int FDECL(mon_has_special, (struct monst *));
E int FDECL(tactics, (struct monst *));
+E boolean FDECL(has_aggravatables, (struct monst *));
E void NDECL(aggravate);
E void NDECL(clonewiz);
E int NDECL(pick_nasty);
return TRUE;
/* aggravation (global wakeup) when everyone is already active */
if (spellnum == MGC_AGGRAVATION) {
- struct monst *nxtmon;
-
- for (nxtmon = fmon; nxtmon; nxtmon = nxtmon->nmon) {
- if (DEADMONSTER(nxtmon))
- continue;
- if ((nxtmon->mstrategy & STRAT_WAITFORU) != 0
- || nxtmon->msleeping || !nxtmon->mcanmove)
- break;
- }
/* if nothing needs to be awakened then this spell is useless
but caster might not realize that [chance to pick it then
must be very small otherwise caller's many retry attempts
will eventually end up picking it too often] */
- if (!nxtmon)
+ if (!has_aggravatables(mtmp))
return rn2(100) ? TRUE : FALSE;
}
} else if (adtyp == AD_CLRC) {
return 0;
}
+/* are there any monsters mon could aggravate? */
+boolean
+has_aggravatables(mon)
+struct monst *mon;
+{
+ struct monst *mtmp;
+ boolean in_w_tower = In_W_tower(mon->mx, mon->my, &u.uz);
+
+ if (in_w_tower != In_W_tower(u.ux, u.uy, &u.uz))
+ return FALSE;
+
+ for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
+ if (DEADMONSTER(mtmp))
+ continue;
+ if (in_w_tower != In_W_tower(mtmp->mx, mtmp->my, &u.uz))
+ continue;
+ if ((mtmp->mstrategy & STRAT_WAITFORU) != 0
+ || mtmp->msleeping || !mtmp->mcanmove)
+ return TRUE;
+ }
+ return FALSE;
+}
+
void
aggravate()
{
register struct monst *mtmp;
+ boolean in_w_tower = In_W_tower(u.ux, u.uy, &u.uz);
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
if (DEADMONSTER(mtmp))
continue;
+ if (in_w_tower != In_W_tower(mtmp->mx, mtmp->my, &u.uz))
+ continue;
mtmp->mstrategy &= ~(STRAT_WAITFORU | STRAT_APPEARMSG);
mtmp->msleeping = 0;
if (!mtmp->mcanmove && !rn2(5)) {