From: Pasi Kallinen Date: Sat, 16 Jan 2016 07:45:08 +0000 (+0200) Subject: Limit aggravate to inside or outside of the Wizard's tower X-Git-Tag: NetHack-3.6.1_RC01~1011 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=04bc048073e87c55e3bcfa3fceab44fe86361e8a;p=nethack Limit aggravate to inside or outside of the Wizard's tower There have been several comments on IRC how the Wizard is a very light sleeper now; aggravate cast by monsters makes him wake up and come out of the tower. So, lets limit aggravate to either outside or inside of the tower, depending on which side the player is. --- diff --git a/include/extern.h b/include/extern.h index d0789f205..46872a895 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2677,6 +2677,7 @@ E void NDECL(amulet); 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); diff --git a/src/mcastu.c b/src/mcastu.c index 24463a59b..06c084916 100644 --- a/src/mcastu.c +++ b/src/mcastu.c @@ -798,20 +798,11 @@ int spellnum; 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) { diff --git a/src/wizard.c b/src/wizard.c index 57d4d6cbe..bb394349f 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -425,14 +425,40 @@ register struct monst *mtmp; 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)) {