MCPcopy Create free account
hub / github.com/crawl/crawl / _do_split

Function _do_split

crawl-ref/source/mon-abil.cc:244–329  ·  view source on GitHub ↗

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).

Source from the content-addressed store, hash-verified

242// merge count with the new monster.
243// Returns the new slime (nullptr if it fails).
244static 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;

Callers 3

_slime_splitFunction · 0.85
slymdra_splitFunction · 0.85
_starcursed_splitFunction · 0.85

Calls 15

create_monsterFunction · 0.85
mprfFunction · 0.85
_share_ench_durationsFunction · 0.85
init_poly_setFunction · 0.85
get_monster_dataFunction · 0.85
hit_pointsFunction · 0.85
_stats_from_blob_countFunction · 0.85
arena_split_monsterFunction · 0.85
can_seeMethod · 0.80
existsMethod · 0.80
set_hit_diceMethod · 0.80
game_is_arenaMethod · 0.80

Tested by

no test coverage detected