diff options
author | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-12 20:15:52 -0800 |
---|---|---|
committer | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-12 20:16:21 -0800 |
commit | be0551c2205ac189be5558447625642553c80dd3 (patch) | |
tree | 65bb0a2b8e30c9f8bc88a67968f6a91420d28163 /crawl-ref/source | |
parent | 81909732f69d66ccd53c0701bbb7c6507ecec5b1 (diff) | |
download | crawl-ref-be0551c2205ac189be5558447625642553c80dd3.tar.gz crawl-ref-be0551c2205ac189be5558447625642553c80dd3.zip |
porkulator: completely restore reverted monsters
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/beam.cc | 11 | ||||
-rw-r--r-- | crawl-ref/source/mon-stuff.cc | 43 | ||||
-rw-r--r-- | crawl-ref/source/mon-stuff.h | 2 |
3 files changed, 42 insertions, 14 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 864d38d439..b5f7e83590 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -5371,13 +5371,20 @@ mon_resist_type bolt::apply_enchantment_to_monster(monsters* mon) if (mons_is_ghost_demon(mon->type)) return (MON_UNAFFECTED); - monster_type orig_type = mon->type; + monsters orig_mon(*mon); if (monster_polymorph(mon, (mon->holiness() == MH_DEMONIC ? MONS_HELL_HOG : MONS_HOG))) { obvious_effect = true; + + // Don't restore items to monster if it reverts. + orig_mon.inv = mon->inv; + + // For monster reverting to original form. + mon->props[ORIG_MONSTER_KEY] = orig_mon; } - mon->number = ((int) orig_type + 1); + + return (MON_AFFECTED); } diff --git a/crawl-ref/source/mon-stuff.cc b/crawl-ref/source/mon-stuff.cc index d035182376..5cf5677528 100644 --- a/crawl-ref/source/mon-stuff.cc +++ b/crawl-ref/source/mon-stuff.cc @@ -1320,23 +1320,42 @@ static void _hogs_to_humans() const bool could_see = you.can_see(*mi); - // XXX: This resets the size of slime creatures, the number - // of heads a hydra has, and the number of spikes a manticore - // has. Plus it also changes the colour of a draconian which - // has a sub-type. And it re-rolls the spellbook the monster - // has. - if (mi->number == 0) - mi->type = MONS_HUMAN; + monsters _orig; + monsters* orig; + + if (mi->props.exists(ORIG_MONSTER_KEY)) + { + orig = &(mi->props[ORIG_MONSTER_KEY].get_monster()); + } else - mi->type = (monster_type) (mi->number - 1); + { + orig = &_orig; + orig->type = MONS_HUMAN; + define_monster(*orig); + } + + // Preserve relative HP. + const float hp + = (float) mi->hit_points / (float) mi->max_hit_points; + // Preserve some flags. + const unsigned long preserve_flags = + mi->flags & ~(MF_JUST_SUMMONED | MF_WAS_IN_VIEW); - // Keep enchantments. + // Preserve enchantments. mon_enchant_list enchantments = mi->enchantments; - mi->number = 0; - define_monster(**mi); + // Restore original monster. + **mi = *orig; mi->enchantments = enchantments; + mi->hit_points = std::max(1, (int) (mi->max_hit_points * hp)); + mi->flags = mi->flags | preserve_flags; + + // Allow ORIG_MONSTER_KEY to be chained. + if (orig->props.exists(ORIG_MONSTER_KEY)) + mi->props[ORIG_MONSTER_KEY] = orig->props[ORIG_MONSTER_KEY]; + else + mi->props.erase(ORIG_MONSTER_KEY); const bool can_see = you.can_see(*mi); @@ -1354,7 +1373,7 @@ static void _hogs_to_humans() && mons_intel(*mi) >= I_NORMAL) { mi->attitude = ATT_GOOD_NEUTRAL; - mi->flags |= MF_WAS_NEUTRAL; + mi->flags |= MF_WAS_NEUTRAL; } } diff --git a/crawl-ref/source/mon-stuff.h b/crawl-ref/source/mon-stuff.h index fe82988618..4f1bb73a78 100644 --- a/crawl-ref/source/mon-stuff.h +++ b/crawl-ref/source/mon-stuff.h @@ -10,6 +10,8 @@ #include "mon-util.h" +#define ORIG_MONSTER_KEY "orig_monster_key" + enum mon_dam_level_type { MDAM_OKAY, |