summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/target.h
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2011-03-07 19:40:23 +0100
committerAdam Borowski <kilobyte@angband.pl>2011-03-07 19:40:23 +0100
commit15537459ded4cf1a6e5dc2818800d59f6af1dc48 (patch)
treee21acbadd6750e19a8d56214cf442501d3bfdc28 /crawl-ref/source/target.h
parent4c1aef9351d8625110220b7d5746a76f01f75565 (diff)
downloadcrawl-ref-15537459ded4cf1a6e5dc2818800d59f6af1dc48.tar.gz
crawl-ref-15537459ded4cf1a6e5dc2818800d59f6af1dc48.zip
New targetting code; for now for reaching and Fire Storm.
directn.cc tried to assume everything is a beam, this make it impossible to properly visualise spells/effects with different rules, like reaching, clouds, IOOD, shotgun-targetted spells, cones, etc. This interface lets every spell come with an object that answers the question: if I aim at X, will location Y be affected? There are three levels of aiming effect now: * tracer only * might be affected * will be affected unless you miss This means we can show spells that have randomized area: Freezing Cloud, Fire Storm's radius, etc. TODO: display in tiles. The old targetter has a great number of special cases, I did not replace it yet since it would be a large amount of work. The new code allows for showing explosions and bounces, but I'd start with clouds and such first. Fire Storm is a good sample. Also, this commit fixes the targetter not allowing you to reach sqrt(8) via 'f' or '.'; you had to use '!' to do that. A number of places in the code assumed that, with a special distinction for two modes of reaching.
Diffstat (limited to 'crawl-ref/source/target.h')
-rw-r--r--crawl-ref/source/target.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/crawl-ref/source/target.h b/crawl-ref/source/target.h
new file mode 100644
index 0000000000..998c4abcca
--- /dev/null
+++ b/crawl-ref/source/target.h
@@ -0,0 +1,73 @@
+#ifndef TARGET_H
+#define TARGET_H
+
+#include "beam.h"
+
+enum aff_type // sign and non-zeroness matters
+{
+ AFF_TRACER = -1,
+ AFF_NO = 0,
+ AFF_MAYBE = 1, // can possibly affect
+ AFF_YES, // intended/likely to affect
+ // If you want to extend this to pass the probability somehow, feel free to,
+ // just keep AFF_YES the minimal "bright" value.
+};
+
+class targetter
+{
+public:
+ virtual ~targetter() {};
+
+ coord_def origin;
+ coord_def aim;
+ const actor* agent;
+
+ virtual bool set_aim(coord_def a);
+ virtual bool valid_aim(coord_def a) = 0;
+
+ virtual aff_type is_affected(coord_def loc) = 0;
+};
+
+class targetter_beam : public targetter
+{
+public:
+ targetter_beam(const actor *act, int range, beam_type flavour, bool stop);
+ bolt beam;
+ bool set_aim(coord_def a);
+ bool valid_aim(coord_def a);
+ aff_type is_affected(coord_def loc);
+};
+
+class targetter_view : public targetter
+{
+public:
+ targetter_view();
+ bool valid_aim(coord_def a);
+ aff_type is_affected(coord_def loc);
+};
+
+class targetter_smite : public targetter
+{
+public:
+ targetter_smite(const actor *act, int range = LOS_RADIUS,
+ int exp_min = 0, int exp_max = 0);
+ bool set_aim(coord_def a);
+ bool valid_aim(coord_def a);
+ aff_type is_affected(coord_def loc);
+private:
+ int range2;
+ // assumes exp_map is valid only if >0, so let's keep it private
+ int exp_range_min, exp_range_max;
+ explosion_map exp_map_min, exp_map_max;
+};
+
+class targetter_reach : public targetter
+{
+public:
+ targetter_reach(const actor* act, reach_type ran = REACH_NONE);
+ reach_type range;
+ bool valid_aim(coord_def a);
+ aff_type is_affected(coord_def loc);
+};
+
+#endif