summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-chimera.cc
diff options
context:
space:
mode:
authorPete Hurst <pete@streamuniverse.tv>2013-06-06 11:18:56 +0100
committerPete Hurst <pete@streamuniverse.tv>2013-06-21 18:26:16 +0100
commit449020270af4920cfeef57a010e616f4a0b6a12b (patch)
tree5ab2368bcaae84c923159ffafa9fe19d8365c26a /crawl-ref/source/mon-chimera.cc
parente9ecdcbda83abf17aabb92e6fac191f22e3143f6 (diff)
downloadcrawl-ref-449020270af4920cfeef57a010e616f4a0b6a12b.tar.gz
crawl-ref-449020270af4920cfeef57a010e616f4a0b6a12b.zip
Implement Chimeric monsters
After creating the monster, the make_chimera function in mon-chimera.cc can be used to set its component creatures.
Diffstat (limited to 'crawl-ref/source/mon-chimera.cc')
-rw-r--r--crawl-ref/source/mon-chimera.cc67
1 files changed, 67 insertions, 0 deletions
diff --git a/crawl-ref/source/mon-chimera.cc b/crawl-ref/source/mon-chimera.cc
new file mode 100644
index 0000000000..18adda7095
--- /dev/null
+++ b/crawl-ref/source/mon-chimera.cc
@@ -0,0 +1,67 @@
+/**
+ * @file
+ * @brief Chimeric beasties
+**/
+
+#include "AppHdr.h"
+#include "mon-chimera.h"
+
+#include "externs.h"
+#include "enum.h"
+#include "mon-info.h"
+#include "mon-util.h"
+#include "monster.h"
+
+#include <sstream>
+
+static void apply_chimera_part(monster* mon, monster_type part, int partnum);
+
+void make_chimera(monster* mon, monster_type part1, monster_type part2, monster_type part3)
+{
+ ASSERT(part1 != MONS_NO_MONSTER);
+ ASSERT(!invalid_monster_type(part1));
+ ASSERT(part2 != MONS_NO_MONSTER);
+ ASSERT(!invalid_monster_type(part2));
+ ASSERT(part3 != MONS_NO_MONSTER);
+ ASSERT(!invalid_monster_type(part3));
+
+ // Set type to the original type to calculate appropriate stats.
+ mon->type = part1;
+ mon->base_monster = MONS_PROGRAM_BUG;
+ define_monster(mon);
+
+ mon->type = MONS_CHIMERA;
+ mon->base_monster = part1;
+ mon->props["chimera_part_2"] = part2;
+ mon->props["chimera_part_3"] = part3;
+ apply_chimera_part(mon,part2,2);
+ apply_chimera_part(mon,part3,3);
+}
+
+static void apply_chimera_part(monster* mon, monster_type part, int partnum)
+{
+ // TODO: Enforce more rules about the Chimera parts so things
+ // can't get broken
+ ASSERT(!mons_class_is_zombified(part));
+
+ // Create a temp monster to transfer properties
+ monster dummy;
+ dummy.type = part;
+ define_monster(&dummy);
+}
+
+string monster_info::chimera_part_names() const
+{
+ if (!props.exists("chimera_part_2") || !props.exists("chimera_part_3"))
+ return "";
+
+ monster_type chimtype2 = static_cast<monster_type>(props["chimera_part_2"].get_int());
+ monster_type chimtype3 = static_cast<monster_type>(props["chimera_part_3"].get_int());
+ ASSERT(chimtype2 > MONS_PROGRAM_BUG && chimtype2 < NUM_MONSTERS);
+ ASSERT(chimtype3 > MONS_PROGRAM_BUG && chimtype3 < NUM_MONSTERS);
+
+ ostringstream s;
+ s << "-" << get_monster_data(chimtype2)->name
+ << "-" << get_monster_data(chimtype3)->name;
+ return s.str();
+}