summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/monstuff.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-09-17 16:15:20 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-09-17 16:15:20 +0000
commite06f39be1017c28488a0ca4b61bb9962ad5ee196 (patch)
tree1c07d339c478cf73db6e03febda70d3023782d20 /crawl-ref/source/monstuff.cc
parent58fadd8bee0e04b270522f5024bb2777ea1fb66d (diff)
downloadcrawl-ref-e06f39be1017c28488a0ca4b61bb9962ad5ee196.tar.gz
crawl-ref-e06f39be1017c28488a0ca4b61bb9962ad5ee196.zip
Add the most recent version of Adam's kraken patch into trunk.
Might still need some tweaks but overall looks great! And... we need more tiles (kraken head + tentacles). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10691 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/monstuff.cc')
-rw-r--r--crawl-ref/source/monstuff.cc83
1 files changed, 80 insertions, 3 deletions
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index efac7c5baa..c5bd78a850 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -1152,6 +1152,8 @@ static void _hogs_to_humans()
// tell them apart anyway.
// On the other hand, hogs which left the level are too far away to be
// affected by the magic of Kirke's death.
+ // FIXME: If another monster was polymorphed into a hog by Kirke's
+ // porkalator spell, they should be handled specially...
int any = 0;
for (int i = 0; i < MAX_MONSTERS; ++i)
@@ -1173,16 +1175,81 @@ static void _hogs_to_humans()
}
}
- if (any==1)
+ if (any == 1)
mpr("No longer under Kirke's spell, the hog turns into a human!");
- else if (any>1)
- mpr("No longer under Kirke's spell, all hogs revert to their human form!");
+ else if (any > 1)
+ {
+ mpr("No longer under Kirke's spell, all hogs revert to their human "
+ "form!");
+ }
// Revert the player as well.
if (you.attribute[ATTR_TRANSFORMATION] == TRAN_PIG)
untransform();
}
+static int _tentacle_too_far(monsters *head, monsters *tentacle)
+{
+ // The Shoals produce no disjoint bodies of water.
+ // If this ever changes, we'd need to check if the head and tentacle
+ // are still in the same pool.
+ // XXX: Actually, using Feawn's Sunlight power you can separate pools...
+ return grid_distance(head->pos(), tentacle->pos()) > LOS_RADIUS;
+}
+
+void mons_relocated(monsters *monster)
+{
+ if (monster->type == MONS_KRAKEN)
+ {
+ int headnum = monster_index(monster);
+
+ if (invalid_monster_index(headnum))
+ return;
+
+ for (int i = 0; i < MAX_MONSTERS; ++i)
+ {
+ monsters *tentacle = &menv[i];
+ if (tentacle->type == MONS_KRAKEN_TENTACLE
+ && (int) tentacle->number == headnum
+ && _tentacle_too_far(monster, tentacle))
+ {
+ monster_die(tentacle, KILL_RESET, -1, true, false);
+ }
+ }
+ }
+ else if (monster->type == MONS_KRAKEN_TENTACLE)
+ {
+ if (invalid_monster_index(monster->number)
+ || menv[monster->number].type!=MONS_KRAKEN
+ || _tentacle_too_far(&menv[monster->number], monster))
+ {
+ monster_die(monster, KILL_RESET, -1, true, false);
+ }
+ }
+}
+
+static int _destroy_tentacles(monsters *head)
+{
+ int tent = 0;
+ int headnum = monster_index(head);
+
+ if (invalid_monster_index(headnum))
+ return 0;
+
+ for (int i = 0; i < MAX_MONSTERS; ++i)
+ {
+ monsters *monster = &menv[i];
+ if (monster->type == MONS_KRAKEN_TENTACLE
+ && (int)monster->number == headnum)
+ {
+ if (mons_near(monster))
+ tent++;
+ monster->hurt(monster, INSTANT_DEATH);
+ }
+ }
+ return tent;
+}
+
int monster_die(monsters *monster, killer_type killer,
int killer_index, bool silent, bool wizard)
{
@@ -1816,6 +1883,14 @@ int monster_die(monsters *monster, killer_type killer,
{
_hogs_to_humans();
}
+ else if (monster->type == MONS_KRAKEN)
+ {
+ if (_destroy_tentacles(monster) && !in_transit)
+ {
+ mpr("The kraken is slain, and its tentacles slide "
+ "back into the water like the carrion they now are.");
+ }
+ }
else if (!mons_is_summoned(monster))
{
if (mons_genus(monster->type) == MONS_MUMMY)
@@ -2427,6 +2502,8 @@ bool monster_blink(monsters *monster, bool quiet)
monster->check_redraw(oldplace);
monster->apply_location_effects(oldplace);
+ mons_relocated(monster);
+
return (true);
}