From 9ee55d87ebaf61cab536271ab51cb302dbeb56a0 Mon Sep 17 00:00:00 2001 From: PatR Date: Wed, 13 Mar 2024 13:28:05 -0700 Subject: [PATCH] fix pull request #1223 - wand of striking by monst Pull request by elunna with assistance by entrez tried to fix up wand of striking discovery when the wand is zapped by a monster. The fix didn't match the intended behavior (which may or may not be the desired behavior...), so this skips the code in the pull request. [I can't post comments on github anymore since I declined to switch to their 2-factor authentication. But I can still read submissions without logging in.] This also tries to fix a couple of inconsistencies between zapping by the hero versus by a monster. If the zap "boinged" :-) due to target's magic resistance, zap by hero didn't discover the wand but zap by monster did. Conversely, a zap by the hero that reached a target and missed did discover it but one by a monster did not. Now a zap of not-yet-discovered wand of striking by the hero which hits, whether or not the hit gets resisted, will become discovered provided that the spot where target is hit can be seen (the target itself need not be), and one which misses or which can't be seen hitting something will no longer be. Supersedes #1223 Closes #1223 --- src/muse.c | 5 ++++- src/zap.c | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/muse.c b/src/muse.c index 5f5edc250..9885b955c 100644 --- a/src/muse.c +++ b/src/muse.c @@ -1562,7 +1562,10 @@ mbhitm(struct monst *mtmp, struct obj *otmp) } else { miss("wand", mtmp); } - if (learnit && cansee(mtmp->mx, mtmp->my) && gz.zap_oseen) + /* need to see the wand being zapped and also the spot where the + target is hit; don't have to see the target itself though */ + if (learnit && gz.zap_oseen && (hits_you + || cansee(mtmp->mx, mtmp->my))) makeknown(WAN_STRIKING); break; case WAN_TELEPORTATION: diff --git a/src/zap.c b/src/zap.c index 071addb8e..c2cdca866 100644 --- a/src/zap.c +++ b/src/zap.c @@ -178,10 +178,11 @@ bhitm(struct monst *mtmp, struct obj *otmp) reveal_invis = TRUE; if (disguised_mimic) seemimic(mtmp); + learn_it = cansee(gb.bhitpos.x, gb.bhitpos.y); if (resists_magm(mtmp)) { /* match effect on player */ shieldeff(mtmp->mx, mtmp->my); pline("Boing!"); - break; /* skip makeknown */ + /* 3.7: used to 'break' to avoid setting learn_it here */ } else if (u.uswallow || rnd(20) < 10 + find_mac(mtmp)) { dmg = d(2, 12); if (dbldam) @@ -190,9 +191,10 @@ bhitm(struct monst *mtmp, struct obj *otmp) dmg = spell_damage_bonus(dmg); hit(zap_type_text, mtmp, exclam(dmg)); (void) resist(mtmp, otmp->oclass, dmg, TELL); - } else + } else { miss(zap_type_text, mtmp); - learn_it = TRUE; + learn_it = FALSE; + } break; case WAN_SLOW_MONSTER: case SPE_SLOW_MONSTER: