summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-ench.h
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2011-09-28 14:15:29 +0200
committerAdam Borowski <kilobyte@angband.pl>2011-09-28 14:15:29 +0200
commit902296b857cafd02dde0f4ad3bd098594069ecde (patch)
tree39eaf3ed7e621d2c122b09fec3e9dc9e35a4aa09 /crawl-ref/source/mon-ench.h
parent4d9c7942241f284129c0ec7bef7b6128d2478150 (diff)
downloadcrawl-ref-902296b857cafd02dde0f4ad3bd098594069ecde.tar.gz
crawl-ref-902296b857cafd02dde0f4ad3bd098594069ecde.zip
Split away enchantment code from monster.cc
Diffstat (limited to 'crawl-ref/source/mon-ench.h')
-rw-r--r--crawl-ref/source/mon-ench.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/crawl-ref/source/mon-ench.h b/crawl-ref/source/mon-ench.h
new file mode 100644
index 0000000000..7aa70f0387
--- /dev/null
+++ b/crawl-ref/source/mon-ench.h
@@ -0,0 +1,54 @@
+#ifndef MON_ENCH_H
+#define MON_ENCH_H
+
+#include "actor.h"
+
+#define INFINITE_DURATION 30000
+
+class mon_enchant
+{
+public:
+ enchant_type ench;
+ int degree;
+ int duration, maxduration;
+ kill_category who; // Source's alignment.
+ mid_t source; // Who set this enchantment?
+
+public:
+ mon_enchant(enchant_type e = ENCH_NONE, int deg = 0,
+ const actor *whose = 0,
+ int dur = 0);
+
+ killer_type killer() const;
+ int kill_agent() const;
+ actor* agent() const;
+
+ operator std::string () const;
+ const char *kill_category_desc(kill_category) const;
+ void merge_killer(kill_category who, mid_t whos);
+ void cap_degree();
+
+ void set_duration(const monster* mons, const mon_enchant *exist);
+
+ bool operator < (const mon_enchant &other) const
+ {
+ return (ench < other.ench);
+ }
+
+ bool operator == (const mon_enchant &other) const
+ {
+ // NOTE: This does *not* check who/degree.
+ return (ench == other.ench);
+ }
+
+ mon_enchant &operator += (const mon_enchant &other);
+ mon_enchant operator + (const mon_enchant &other) const;
+
+private:
+ int modded_speed(const monster* mons, int hdplus) const;
+ int calc_duration(const monster* mons, const mon_enchant *added) const;
+};
+
+enchant_type name_to_ench(const char *name);
+
+#endif