diff options
author | David Lawrence Ramsey <dolorous@users.sourceforge.net> | 2009-10-06 18:31:13 -0500 |
---|---|---|
committer | David Lawrence Ramsey <dolorous@users.sourceforge.net> | 2009-10-06 18:31:13 -0500 |
commit | f408bf9c354f827c64e1416279b338a921545ff0 (patch) | |
tree | e7c9b77b1616c5efbbd9de3c9f7761b86c58395b /crawl-ref/source/ghost.cc | |
parent | 23ff814fd3727442f17b093612e2bd802e972c2e (diff) | |
download | crawl-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/ghost.cc')
-rw-r--r-- | crawl-ref/source/ghost.cc | 25 |
1 files changed, 19 insertions, 6 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. |