Skip to content

Commit 535b806

Browse files
committed
Fix: passive AD_MAGM damage when attacking the Oracle (player or another monster).
This is a long-standing bug, especially concerning pets or other monsters attacking the Oracle. The order of events were wrong - the attacking pet/monster would take passive AD_MAGM (magic missile) first, and then the actual attack would occur. This was because 'mhit' was not defined for that type of passive attack. Oops. It was really that simple. While there, I noticed that monsters that fall under resists_mgc() were not accounted for, so that'd been included. While working on this, I noticed that the same conditions for the player attacking the Oracle could use some attention also.
1 parent 19efb4f commit 535b806

File tree

3 files changed

+47
-23
lines changed

3 files changed

+47
-23
lines changed

doc/evilhack-changelog.md

+2
Original file line numberDiff line numberDiff line change
@@ -3537,4 +3537,6 @@ The following changes to date are:
35373537
- Tweak power cost for wizards casting force bolt spell
35383538
- Adjust feedback when hitting a water-based monster or one that is
35393539
underwater with burning hands spell
3540+
- Fix: passive AD_MAGM damage when attacking the Oracle (player or
3541+
another monster)
35403542

src/mhitm.c

+26-15
Original file line numberDiff line numberDiff line change
@@ -3294,22 +3294,33 @@ struct obj *mwep;
32943294
break;
32953295
/* Grudge patch. */
32963296
case AD_MAGM:
3297-
/* wrath of gods for attacking Oracle */
3298-
if (resists_magm(magr) || defended(magr, AD_MAGM)) {
3299-
tmp = (tmp + 1) / 2;
3300-
if (canseemon(magr)) {
3301-
shieldeff(magr->mx, magr->my);
3302-
pline(magr->data == &mons[PM_WOODCHUCK] ? "ZOT!" :
3303-
"%s is hit by magic missiles appearing from thin air!",
3304-
Monnam(magr));
3305-
pline("Some missiles bounce off!");
3297+
/* wrath of gods for attacking Oracle */
3298+
if (mhit) {
3299+
if (resists_mgc(magr->data)) {
3300+
tmp = 0;
3301+
if (canseemon(magr)) {
3302+
shieldeff(magr->mx, magr->my);
3303+
pline("%s is hit by magic missiles appearing from thin air!",
3304+
Monnam(magr));
3305+
pline_The("missiles bounce off!");
3306+
}
3307+
} else if (resists_magm(magr) || defended(magr, AD_MAGM)) {
3308+
tmp = (tmp + 1) / 2;
3309+
if (canseemon(magr)) {
3310+
shieldeff(magr->mx, magr->my);
3311+
pline(magr->data == &mons[PM_WOODCHUCK] ? "ZOT!" :
3312+
"%s is hit by magic missiles appearing from thin air!",
3313+
Monnam(magr));
3314+
pline("Some missiles bounce off!");
3315+
}
3316+
goto assess_dmg;
3317+
} else {
3318+
if (canseemon(magr))
3319+
pline(magr->data == &mons[PM_WOODCHUCK] ? "ZOT!" :
3320+
"%s is hit by magic missiles appearing from thin air!",
3321+
Monnam(magr));
3322+
goto assess_dmg;
33063323
}
3307-
} else {
3308-
if (canseemon(magr))
3309-
pline(magr->data == &mons[PM_WOODCHUCK] ? "ZOT!" :
3310-
"%s is hit by magic missiles appearing from thin air!",
3311-
Monnam(magr));
3312-
goto assess_dmg;
33133324
}
33143325
break;
33153326
case AD_ENCH: /* KMH -- remove enchantment (disenchanter) */

src/uhitm.c

+19-8
Original file line numberDiff line numberDiff line change
@@ -2685,6 +2685,11 @@ struct attack *mattk;
26852685
other += 10;
26862686
if (Confusion || Stunned) /* hard to do much anything if impaired */
26872687
other += 20;
2688+
if (mdef->data == &mons[PM_ORACLE]) {
2689+
/* stealing from the Oracle will never succeed,
2690+
although the attempt is allowed [see AD_MAGM in passive()] */
2691+
other += 50;
2692+
}
26882693

26892694
/* failure routine */
26902695
if (!Upolyd
@@ -4676,19 +4681,25 @@ boolean wep_was_destroyed;
46764681
break;
46774682
case AD_MAGM:
46784683
/* wrath of gods for attacking Oracle */
4679-
if (Antimagic) {
4684+
if (!uwep && thievery && mon->mpeaceful) {
4685+
pline_The("gods notice your deception!");
4686+
/* The Oracle notices too... */
4687+
setmangry(mon, FALSE);
4688+
}
4689+
You("are hit by magic missiles appearing from thin air!");
4690+
4691+
if (resists_mgc(youmonst.data)) { /* no damage */
4692+
shieldeff(u.ux, u.uy);
4693+
pline_The("missiles bounce off!");
4694+
monstseesu(M_SEEN_MAGR);
4695+
tmp = 0;
4696+
} else if (Antimagic) { /* half damage */
46804697
shieldeff(u.ux, u.uy);
4681-
You("are hit by magic missiles appearing from thin air!");
46824698
pline("Some missiles bounce off!");
46834699
monstseesu(M_SEEN_MAGR);
46844700
tmp = (tmp + 1) / 2;
46854701
mdamageu(mon, tmp);
4686-
} else {
4687-
if (!uwep && thievery && mon->mpeaceful)
4688-
pline_The("gods notice your deception!");
4689-
/* The Oracle notices too... */
4690-
setmangry(mon, FALSE);
4691-
You("are hit by magic missiles appearing from thin air!");
4702+
} else { /* full damage */
46924703
mdamageu(mon, tmp);
46934704
}
46944705
break;

0 commit comments

Comments
 (0)