]> granicus.if.org Git - nethack/commitdiff
Limit aggravate to inside or outside of the Wizard's tower
authorPasi Kallinen <paxed@alt.org>
Sat, 16 Jan 2016 07:45:08 +0000 (09:45 +0200)
committerPasi Kallinen <paxed@alt.org>
Sat, 16 Jan 2016 07:45:12 +0000 (09:45 +0200)
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.

include/extern.h
src/mcastu.c
src/wizard.c

index d0789f2057ba312a06c324c3fd6e13964417f508..46872a895d9ace1fef54b2a78d1ce28834fcbe02 100644 (file)
@@ -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);
index 24463a59bfd4c8d952cca0ba9bb06519ee601dae..06c084916cddd5e5246f07c57ad02880fa6a11c9 100644 (file)
@@ -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) {
index 57d4d6cbeb44abd5486794b1d97adc84a810fa6f..bb394349f7f513d2cb89c5ce897e06bc66009ede 100644 (file)
@@ -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)) {