summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spl-util.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/spl-util.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/spl-util.cc')
-rw-r--r--crawl-ref/source/spl-util.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc
index 67ec2c373d..3cfed59490 100644
--- a/crawl-ref/source/spl-util.cc
+++ b/crawl-ref/source/spl-util.cc
@@ -672,6 +672,7 @@ void apply_area_cloud( cloud_func func, const coord_def& where,
// Return false if the user canceled, true otherwise.
bool spell_direction( dist &spelld, bolt &pbolt,
targeting_type restrict, targ_mode_type mode,
+ int range,
bool needs_path, bool may_target_monster,
bool may_target_self, const char *prompt,
bool cancel_at_self )
@@ -679,7 +680,7 @@ bool spell_direction( dist &spelld, bolt &pbolt,
if (restrict != DIR_DIR)
message_current_target();
- direction( spelld, restrict, mode, -1, false, needs_path,
+ direction( spelld, restrict, mode, range, false, needs_path,
may_target_monster, may_target_self, prompt, NULL,
cancel_at_self );
@@ -871,3 +872,21 @@ int spell_power_cap(spell_type spell)
{
return (_seekspell(spell)->power_cap);
}
+
+int spell_range(spell_type spell, int pow, bool real_cast)
+{
+ const int minrange = _seekspell(spell)->min_range;
+ const int maxrange = _seekspell(spell)->max_range;
+ ASSERT(maxrange >= minrange);
+
+ if (minrange == maxrange)
+ return minrange;
+
+ const int powercap = spell_power_cap(spell);
+
+ if (powercap <= pow)
+ return maxrange;
+
+ // Round appropriately.
+ return ((pow*(maxrange - minrange) + powercap/2) / powercap + minrange);
+}