From b6484c07a27d0856140792f33397930f9e6e7689 Mon Sep 17 00:00:00 2001 From: dolorous Date: Tue, 7 Oct 2008 03:09:27 +0000 Subject: Fix flight type handling so that spectral things can at least always levitate again (since their class can), regardless of what actual type they are. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7169 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/abl-show.cc | 6 +++--- crawl-ref/source/enum.h | 6 ++++-- crawl-ref/source/ghost.cc | 4 ++-- crawl-ref/source/misc.cc | 17 +++++++++-------- crawl-ref/source/mon-util.cc | 27 ++++++++++++++++++--------- crawl-ref/source/player.cc | 2 +- 6 files changed, 37 insertions(+), 25 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index 2559e76713..bc0a29fb98 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -844,10 +844,10 @@ bool activate_ability() else if (you.species == SP_KENKU && you.experience_level >= 5 || player_mutation_level(MUT_BIG_WINGS)) { - if (you.flight_mode() == FL_FLY) - mpr("You're already flying!"); - else if (you.flight_mode() == FL_LEVITATE) + if (you.flight_mode() == FL_LEVITATE) mpr("You can only start flying from the ground."); + else if (you.flight_mode() == FL_FLY) + mpr("You're already flying!"); } else mpr("Sorry, you're not good enough to have a special ability."); diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index cdf74670c9..a3b4db2fc8 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -1410,11 +1410,13 @@ enum killer_type // monster_die(), thing_thrown KILL_DISMISSED // only on new game startup }; +// This should be in order from the worst flight status to the best. +// See mons_flies(). enum flight_type { FL_NONE = 0, - FL_FLY, - FL_LEVITATE + FL_LEVITATE, + FL_FLY }; enum level_area_type // you.level_type diff --git a/crawl-ref/source/ghost.cc b/crawl-ref/source/ghost.cc index 97bcca30a5..a2986add5c 100644 --- a/crawl-ref/source/ghost.cc +++ b/crawl-ref/source/ghost.cc @@ -198,8 +198,8 @@ void ghost_demon::init_random_demon() spellcaster = !one_chance_in(10); // Does demon fly? - fly = (one_chance_in(3)? FL_NONE : - one_chance_in(5)? FL_LEVITATE : FL_FLY); + fly = (one_chance_in(3) ? FL_NONE : + one_chance_in(5) ? FL_LEVITATE : FL_FLY); // hit dice: xl = 10 + roll_dice(2, 10); diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 609c107a39..c55e4573b2 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -1352,15 +1352,16 @@ static void climb_message(dungeon_feature_type stair, bool going_up, mpr("A mysterious force pulls you upwards."); else { - mprf("You %s downwards.", you.flight_mode() == FL_FLY? "fly" : - (player_is_airborne()? "float" : "slide")); + mprf("You %s downwards.", + you.flight_mode() == FL_FLY ? "fly" : + (player_is_airborne() ? "float" : "slide")); } } else { - mprf("You %s %swards.", you.flight_mode() == FL_FLY? "fly" : - (player_is_airborne()? "float" : "climb"), - going_up? "up": "down"); + mprf("You %s %swards.", you.flight_mode() == FL_FLY ? "fly" : + (player_is_airborne() ? "float" : "climb"), + going_up ? "up" : "down"); } } @@ -1593,10 +1594,10 @@ void up_stairs(dungeon_feature_type force_stair, const dungeon_feature_type stair_taken = stair_find; - if (you.flight_mode() == FL_FLY) - mpr("You fly upwards."); - else if (you.flight_mode() == FL_LEVITATE) + if (you.flight_mode() == FL_LEVITATE) mpr("You float upwards... And bob straight up to the ceiling!"); + else if (you.flight_mode() == FL_FLY) + mpr("You fly upwards."); else climb_message(stair_find, true, old_level_type); diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 19a23a236f..07f3f24b38 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -1263,12 +1263,12 @@ bool mons_skeleton(int mc) flight_type mons_class_flies(int mc) { - if (mons_class_flag(mc, M_FLIES)) - return (FL_FLY); - if (mons_class_flag(mc, M_LEVITATE)) return (FL_LEVITATE); + if (mons_class_flag(mc, M_FLIES)) + return (FL_FLY); + return (FL_NONE); } @@ -1280,13 +1280,22 @@ flight_type mons_flies(const monsters *mon) return (mon->ghost->fly); } - const int montype = mons_is_zombified(mon) ? mons_zombie_base(mon) - : mon->type; + flight_type ret = FL_NONE; + + if (mons_is_zombified(mon)) + ret = mons_class_flies(mon->base_monster); - const flight_type ret = mons_class_flies(montype); - return (ret ? ret - : (_scan_mon_inv_randarts(mon, RAP_LEVITATE) > 0) ? FL_LEVITATE - : FL_NONE); + // Set flight status this way so that monsters will always have the + // best flight status possible. This is necessary so that monsters + // with FL_NONE status when alive get FL_LEVITATE status as spectral + // things, and monsters with FL_FLY status when alive retain it as + // spectral things. + ret = std::max(mons_class_flies(mon->type), ret); + + if (ret == FL_NONE && _scan_mon_inv_randarts(mon, RAP_LEVITATE) > 0) + ret = FL_LEVITATE; + + return (ret); } bool mons_class_amphibious(int mc) diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index c0d0cf39e0..588e95280e 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -6369,7 +6369,7 @@ flight_type player::flight_mode() const if (attribute[ATTR_TRANSFORMATION] == TRAN_DRAGON || attribute[ATTR_TRANSFORMATION] == TRAN_BAT) { - return FL_FLY; + return (FL_FLY); } else if (is_levitating()) { -- cgit v1.2.3-54-g00ecf