From: nethack.rankin Date: Tue, 7 Feb 2006 05:35:29 +0000 (+0000) Subject: wildmiss refinement (trunk only) X-Git-Tag: MOVE2GIT~1128 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=02a2e8b6ef18b454667e88ec58c80dbe0f4c3aba;p=nethack wildmiss refinement (trunk only) > This makes monsters marginally smarter--independent of their defined > intelligence levels--by skipping their remaining attacks when the first > turns out to be targetted at nothing. The exception is for monsters with > both melee and spell attacks; they'll keep going in case they end up > choosing a spell which doesn't need a target location. (It's rather > ironic that the most intelligent monsters are the ones who'll foolishly > continue swinging at thin air. This could be improved by forcing then to > skip ahead to their spell attack.) This implements the improvement for spellcasters. After they make a wildmiss, they'll skip any further physical attacks but eventually try their spell. (Titans have multiple physical attacks followed by a spell; other high-end monsters probably do too.) --- diff --git a/src/mhitu.c b/src/mhitu.c index c899298c9..2e4d96df1 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -304,8 +304,8 @@ mattacku(mtmp) /* Might be attacking your image around the corner, or * invisible, or you might be blind.... */ - boolean giveup = FALSE; - /* Are further attack attempts useless? */ + boolean skipnonmagc = FALSE; + /* Are further physical attack attempts useless? */ if(!ranged) nomul(0); if(mtmp->mhp <= 0 || (Underwater && !is_swimmer(mtmp->data))) @@ -544,8 +544,10 @@ mattacku(mtmp) sum[i] = 0; mattk = getmattk(mdat, i, sum, &alt_attk); - if (u.uswallow && (mattk->aatyp != AT_ENGL)) + if ((u.uswallow && mattk->aatyp != AT_ENGL) || + (skipnonmagc && mattk->aatyp != AT_MAGC)) continue; + switch(mattk->aatyp) { case AT_CLAW: /* "hand to hand" attacks */ case AT_KICK: @@ -565,9 +567,8 @@ mattacku(mtmp) missmu(mtmp, (tmp == j), mattk); } else { wildmiss(mtmp, mattk); - /* skip any remaining attacks unless this - monster might attempt undirected spell */ - giveup = !attacktype(mtmp->data, AT_MAGC); + /* skip any remaining non-spell attacks */ + skipnonmagc = TRUE; } } break; @@ -660,9 +661,8 @@ mattacku(mtmp) tmp -= hittmp; } else { wildmiss(mtmp, mattk); - /* skip any remaining attacks unless this - monster might attempt undirected spell */ - giveup = !attacktype(mtmp->data, AT_MAGC); + /* skip any remaining non-spell attacks */ + skipnonmagc = TRUE; } } break; @@ -687,7 +687,6 @@ mattacku(mtmp) if(sum[i] == 2) return 1; /* attacker dead */ if(sum[i] == 3) break; /* attacker teleported, no more attacks */ /* sum[i] == 0: unsuccessful attack */ - if (giveup) break; /* skip any remaining attacks */ } return(0); }