Create a new slime creature at 'target', and split 'thing''s hp and merge count with the new monster. Returns the new slime (nullptr if it fails).
| 242 | // merge count with the new monster. |
| 243 | // Returns the new slime (nullptr if it fails). |
| 244 | static monster* _do_split(monster* thing, const coord_def & target, bool quiet = false) |
| 245 | { |
| 246 | ASSERT(thing); // XXX: change to monster &thing |
| 247 | ASSERT(thing->alive()); |
| 248 | |
| 249 | // Create a new slime. |
| 250 | monster_type type = thing->type == MONS_SLYMDRA ? MONS_SLIME_CREATURE |
| 251 | : thing->type; |
| 252 | mgen_data new_slime_data = mgen_data(type, |
| 253 | SAME_ATTITUDE(thing), |
| 254 | target, |
| 255 | thing->foe, |
| 256 | MG_FORCE_PLACE); |
| 257 | |
| 258 | // Don't explicitly announce the child slime coming into view if you |
| 259 | // saw the split that created it |
| 260 | if (you.can_see(*thing)) |
| 261 | new_slime_data.extra_flags |= MF_WAS_IN_VIEW; |
| 262 | |
| 263 | monster *new_slime = create_monster(new_slime_data); |
| 264 | |
| 265 | if (!new_slime) |
| 266 | return 0; |
| 267 | |
| 268 | if (!quiet && you.can_see(*thing)) |
| 269 | { |
| 270 | if (thing->type == MONS_SLYMDRA) |
| 271 | { |
| 272 | mprf("%s separates from %s.", new_slime->name(DESC_A).c_str(), |
| 273 | thing->name(DESC_A).c_str()); |
| 274 | } |
| 275 | else |
| 276 | mprf("%s splits.", thing->name(DESC_A).c_str()); |
| 277 | } |
| 278 | |
| 279 | // Inflict the new slime with any enchantments on the parent. |
| 280 | _share_ench_durations(thing, new_slime); |
| 281 | new_slime->attitude = thing->attitude; |
| 282 | new_slime->behaviour = thing->behaviour; |
| 283 | new_slime->flags = thing->flags; |
| 284 | new_slime->props = thing->props; |
| 285 | new_slime->summoner = thing->summoner; |
| 286 | if (thing->props.exists(BLAME_KEY)) |
| 287 | new_slime->props[BLAME_KEY] = thing->props[BLAME_KEY].get_vector(); |
| 288 | if (thing->type == MONS_SLYMDRA) |
| 289 | { |
| 290 | new_slime->props.erase(POLY_SET_KEY); |
| 291 | init_poly_set(new_slime); |
| 292 | } |
| 293 | |
| 294 | // Lose heads and HP equivalent to those heads |
| 295 | if (thing->type == MONS_SLYMDRA) |
| 296 | { |
| 297 | --thing->num_heads; |
| 298 | const monsterentry *m_ent = get_monster_data(MONS_SLYMDRA); |
| 299 | |
| 300 | const int new_avg_hp = div_rand_round(m_ent->avg_hp_10x * thing->get_hit_dice(), m_ent->HD); |
| 301 | const int hp = hit_points(new_avg_hp) + SLYMDRA_HP_PER_HEAD * thing->num_heads; |
no test coverage detected