| 533 | } |
| 534 | |
| 535 | void 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 | |
| 564 | static monster_type _poly_from_set(monster &mons) |
| 565 | { |
no test coverage detected