From dfc417fb139ee880cccfcbca5c8c7ec94913da63 Mon Sep 17 00:00:00 2001 From: Charles Otto Date: Fri, 13 Nov 2009 19:44:57 -0500 Subject: Change ballistomycete spawn mechanics (again) When a spore pops or a ballistomycete is killed randomly select a single ballisto to activate instead of activating the entire level's worth. Along with this, only deactivate the ballisto that produced a spore instead of deactivating the entire level. Rationale: since inactive ballistos don't interrupt travel anymore it's nicer from an interface perspective to keep most of the ballistos on the level inactive. --- crawl-ref/source/mon-abil.cc | 61 +++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 41 deletions(-) (limited to 'crawl-ref/source/mon-abil.cc') diff --git a/crawl-ref/source/mon-abil.cc b/crawl-ref/source/mon-abil.cc index 3a258d469f..e51d95214e 100644 --- a/crawl-ref/source/mon-abil.cc +++ b/crawl-ref/source/mon-abil.cc @@ -1439,61 +1439,40 @@ void activate_ballistomycetes( monsters * monster, const coord_def & origin) } bool found_others = false; - int seen_others = 0; + std::vector candidates; for (monster_iterator mi; mi; ++mi) { if (mi->mindex() != monster->mindex() && mi->alive() && mi->type == MONS_BALLISTOMYCETE) { - mi->number++; - found_others = true; - // Change color and start the spore production timer if we - // are moving from 0 to 1. - if (mi->number == 1) - { - mi->colour = LIGHTRED; - // Reset the spore production timer. - mi->del_ench(ENCH_SPORE_PRODUCTION, false); - mi->add_ench(ENCH_SPORE_PRODUCTION); + candidates.push_back(*mi); - if (you.can_see(*mi)) - seen_others++; - } } } - if (you.see_cell(origin) && found_others) - { - mprf("You feel the ballistomycetes will spawn a replacement spore."); - } -} -// Decrease the count on each ballistomycete on the level. To be called -// after a new spore is created. If a ballistos count drops to 0 it changes -// colorr (back to magenta) and stops producing spores. -void deactivate_ballistos() -{ - for (monster_iterator mi; mi; ++mi) + if (!candidates.empty()) { - if (mi->alive() - && mi->type == MONS_BALLISTOMYCETE) - { - // Decrease the count and maybe become inactive - // again - if (mi->number) - { - mi->number--; - if (mi->number == 0) - { - mi->colour = MAGENTA; - mi->del_ench(ENCH_SPORE_PRODUCTION); - } - } + monsters * spawner = candidates[random2(candidates.size())]; + spawner->number++; + found_others = true; + + // Change color and start the spore production timer if we + // are moving from 0 to 1. + if (spawner->number == 1) + { + spawner->colour = LIGHTRED; + // Reset the spore production timer. + spawner->del_ench(ENCH_SPORE_PRODUCTION, false); + spawner->add_ench(ENCH_SPORE_PRODUCTION); } } -} - + if (you.see_cell(origin) && found_others) + { + mprf("You feel the ballistomycetes will spawn a replacement spore."); + } +} -- cgit v1.2.3-54-g00ecf