the code to change one monster type into another into its own function, and use it. The code handling net trapping should probably be somewhere else, though.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3772 c06c8d41-db1a-0410-9941-cceddc491573
USSKCWQTF6BTE3SFLQVCT6RZHU2R7URWFC7EPO2EN3Z6U4IEQ7GQC LJ7HIRLTL5KHP3DJP57KRDH3PHZIS37HNC4SLZGK2ZQI2WTQBOPAC IE3INS4WUXZOBVXB5VWRBYPVPXADD2U2W5H3TBTOYNWJ3EGRSGQQC AOXEL2V6ICXEIRWXB76LJARWP3NPKG2L4UFYOIQUALUJU4ZLE3UQC RIIO4BI64ECFXSRLBP3RA24QOPYXJVWMSFHLNTKUZS5YCLISLVJQC K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC KFULGQQOHWUTXOM3BXCCYPGGVGGY4Z6265XUFRCBPNLTZAEHJZSQC RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC RCPQNIRPR3NQXEMVLBAQW6657UJFIP43N54UJVEZHJH22OH4UQIQC MX2KOWAIE37VLSQJWXVEDVQVB3DL325Q7YFUSSHYMAIH53Y74IJQC 4UXFU3FZOCBSLDQ4S7MJKAE2H7VUHCNRDQMIY6NJ3PHYXWNGISDQC OSGS3PH2L5CBTDVZCZS6OCFQNA4A7RMEXBYJQB7DDZBYYJW7QSSAC X5WLJCJVW55SXZVP7IKP7ADCJIGNKN4PKAXFECVR6TNK7XSMZR7QC UIRWVLX5LDNWURTZOG7EFLXE5OOEL4XBPSLSUHUQSKHC4A7WCVLQC 2SMZGNBB352OJBIT2UE3NONODTTMV3FJJFBQUN4VNLLNYJKTJKBQC 5ZYOO2RVGH53ONV4U5NO6MTINQXET6GV6TETPVCFAVOX44LDNR4QC BRGAZR5AXWC2IALBVXO5SB354IRQEIRHSK55RZPGFI4AGIOD4LUQC 3BJ2OOF4F524G6UKVGOZVT6W3FSTSHHTKRJADUBZCHDXZWV3KANQC RGY2525RQH7SSGM6ZVI7CZL4WMNFZK2WRABOSIWRKQYYOU2RWN4QC const int old_hp = mon->hit_points;const int old_hp_max = mon->max_hit_points;const char old_ench_countdown = mon->ench_countdown;mon_enchant abj = mon->get_ench(ENCH_ABJ);mon_enchant shifter = mon->get_ench(ENCH_GLOWING_SHAPESHIFTER,ENCH_SHAPESHIFTER);const bool old_mon_caught = mons_is_caught(mon);
mon->hit_points = mon->max_hit_points *((old_hp * 100) / old_hp_max) / 100;mon->ench_countdown = old_ench_countdown;mon->add_ench(abj);mon->add_ench(shifter);if (old_mon_caught)mon->add_ench(ENCH_HELD);if (mons_class_flag(mon->type, M_INVIS))mon->add_ench(ENCH_INVIS);mon->fix_speed();
/* Change one monster type into another. */void monster_change_type(monsters *monster, monster_type 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;/* 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! -- bwrdefine_monster( monster_index(monster) );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){if (monster->body_size(PSIZE_BODY) >= SIZE_GIANT){int net = get_trapping_net(monster->x, monster->y);if (net != NON_ITEM)destroy_item(net);
if (see_grid(monster->x, monster->y)){if (player_monster_visible(monster)){mprf("The net rips apart, and %s comes free!",monster->name(DESC_NOCAP_THE).c_str());}else{mpr("All of a sudden the net rips apart!");}}}else if (mons_is_insubstantial(monster->type)|| monster->type == MONS_OOZE|| monster->type == MONS_PULSATING_LUMP){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," drifts right through the net!");}else{simple_monster_message(monster," oozes right through the net!");}}elsemonster->add_ench(ENCH_HELD);}}
// Used to be mons_power, but that just returns hit_dice// for the monster class. By using the current hit dice// the player gets the opportunity to use draining more
// Used to be mons_power, but that just returns hit_dice// for the monster class. By using the current hit dice// the player gets the opportunity to use draining more
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;
monster_change_type(monster, targetc);
/* 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);
monster->hit_points += random2(monster->max_hit_points);
if (mons_class_flag( monster->type, M_INVIS ))monster->add_ench(ENCH_INVIS);if (!player_messaged && mons_near(monster)&& player_monster_visible(monster))
if (!player_messaged && player_monster_visible(monster)&& mons_near(monster))
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);
if (see_grid(monster->x, monster->y)){if (player_monster_visible(monster)){mprf("The net rips apart, and %s comes free!",monster->name(DESC_NOCAP_THE).c_str());}else{mpr("All of a sudden the net rips apart!");}}}else if (mons_is_insubstantial(monster->type)|| monster->type == MONS_OOZE|| monster->type == MONS_PULSATING_LUMP){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," drifts right through the net!");}else{simple_monster_message(monster," oozes right through the net!");}}elsemonster->add_ench(ENCH_HELD);}