From 1f9e38751c81744f2e8d4ffb1aea7f3870ba9d5b Mon Sep 17 00:00:00 2001 From: haranp Date: Thu, 25 Sep 2008 17:13:23 +0000 Subject: Ranges redone. bolt no longer has a rangeMax, just a range. Almost all ranges are now capped by LOS. There are still some things missing, most noticeably randomizing ranges for the range-1-to-2 spells (e.g. Flame Tongue.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6984 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/item_use.cc | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'crawl-ref/source/item_use.cc') diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 31c539c448..bf63dff657 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -1865,46 +1865,39 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, pbolt.aux_source.clear(); // pbolt.range is set below + int max_range = 0; + int range = 0; + if (projected) { if (wepType == MI_LARGE_ROCK) { - pbolt.range = 1 + random2( you.strength / 5 ); - pbolt.rangeMax = you.strength / 5; + range = 1 + random2( you.strength / 5 ); + max_range = you.strength / 5; if (you.can_throw_rocks()) { - pbolt.range += random_range(4, 7); - pbolt.rangeMax += 7; - } - if (pbolt.rangeMax > 12) - { - pbolt.rangeMax = 12; - if (pbolt.range > 12) - pbolt.range = 12; + range += random_range(4, 7); + max_range += 7; } } else if (wepType == MI_THROWING_NET) { - pbolt.rangeMax = pbolt.range = 2 + player_size(PSIZE_BODY); + max_range = range = 2 + player_size(PSIZE_BODY); } else { - pbolt.rangeMax = pbolt.range = 12; + max_range = range = LOS_RADIUS; } } else { // Range based on mass & strength, between 1 and 9. - pbolt.range = you.strength - item_mass(item) / 10 + 3; - if (pbolt.range < 1) - pbolt.range = 1; - - if (pbolt.range > 9) - pbolt.range = 9; - - pbolt.rangeMax = pbolt.range; + max_range = range = std::max(you.strength - item_mass(item)/10 + 3, 1); } + range = std::min(range, LOS_RADIUS); + max_range = std::min(max_range, LOS_RADIUS); + pbolt.is_beam = false; pbolt.beam_source = 0; pbolt.can_see_invis = player_see_invis(); @@ -1912,6 +1905,9 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, pbolt.attitude = ATT_FRIENDLY; pbolt.is_tracer = true; + // For the tracer, use max_range. For the actual shot, use range. + pbolt.range = max_range; + // Don't do the tracing when using Portaled Projectile, or when confused. if (!teleport && !you.duration[DUR_CONF]) { @@ -1934,6 +1930,9 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, } } + // Use real range for firing. + pbolt.range = range; + // Now start real firing! origin_set_unknown(item); -- cgit v1.2.3-54-g00ecf