summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Otto <ottochar@gmail.com>2009-11-13 01:50:34 -0500
committerCharles Otto <ottochar@gmail.com>2009-11-13 01:50:34 -0500
commite55cf763ffe7a240f57663731d820b8bff78219b (patch)
tree8cea1c95475ca00958b7c89e8abeddeaf732fe00
parent5e448f7064f29d42f4d22e177c05acdae0da2d5c (diff)
downloadcrawl-ref-e55cf763ffe7a240f57663731d820b8bff78219b.tar.gz
crawl-ref-e55cf763ffe7a240f57663731d820b8bff78219b.zip
Use monster_iterator in ballistomycete functions
Also some comment and whitespace changes.
-rw-r--r--crawl-ref/source/beam.cc4
-rw-r--r--crawl-ref/source/mon-abil.cc49
-rw-r--r--crawl-ref/source/monster.cc4
3 files changed, 28 insertions, 29 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 973962a6af..4d4d2526f6 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -3108,13 +3108,13 @@ void bolt::affect_ground()
{
beh_type beh;
// Half the fungi in arena mode are friendly.
- if(crawl_state.arena)
+ if (crawl_state.arena)
{
beh = coinflip() ? BEH_FRIENDLY : BEH_HOSTILE;
}
else
{
- switch(this->attitude)
+ switch (this->attitude)
{
case ATT_NEUTRAL:
beh = BEH_NEUTRAL;
diff --git a/crawl-ref/source/mon-abil.cc b/crawl-ref/source/mon-abil.cc
index 2553c4faee..02afabec9a 100644
--- a/crawl-ref/source/mon-abil.cc
+++ b/crawl-ref/source/mon-abil.cc
@@ -1400,7 +1400,7 @@ void ballisto_on_move(monsters * monster, const coord_def & position)
if (one_chance_in(4))
{
beh_type attitude = SAME_ATTITUDE(monster);
- if(!crawl_state.arena && attitude == BEH_FRIENDLY)
+ if (!crawl_state.arena && attitude == BEH_FRIENDLY)
{
attitude = BEH_GOOD_NEUTRAL;
}
@@ -1432,33 +1432,34 @@ void ballisto_on_move(monsters * monster, const coord_def & position)
// than 0 it changes color and starts producing spores.
void activate_ballistomycetes( monsters * monster)
{
- if(!monster || monster->type != MONS_BALLISTOMYCETE
- && monster->type != MONS_GIANT_SPORE)
+ if (!monster || monster->type != MONS_BALLISTOMYCETE
+ && monster->type != MONS_GIANT_SPORE)
{
return;
}
bool activated_others = false;
int seen_others = 0;
- for(int i=0; i < int(env.mons.size()); ++i)
+
+ for (monster_iterator mi; mi; ++mi)
{
- if(i != monster->mindex()
- && env.mons[i].alive()
- && env.mons[i].type == MONS_BALLISTOMYCETE)
+ if (mi->mindex() != monster->mindex()
+ && mi->alive()
+ && mi->type == MONS_BALLISTOMYCETE)
{
- env.mons[i].number++;
+ mi->number++;
// Change color and start the spore production timer if we
// are moving from 0 to 1.
- if(env.mons[i].number == 1)
+ if (mi->number == 1)
{
- env.mons[i].colour = LIGHTRED;
+ mi->colour = LIGHTRED;
// Reset the spore production timer.
- env.mons[i].del_ench(ENCH_SPORE_PRODUCTION, false);
- env.mons[i].add_ench(ENCH_SPORE_PRODUCTION);
+ mi->del_ench(ENCH_SPORE_PRODUCTION, false);
+ mi->add_ench(ENCH_SPORE_PRODUCTION);
activated_others = true;
- if(you.can_see(&env.mons[i]))
+ if (you.can_see(*mi))
seen_others++;
}
}
@@ -1466,7 +1467,7 @@ void activate_ballistomycetes( monsters * monster)
// Do some messaging. I'm not entirely sure how detailed to get,
// so erroring on the side of message spam at this point. -cao
- if(mons_near(monster) && activated_others)
+ if (mons_near(monster) && activated_others)
mprf("The fungus' death has angered other fungi on the level.");
if (seen_others == 1)
mprf("A ballistomycete appears irritated.");
@@ -1479,28 +1480,26 @@ void activate_ballistomycetes( monsters * monster)
// colorr (back to magenta) and stops producing spores.
void deactivate_ballistos()
{
- for(unsigned i=0;i < env.mons.size(); i++)
+ for (monster_iterator mi; mi; ++mi)
{
- if(env.mons[i].alive()
- && env.mons[i].type == MONS_BALLISTOMYCETE)
+ if (mi->alive()
+ && mi->type == MONS_BALLISTOMYCETE)
{
- monsters * temp = &env.mons[i];
// Decrease the count and maybe become inactive
// again
- if(temp->number)
+ if (mi->number)
{
- temp->number--;
- if(temp->number == 0)
+ mi->number--;
+ if (mi->number == 0)
{
- temp->colour = MAGENTA;
- temp->del_ench(ENCH_SPORE_PRODUCTION);
+ mi->colour = MAGENTA;
+ mi->del_ench(ENCH_SPORE_PRODUCTION);
- if(you.can_see(temp))
+ if (you.can_see(*mi))
mprf("A nearby ballistomycete calms down.");
}
}
-
}
}
}
diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc
index 393985e1ef..2944ff1188 100644
--- a/crawl-ref/source/monster.cc
+++ b/crawl-ref/source/monster.cc
@@ -6058,8 +6058,8 @@ int mon_enchant::calc_duration(const monsters *mons,
return (2 * FRESHEST_CORPSE + random2(10))
* speed_to_duration(mons->speed) * mons->speed / 10;
case ENCH_SPORE_PRODUCTION:
- // The duration of the spore production timer depends on the color
- // of the fungus
+ // This is used as a simple timer, when the enchantment runs out
+ // the monster will create a giant spore.
cturn = 150;
break;