diff options
author | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-03-21 02:22:03 +0000 |
---|---|---|
committer | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-03-21 02:22:03 +0000 |
commit | 0c496e0be392bbf839533c9d69da1499b883b3ac (patch) | |
tree | 113f5b56928b11cbd7049535cdbb815d49f6d6d4 /crawl-ref/source/monstuff.cc | |
parent | d07a34ba115b47a74496b1810c5ede4b0e86c748 (diff) | |
download | crawl-ref-0c496e0be392bbf839533c9d69da1499b883b3ac.tar.gz crawl-ref-0c496e0be392bbf839533c9d69da1499b883b3ac.zip |
Revert the splitting out of monster_change_type() from
monster_polymorph(), as it still doesn't do everything needed. Replace
it with monsters::change_type(), split out from
monsters::level_up_change(), which does do everything needed, and in a
cleaner way. Unfortunately, it's still a hack, but it should be easier
to deal with for now. Sorry for the mess.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3783 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/monstuff.cc')
-rw-r--r-- | crawl-ref/source/monstuff.cc | 100 |
1 files changed, 38 insertions, 62 deletions
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 8321035178..b293160a48 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -1305,49 +1305,6 @@ static bool is_poly_power_unsuitable( } } -// Change one monster type into another. This preserves as much as -// possible between types, so, if the two types are radically different, -// some special handling may be needed after calling this. -void monster_change_type(monsters *monster, monster_type targetc) -{ - const unsigned long old_flags = monster->flags; - const unsigned long old_exp = monster->experience; - const int old_hp = monster->hit_points; - const int old_hp_max = monster->max_hit_points; - const char old_ench_countdown = monster->ench_countdown; - const bool old_mon_caught = mons_is_caught(monster); - - /* deal with mons_sec */ - monster->type = targetc; - monster->number = MONS_PROGRAM_BUG; - - mon_enchant abj = monster->get_ench(ENCH_ABJ); - mon_enchant shifter = monster->get_ench(ENCH_GLOWING_SHAPESHIFTER, - ENCH_SHAPESHIFTER); - - // Note: define_monster() will clear out all enchantments! -- bwr - define_monster( monster_index(monster) ); - - monster->flags = old_flags; - monster->gain_exp(old_exp); - - monster->add_ench(abj); - monster->add_ench(shifter); - - monster->ench_countdown = old_ench_countdown; - - if (mons_class_flag( monster->type, M_INVIS )) - monster->add_ench(ENCH_INVIS); - - monster->hit_points = monster->max_hit_points - * ((old_hp * 100) / old_hp_max) / 100; - - monster->fix_speed(); - - if (old_mon_caught) - monster->add_ench(ENCH_HELD); -} - /* * if targetc == RANDOM_MONSTER then relpower indicates the desired * power of the new monster relative to the current monster. @@ -1428,7 +1385,6 @@ bool monster_polymorph( monsters *monster, monster_type targetc, } bool player_messaged = simple_monster_message(monster, str_polymon.c_str()); - const bool old_mon_caught = mons_is_caught(monster); // Even if the monster transforms from one type that can behold the // player into a different type which can also behold the player, @@ -1438,29 +1394,48 @@ bool monster_polymorph( monsters *monster, monster_type targetc, update_beholders(monster, true); // the actual polymorphing: - monster_change_type(monster, targetc); + const int old_hp = monster->hit_points; + const int old_hp_max = monster->max_hit_points; + const bool old_mon_caught = mons_is_caught(monster); + const char old_ench_countdown = monster->ench_countdown; - // randomize things: - monster->flags = 0L; - monster->experience = 0L; + /* deal with mons_sec */ + monster->type = targetc; + monster->number = MONS_PROGRAM_BUG; - monster->hit_points += random2(monster->max_hit_points); + mon_enchant abj = monster->get_ench(ENCH_ABJ); + mon_enchant shifter = monster->get_ench(ENCH_GLOWING_SHAPESHIFTER, + ENCH_SHAPESHIFTER); - if (monster->hit_points > monster->max_hit_points) - monster->hit_points = monster->max_hit_points; + // Note: define_monster() will clear out all enchantments! -- bwr + define_monster( monster_index(monster) ); - monster->speed_increment = 67 + random2(6); + monster->add_ench(abj); + monster->add_ench(shifter); - // drop entire inventory: - monster_drop_ething(monster); + monster->ench_countdown = old_ench_countdown; - if (!player_messaged && player_monster_visible(monster) - && mons_near(monster)) + if (mons_class_flag( monster->type, M_INVIS )) + monster->add_ench(ENCH_INVIS); + + if (!player_messaged && mons_near(monster) + && player_monster_visible(monster)) { - player_messaged = true; mprf("%s appears out of thin air!", monster->name(DESC_CAP_A).c_str()); + player_messaged = true; } + monster->hit_points = monster->max_hit_points + * ((old_hp * 100) / old_hp_max) / 100 + + random2(monster->max_hit_points); + + if (monster->hit_points > monster->max_hit_points) + monster->hit_points = monster->max_hit_points; + + monster->speed_increment = 67 + random2(6); + + monster_drop_ething(monster); + // New monster type might be interesting mark_interesting_monst(monster); @@ -1474,10 +1449,7 @@ bool monster_polymorph( monsters *monster, monster_type targetc, { int net = get_trapping_net(monster->x, monster->y); if (net != NON_ITEM) - { destroy_item(net); - monster->del_ench(ENCH_HELD, true); - } if (see_grid(monster->x, monster->y)) { @@ -1496,8 +1468,10 @@ bool monster_polymorph( monsters *monster, monster_type targetc, || monster->type == MONS_OOZE || monster->type == MONS_PULSATING_LUMP) { - mons_clear_trapping_net(monster); - + const int net = get_trapping_net(monster->x, monster->y); + if (net != NON_ITEM) + remove_item_stationary(mitm[net]); + if (mons_is_insubstantial(monster->type)) { simple_monster_message(monster, @@ -1509,6 +1483,8 @@ bool monster_polymorph( monsters *monster, monster_type targetc, " oozes right through the net!"); } } + else + monster->add_ench(ENCH_HELD); } return (player_messaged); |