summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/item_use.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-09-25 17:13:23 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-09-25 17:13:23 +0000
commit1f9e38751c81744f2e8d4ffb1aea7f3870ba9d5b (patch)
tree8dfafad2a170ec6b870f90c9cf3aee89638a33cd /crawl-ref/source/item_use.cc
parent67f77bb507d0f27b169f53258bcc94a24d7f8894 (diff)
downloadcrawl-ref-1f9e38751c81744f2e8d4ffb1aea7f3870ba9d5b.tar.gz
crawl-ref-1f9e38751c81744f2e8d4ffb1aea7f3870ba9d5b.zip
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
Diffstat (limited to 'crawl-ref/source/item_use.cc')
-rw-r--r--crawl-ref/source/item_use.cc39
1 files changed, 19 insertions, 20 deletions
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);