summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorDavid Lawrence Ramsey <dolorous@users.sourceforge.net>2009-10-06 18:31:13 -0500
committerDavid Lawrence Ramsey <dolorous@users.sourceforge.net>2009-10-06 18:31:13 -0500
commitf408bf9c354f827c64e1416279b338a921545ff0 (patch)
treee7c9b77b1616c5efbbd9de3c9f7761b86c58395b /crawl-ref/source
parent23ff814fd3727442f17b093612e2bd802e972c2e (diff)
downloadcrawl-ref-f408bf9c354f827c64e1416279b338a921545ff0.tar.gz
crawl-ref-f408bf9c354f827c64e1416279b338a921545ff0.zip
Make sure that all (very) ugly things in a band start with the same
colour.
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/ghost.cc25
-rw-r--r--crawl-ref/source/ghost.h4
-rw-r--r--crawl-ref/source/monplace.cc32
3 files changed, 49 insertions, 12 deletions
diff --git a/crawl-ref/source/ghost.cc b/crawl-ref/source/ghost.cc
index 5c44c36434..02d882d4b9 100644
--- a/crawl-ref/source/ghost.cc
+++ b/crawl-ref/source/ghost.cc
@@ -398,18 +398,29 @@ void ghost_demon::init_player_ghost()
add_spells();
}
-static unsigned char _ugly_thing_random_colour(unsigned char not_colour)
+unsigned char ugly_thing_random_colour()
{
const unsigned char colours[] =
{
CYAN, GREEN, RED, LIGHTGREY, BROWN, MAGENTA
};
+ return (RANDOM_ELEMENT(colours));
+}
+
+static unsigned char _ugly_thing_assign_colour(unsigned char force_colour,
+ unsigned char force_not_colour)
+{
unsigned char colour;
- do
- colour = RANDOM_ELEMENT(colours);
- while (colour == not_colour);
+ if (force_colour != BLACK)
+ colour = force_colour;
+ else
+ {
+ do
+ colour = ugly_thing_random_colour();
+ while (force_not_colour != BLACK && colour == force_not_colour);
+ }
return (colour);
}
@@ -474,7 +485,8 @@ static mon_attack_flavour _ugly_thing_flavour_upgrade(mon_attack_flavour u_att_f
return (u_att_flav);
}
-void ghost_demon::init_ugly_thing(bool very_ugly, bool only_mutate)
+void ghost_demon::init_ugly_thing(bool very_ugly, bool only_mutate,
+ unsigned char force_colour)
{
// Midpoint: 10, as in mon-data.h.
speed = 9 + random2(3);
@@ -521,7 +533,8 @@ void ghost_demon::init_ugly_thing(bool very_ugly, bool only_mutate)
// An ugly thing always gets a low-intensity colour. If we're
// mutating it, it always gets a different colour from what it had
// before.
- colour = _ugly_thing_random_colour(only_mutate ? make_low_colour(colour)
+ colour = _ugly_thing_assign_colour(make_low_colour(force_colour),
+ only_mutate ? make_low_colour(colour)
: BLACK);
// Pick a compatible attack flavour for this colour.
diff --git a/crawl-ref/source/ghost.h b/crawl-ref/source/ghost.h
index ae2ac91a23..db774701d0 100644
--- a/crawl-ref/source/ghost.h
+++ b/crawl-ref/source/ghost.h
@@ -44,7 +44,8 @@ public:
void reset();
void init_random_demon();
void init_player_ghost();
- void init_ugly_thing(bool very_ugly, bool only_mutate = false);
+ void init_ugly_thing(bool very_ugly, bool only_mutate = false,
+ unsigned char force_colour = BLACK);
void ugly_thing_to_very_ugly_thing();
public:
@@ -62,6 +63,7 @@ private:
void ugly_thing_add_resistance();
};
+unsigned char ugly_thing_random_colour();
bool debug_check_ghosts();
extern std::vector<ghost_demon> ghosts;
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc
index f300baa4ce..b44daf8f51 100644
--- a/crawl-ref/source/monplace.cc
+++ b/crawl-ref/source/monplace.cc
@@ -757,6 +757,9 @@ int place_monster(mgen_data mg, bool force_pos)
monster_type band_monsters[BIG_BAND]; // band monster types
band_monsters[0] = mg.cls;
+ // The (very) ugly thing band colour.
+ static unsigned char ugly_colour = BLACK;
+
if (mg.permit_bands())
{
#ifdef DEBUG_MON_CREATION
@@ -765,10 +768,25 @@ int place_monster(mgen_data mg, bool force_pos)
const band_type band = _choose_band(mg.cls, mg.power, band_size);
band_size++;
- for (int i = 1; i < band_size; i++)
- band_monsters[i] = _band_member( band, mg.power );
+ for (int i = 1; i < band_size; ++i)
+ {
+ band_monsters[i] = _band_member(band, mg.power);
+
+ // Get the (very) ugly thing band colour, so that all (very)
+ // ugly things in a band will start with it.
+ if ((band_monsters[i] == MONS_UGLY_THING
+ || band_monsters[i] == MONS_VERY_UGLY_THING)
+ && ugly_colour == BLACK)
+ {
+ ugly_colour = ugly_thing_random_colour();
+ }
+ }
}
+ // Set the (very) ugly thing band colour.
+ if (ugly_colour != BLACK)
+ mg.colour = ugly_colour;
+
// Returns 2 if the monster is placed near player-occupied stairs.
int pval = _is_near_stairs(mg.pos);
if (mg.proximity == PROX_NEAR_STAIRS)
@@ -890,6 +908,9 @@ int place_monster(mgen_data mg, bool force_pos)
id = _place_monster_aux(mg, true, force_pos);
+ // Reset the (very) ugly thing band colour.
+ ugly_colour = BLACK;
+
// Bail out now if we failed.
if (id == -1)
return (-1);
@@ -1235,8 +1256,8 @@ static int _place_monster_aux(const mgen_data &mg,
if (summoned)
{
- menv[id].mark_summoned( mg.abjuration_duration, true,
- mg.summon_type );
+ menv[id].mark_summoned(mg.abjuration_duration, true,
+ mg.summon_type);
}
menv[id].foe = mg.foe;
@@ -1245,7 +1266,8 @@ static int _place_monster_aux(const mgen_data &mg,
|| menv[id].type == MONS_VERY_UGLY_THING)
{
ghost_demon ghost;
- ghost.init_ugly_thing(menv[id].type == MONS_VERY_UGLY_THING);
+ ghost.init_ugly_thing(menv[id].type == MONS_VERY_UGLY_THING, false,
+ menv[id].colour);
menv[id].set_ghost(ghost, false);
menv[id].uglything_init();
}