From 5d5389034da866a517b5d78095d5b1c7efb47e31 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Sun, 7 Jun 2009 19:13:12 +0000 Subject: Make weapons of reaching work through granite statues again. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9913 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/fight.cc | 2 +- crawl-ref/source/it_use3.cc | 21 ++++++++++++--------- crawl-ref/source/monstuff.cc | 12 ++++++++++-- 3 files changed, 23 insertions(+), 12 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 9900d9a501..d9346d1c60 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -4312,7 +4312,7 @@ std::string melee_attack::mons_weapon_desc() const item_def wpn = *weapon; if (get_weapon_brand(wpn) == SPWPN_REACHING) { - if ( grid_distance(attacker->pos(), defender->pos()) == 2 ) + if (grid_distance(attacker->pos(), defender->pos()) == 2) result += " from afar"; } diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc index 77c91e5554..b0b1d34fa5 100644 --- a/crawl-ref/source/it_use3.cc +++ b/crawl-ref/source/it_use3.cc @@ -256,17 +256,26 @@ static bool _reaching_weapon_attack(const item_def& wpn) } const coord_def delta = beam.target - you.pos(); - const int x_distance = abs(delta.x); - const int y_distance = abs(delta.y); + const int x_distance = abs(delta.x); + const int y_distance = abs(delta.y); monsters* mons = monster_at(beam.target); + const int x_middle = std::max(beam.target.x, you.pos().x) + - (x_distance / 2); + const int y_middle = std::max(beam.target.y, you.pos().y) + - (y_distance / 2); + const coord_def middle(x_middle, y_middle); + if (x_distance > 2 || y_distance > 2) { mpr("Your weapon cannot reach that far!"); return (false); } - else if (!see_grid_no_trans(beam.target)) + else if (!see_grid_no_trans(beam.target) + && grd(middle) <= DNGN_MAX_NONREACH) { + // Might also be a granite statue/orcish idol which you + // can reach _past_. mpr("There's a wall in the way."); return (false); } @@ -285,12 +294,6 @@ static bool _reaching_weapon_attack(const item_def& wpn) // If we're attacking more than a space away... if (x_distance > 1 || y_distance > 1) { - const int x_middle = std::max(beam.target.x, you.pos().x) - - (x_distance / 2); - const int y_middle = std::max(beam.target.y, you.pos().y) - - (y_distance / 2); - const coord_def middle(x_middle, y_middle); - bool success = false; // If either the x or the y is the same, we should check for // a monster: diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index ed3475aaf8..c49d39b800 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -5977,10 +5977,18 @@ static bool _handle_reaching(monsters *monster) { if (monster->foe == MHITYOU) { + const coord_def delta = monster->pos() - you.pos(); + const int x_middle = std::max(monster->pos().x, you.pos().x) + - (abs(delta.x) / 2); + const int y_middle = std::max(monster->pos().y, you.pos().y) + - (abs(delta.y) / 2); + const coord_def middle(x_middle, y_middle); + // This check isn't redundant -- player may be invisible. if (monster->target == you.pos() - && see_grid_no_trans(monster->pos()) - && grid_distance(monster->pos(), you.pos()) == 2) + && grid_distance(monster->pos(), you.pos()) == 2 + && (see_grid_no_trans(monster->pos()) + || grd(middle) > DNGN_MAX_NONREACH)) { ret = true; monster_attack(monster, false); -- cgit v1.2.3-54-g00ecf