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

Function init_poly_set

crawl-ref/source/mon-poly.cc:535–562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

533}
534
535void init_poly_set(monster *mons)
536{
537 rng::subgenerator poly_rng;
538
539 if (mons->props.exists(POLY_SET_KEY))
540 return;
541
542 const int orig_tier = mons_demon_tier(mons->type);
543 if (orig_tier == -1)
544 {
545 // panlords & hell lords get poly immunity. why? unclear to me
546 // TODO: allow polying panlords into other random panlords, ha
547 return;
548 }
549
550 map<monster_type, int> weights;
551 _fill_poly_weights(*mons, PPT_SAME, true, weights);
552 CrawlVector &set = mons->props[POLY_SET_KEY];
553 for (int i = 0; i < 3; i++)
554 {
555 if (weights.empty())
556 return; // can't choose any more
557 const monster_type *chosen = random_choose_weighted<map<monster_type,int>>(weights);
558 ASSERT(chosen);
559 set.push_back(*chosen);
560 weights.erase(*chosen);
561 }
562}
563
564static monster_type _poly_from_set(monster &mons)
565{

Callers 5

_protean_explosionFunction · 0.85
change_monster_typeFunction · 0.85
tags.ccFile · 0.85
_place_monster_auxFunction · 0.85
_do_splitFunction · 0.85

Calls 6

mons_demon_tierFunction · 0.85
_fill_poly_weightsFunction · 0.85
existsMethod · 0.80
emptyMethod · 0.45
push_backMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected