summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/godcompanions.cc
diff options
context:
space:
mode:
authorDracoOmega <draco_omega@live.com>2013-02-26 16:35:56 -0330
committerDracoOmega <draco_omega@live.com>2013-03-03 18:36:48 -0330
commit5366e40bb4f959cf39edc21afbcf167bddba3009 (patch)
tree5dadc6a919ab8ff515fb21241ea19f6287a79ed1 /crawl-ref/source/godcompanions.cc
parent1bd74f58a62e72d0ffebc7184334b0d6b5a7fdac (diff)
downloadcrawl-ref-5366e40bb4f959cf39edc21afbcf167bddba3009.tar.gz
crawl-ref-5366e40bb4f959cf39edc21afbcf167bddba3009.zip
Timeout monster enchantments and heal monsters when recalling from off-level
Diffstat (limited to 'crawl-ref/source/godcompanions.cc')
-rw-r--r--crawl-ref/source/godcompanions.cc30
1 files changed, 29 insertions, 1 deletions
diff --git a/crawl-ref/source/godcompanions.cc b/crawl-ref/source/godcompanions.cc
index ab2dd09ae7..0edbd3ee90 100644
--- a/crawl-ref/source/godcompanions.cc
+++ b/crawl-ref/source/godcompanions.cc
@@ -93,11 +93,39 @@ bool recall_offlevel_companions()
{
if (comp->mons.place(true))
{
+ monster* mons = monster_by_mid(mid);
+
// The monster is now on this level
remove_monster_from_transit(comp->level, mid);
comp->level = level_id::current();
- simple_monster_message(monster_by_mid(mid), " is recalled.");
+ simple_monster_message(mons, " is recalled.");
recalled = true;
+
+ // Catch up time for off-level monsters
+ // (We move the player away so that we don't get expiry
+ // messages for things that supposed wore off ages ago)
+ const coord_def old_pos = you.pos();
+ you.moveto(coord_def(0, 0));
+
+ int turns = you.elapsed_time - comp->timestamp;
+ if (mons_can_regenerate(mons))
+ {
+ if (monster_descriptor(mons->type, MDSC_REGENERATES))
+ mons->heal(turns);
+ else
+ {
+ const int regen_rate = max(mons_natural_regen_rate(mons) * 2, 5);
+ mons->heal(div_rand_round(turns * regen_rate, 50));
+ }
+ }
+ if (turns >= 10 && mons->alive())
+ {
+ // Remove confusion manually (so that the monster
+ // doesn't blink after being recalled)
+ mons->del_ench(ENCH_CONFUSION, true);
+ mons->timeout_enchantments(turns / 10);
+ }
+ you.moveto(old_pos);
}
}
}