From e38d19ed671795b6cb2e177a7f730272ce4f35b0 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Sat, 27 Oct 2007 07:44:37 +0000 Subject: [1821098] Fixed bat transform not conferring flight. Fixed player_is_levitating and renamed it to player_is_airborne to describe the function better. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2613 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/abl-show.cc | 2 +- crawl-ref/source/acr.cc | 6 +++--- crawl-ref/source/clua.cc | 4 ++-- crawl-ref/source/externs.h | 6 +++--- crawl-ref/source/fight.cc | 4 ++-- crawl-ref/source/food.cc | 4 ++-- crawl-ref/source/it_use2.cc | 4 ++-- crawl-ref/source/item_use.cc | 2 +- crawl-ref/source/items.cc | 6 +++--- crawl-ref/source/misc.cc | 22 +++++++++++----------- crawl-ref/source/mon-util.cc | 2 +- crawl-ref/source/output.cc | 8 ++++---- crawl-ref/source/player.cc | 29 +++++++++++++++-------------- crawl-ref/source/player.h | 2 +- crawl-ref/source/religion.cc | 4 ++-- crawl-ref/source/spells1.cc | 2 +- crawl-ref/source/spells4.cc | 2 +- crawl-ref/source/terrain.cc | 2 +- crawl-ref/source/traps.cc | 8 ++++---- 19 files changed, 60 insertions(+), 59 deletions(-) diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index b181a12568..20bb15d915 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -1975,7 +1975,7 @@ std::vector your_talents( bool check_confused ) add_talent(talents, ABIL_TRAN_BAT, check_confused ); } - if (!you.duration[DUR_CONTROLLED_FLIGHT] && !player_is_levitating()) + if (!you.duration[DUR_CONTROLLED_FLIGHT] && !player_is_airborne()) { // kenku can fly, but only from the ground // (until level 15, when it becomes permanent until revoked) diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index d53f45446a..9431fe3675 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -1523,7 +1523,7 @@ static void go_downstairs() if (stairs_check_beheld()) return; - if (shaft && you.flies() == FL_LEVITATE) + if (shaft && you.flight_mode() == FL_LEVITATE) { mpr("You can't fall through a shaft while levitating."); return; @@ -3310,7 +3310,7 @@ static void open_door(int move_x, int move_y, bool check_confused) } else { - mpr( player_is_levitating() ? "You reach down and open the door." + mpr( player_is_airborne() ? "You reach down and open the door." : "You open the door." ); } @@ -3393,7 +3393,7 @@ static void close_door(int door_x, int door_y) } else { - mpr( player_is_levitating() ? "You reach down and close the door." + mpr( player_is_airborne() ? "You reach down and close the door." : "You close the door." ); } diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index 8943fc3bb3..4539a81da2 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -735,8 +735,8 @@ LUARET1(you_res_mutation, number, wearing_amulet(AMU_RESIST_MUTATION, false)) LUARET1(you_res_slowing, number, wearing_amulet(AMU_RESIST_SLOW, false)) LUARET1(you_gourmand, boolean, wearing_amulet(AMU_THE_GOURMAND, false)) LUARET1(you_saprovorous, number, you.mutation[MUT_SAPROVOROUS]) -LUARET1(you_levitating, boolean, you.flies() == FL_LEVITATE) -LUARET1(you_flying, boolean, you.flies() == FL_FLY) +LUARET1(you_levitating, boolean, you.flight_mode() == FL_LEVITATE) +LUARET1(you_flying, boolean, you.flight_mode() == FL_FLY) LUARET1(you_transform, string, transform_name()) LUARET1(you_where, string, level_id::current().describe().c_str()) LUARET1(you_branch, string, level_id::current().describe(false, false).c_str()) diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index e6097dbb07..856cfc7ea5 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -165,7 +165,7 @@ public: virtual int res_poison() const = 0; virtual int res_negative_energy() const = 0; - virtual flight_type flies() const = 0; + virtual flight_type flight_mode() const = 0; virtual bool is_levitating() const = 0; virtual bool airborne() const; @@ -818,7 +818,7 @@ public: bool omnivorous() const; - flight_type flies() const; + flight_type flight_mode() const; bool paralysed() const; bool confused() const; @@ -1103,7 +1103,7 @@ public: int res_poison() const; int res_negative_energy() const; - flight_type flies() const; + flight_type flight_mode() const; bool is_levitating() const; bool invisible() const; bool can_see_invisible() const; diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 6eef4bd4b3..12f4a370b1 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -1814,7 +1814,7 @@ bool melee_attack::apply_damage_brand() break; case SPWPN_ELECTROCUTION: - if (defender->flies()) + if (defender->airborne()) break; else if (defender->res_elec() > 0) break; @@ -3228,7 +3228,7 @@ void melee_attack::mons_apply_attack_flavour(const mon_attack_def &attk) defender->res_elec(), atk->hit_dice + random2( atk->hit_dice / 2 )); - if (defender->flies()) + if (defender->airborne()) special_damage = special_damage * 2 / 3; if (needs_message && special_damage) diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc index 160a9c7448..58f887e91d 100644 --- a/crawl-ref/source/food.cc +++ b/crawl-ref/source/food.cc @@ -226,7 +226,7 @@ bool butchery(void) return (false); } - if (you.flies() == FL_LEVITATE) + if (you.flight_mode() == FL_LEVITATE) { mpr("You can't reach the floor from up here."); return (false); @@ -729,7 +729,7 @@ void eat_floor_item(int item_link) bool eat_from_floor(void) { - if (you.flies() == FL_LEVITATE) + if (you.flight_mode() == FL_LEVITATE) return (false); bool need_more = false; diff --git a/crawl-ref/source/it_use2.cc b/crawl-ref/source/it_use2.cc index a43fac7311..568a6c24a4 100644 --- a/crawl-ref/source/it_use2.cc +++ b/crawl-ref/source/it_use2.cc @@ -137,9 +137,9 @@ bool potion_effect( potion_type pot_eff, int pow ) case POT_LEVITATION: mprf("You feel %s buoyant.", - (!player_is_levitating()) ? "very" : "more"); + (!player_is_airborne()) ? "very" : "more"); - if (!player_is_levitating()) + if (!player_is_airborne()) mpr("You gently float upwards from the floor."); you.duration[DUR_LEVITATION] += 25 + random2(pow); diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 906d824b9b..d614bc768c 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -3168,7 +3168,7 @@ bool drink_fountain() if ( feat != DNGN_BLUE_FOUNTAIN && feat != DNGN_SPARKLING_FOUNTAIN ) return false; - if (you.flies() == FL_LEVITATE) + if (you.flight_mode() == FL_LEVITATE) { mpr("You're floating high above the fountain."); return false; diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index d910e5ecc3..c0dc3cf054 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1128,7 +1128,7 @@ bool pickup_single_item(int link, int qty) return (false); } - if (you.flies() == FL_LEVITATE) + if (you.flight_mode() == FL_LEVITATE) { mpr("You can't reach the floor from up here."); return (false); @@ -1170,7 +1170,7 @@ void pickup() return; } - if (you.flies() == FL_LEVITATE) + if (you.flight_mode() == FL_LEVITATE) { mpr("You can't reach the floor from up here."); return; @@ -2951,7 +2951,7 @@ bool can_autopickup() && you.duration[DUR_TRANSFORMATION] > 0) return (false); - if (you.flies() == FL_LEVITATE) + if (you.flight_mode() == FL_LEVITATE) return (false); if ( Options.safe_autopickup && !i_feel_safe() ) diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 385946cd44..3328530bd4 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -444,15 +444,15 @@ static void climb_message(dungeon_feature_type stair, bool going_up, mpr("A mysterious force pulls you upwards."); else { - mprf("You %s downwards.", you.flies()? "fly" : - (player_is_levitating()? "float" : + mprf("You %s downwards.", you.flight_mode() == FL_FLY? "fly" : + (player_is_airborne()? "float" : "slide")); } } else { - mprf("You %s %swards.", you.flies()? "fly" : - (player_is_levitating()? "float" : "climb"), + mprf("You %s %swards.", you.flight_mode() == FL_FLY? "fly" : + (player_is_airborne()? "float" : "climb"), going_up? "up": "down"); } } @@ -571,7 +571,7 @@ void up_stairs(dungeon_feature_type force_stair, // Since the overloaded message set turn_is_over, I'm assuming that // the overloaded character makes an attempt... so we're doing this // check before that one. -- bwr - if (!player_is_levitating() + if (!player_is_airborne() && you.duration[DUR_CONF] && (stair_find >= DNGN_STONE_STAIRS_UP_I && stair_find <= DNGN_ROCK_STAIRS_UP) @@ -675,7 +675,7 @@ void up_stairs(dungeon_feature_type force_stair, const dungeon_feature_type stair_taken = stair_find; - if (player_is_levitating()) + if (player_is_airborne()) { if (you.duration[DUR_CONTROLLED_FLIGHT]) mpr("You fly upwards."); @@ -832,7 +832,7 @@ void down_stairs( int old_level, dungeon_feature_type force_stair, return; } - if (!force_stair && you.flies() == FL_LEVITATE) + if (!force_stair && you.flight_mode() == FL_LEVITATE) { mpr("You're floating high up above the floor!"); return; @@ -849,7 +849,7 @@ void down_stairs( int old_level, dungeon_feature_type force_stair, return; } - if (you.flies() == FL_LEVITATE && !force_stair) + if (you.flight_mode() == FL_LEVITATE && !force_stair) { if (known_trap) mpr("You can't fall through a shaft while levitating."); @@ -873,7 +873,7 @@ void down_stairs( int old_level, dungeon_feature_type force_stair, shaft_level = absdungeon_depth(shaft_dest.branch, shaft_dest.depth); - if (you.flies() != FL_FLY || force_stair) + if (you.flight_mode() != FL_FLY || force_stair) mpr("You fall through a shaft!"); } @@ -1033,7 +1033,7 @@ void down_stairs( int old_level, dungeon_feature_type force_stair, mprf("Welcome back to %s!", branches[you.where_are_you].longname); - if (!player_is_levitating() + if (!player_is_airborne() && you.duration[DUR_CONF] && (stair_find >= DNGN_STONE_STAIRS_DOWN_I && stair_find <= DNGN_ROCK_STAIRS_DOWN) @@ -1091,7 +1091,7 @@ void down_stairs( int old_level, dungeon_feature_type force_stair, default: if (shaft) { - if (you.flies() == FL_FLY && !force_stair) + if (you.flight_mode() == FL_FLY && !force_stair) mpr("You dive down through the shaft."); } else diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index aafec13798..89d3528dee 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -3541,7 +3541,7 @@ int monsters::res_negative_energy() const return (mons_res_negative_energy(this)); } -flight_type monsters::flies() const +flight_type monsters::flight_mode() const { return (mons_flies(this)); } diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index b5b14fe1b2..dfda9e4110 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -474,7 +474,7 @@ void print_stats(void) cprintf( "Ins " ); } - if (player_is_levitating()) + if (player_is_airborne()) { bool perm = (you.species == SP_KENKU && you.experience_level >= 15) || (player_equip_ego_type( EQ_BOOTS, SPARM_LEVITATION )) @@ -949,7 +949,7 @@ std::vector get_full_detail(bool calc_unid, long sc) cols.add_formatted(2, buf, false); const int rctel = player_control_teleport(calc_unid); - const int rlevi = player_is_levitating(); + const int rlevi = player_is_airborne(); const int rcfli = wearing_amulet(AMU_CONTROLLED_FLIGHT, calc_unid); snprintf(buf, sizeof buf, "%sCtrl.Telep.: %s\n" @@ -1200,7 +1200,7 @@ void print_overview_screen() cols.add_formatted(1, buf, false); const int rctel = player_control_teleport(calc_unid); - const int rlevi = player_is_levitating(); + const int rlevi = player_is_airborne(); const int rcfli = wearing_amulet(AMU_CONTROLLED_FLIGHT, calc_unid); snprintf(buf, sizeof buf, "%sCtrl.Telep.: %s\n" @@ -1377,7 +1377,7 @@ std::string status_mut_abilities() if (you.duration[DUR_BERSERKER]) text += "berserking, "; - if (player_is_levitating()) + if (player_is_airborne()) text += "levitating, "; if (you.duration[DUR_BARGAIN]) diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index f067794e77..a56f8e51a5 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -173,7 +173,7 @@ bool move_player_to_grid( int x, int y, bool stepped, bool allow_shift, } // only consider terrain if player is not levitating - if (!player_is_levitating()) + if (!player_is_airborne()) { // XXX: at some point we're going to need to fix the swimming // code to handle burden states. @@ -286,7 +286,7 @@ bool move_player_to_grid( int x, int y, bool stepped, bool allow_shift, if (!stepped) trap_known = false; - if (!player_is_levitating() + if (!player_is_airborne() || trap_category( env.trap[id].type ) != DNGN_TRAP_MECHANICAL) { handle_traps(env.trap[id].type, id, trap_known); @@ -319,7 +319,7 @@ bool player_can_swim() bool is_grid_dangerous(int grid) { - return (!player_is_levitating() + return (!player_is_airborne() && (grid == DNGN_LAVA || (grid == DNGN_DEEP_WATER && !player_likes_water()) )); } @@ -1571,7 +1571,7 @@ int player_movement_speed(void) // Swiftness is an Air spell, it doesn't work in water, but // flying players will move faster. if (you.duration[DUR_SWIFTNESS] > 0 && !player_in_water()) - mv -= (you.flies() == FL_FLY ? 4 : 2); + mv -= (you.flight_mode() == FL_FLY ? 4 : 2); /* Mutations: -2, -3, -4, unless innate and shapechanged */ if (you.mutation[MUT_FAST] > 0 && @@ -2069,7 +2069,7 @@ int player_evasion() case SP_KENKU: // Flying kenku get an evasion bonus. - if (you.flies() == FL_FLY) + if (you.flight_mode() == FL_FLY) { const int ev_bonus = std::min(9, std::max(1, ev / 5)); ev += ev_bonus; @@ -2429,7 +2429,7 @@ int player_sust_abil(bool calc_unid) int carrying_capacity( burden_state_type bs ) { - int cap = 3500+(you.strength * 100)+(player_is_levitating() ? 1000 : 0); + int cap = 3500+(you.strength * 100)+(player_is_airborne() ? 1000 : 0); if ( bs == BS_UNENCUMBERED ) return (cap * 5) / 6; else if ( bs == BS_ENCUMBERED ) @@ -3271,7 +3271,7 @@ int check_stealth(void) stealth += scan_randarts( RAP_STEALTH ); - if (player_is_levitating()) + if (player_is_airborne()) stealth += 10; else if (player_in_water()) { @@ -3476,7 +3476,7 @@ void display_char_status() if (you.duration[DUR_BERSERKER]) mpr( "You are possessed by a berserker rage." ); - if (player_is_levitating()) + if (player_is_airborne()) mpr( "You are hovering above the floor." ); if (you.attribute[ATTR_HELD]) @@ -3540,7 +3540,7 @@ void display_char_status() const bool water = player_in_water(); const bool swim = player_is_swimming(); - const bool lev = player_is_levitating(); + const bool lev = player_is_airborne(); const bool fly = (lev && you.duration[DUR_CONTROLLED_FLIGHT]); const bool swift = (you.duration[DUR_SWIFTNESS] > 0); @@ -3825,9 +3825,9 @@ bool wearing_amulet(char amulet, bool calc_unid) return false; } // end wearing_amulet() -bool player_is_levitating(void) +bool player_is_airborne(void) { - return you.is_levitating(); + return you.airborne(); } bool player_has_spell( int spell ) @@ -5077,7 +5077,7 @@ level_id actor::shaft_dest() const bool actor::airborne() const { - return (is_levitating() || (flies() == FL_FLY && !paralysed())); + return (is_levitating() || (flight_mode() == FL_FLY && !paralysed())); } ////////////////////////////////////////////////////////////////////////////// @@ -5886,7 +5886,7 @@ bool player::omnivorous() const return (species == SP_TROLL || species == SP_OGRE); } -flight_type player::flies() const +flight_type player::flight_mode() const { if (attribute[ATTR_TRANSFORMATION] == TRAN_DRAGON || attribute[ATTR_TRANSFORMATION] == TRAN_BAT) @@ -5904,7 +5904,8 @@ flight_type player::flies() const bool player::light_flight() const { // Only Kenku get perks for flying light. - return (species == SP_KENKU && flies() == FL_FLY && travelling_light()); + return (species == SP_KENKU + && flight_mode() == FL_FLY && travelling_light()); } bool player::travelling_light() const diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index 055649ff82..3e3b8c172f 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -59,7 +59,7 @@ bool player_light_armour(bool with_skill = false); * *********************************************************************** */ bool player_in_water(void); bool player_is_swimming(void); -bool player_is_levitating(void); +bool player_is_airborne(void); /* *********************************************************************** * called from: ability - chardump - fight - religion - spell - spells - diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 081ac797b6..f3913e32cd 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -977,7 +977,7 @@ void pray() const god_type altar_god = grid_altar_god(grd[you.x_pos][you.y_pos]); if (altar_god != GOD_NO_GOD) { - if (you.flies() == FL_LEVITATE) + if (you.flight_mode() == FL_LEVITATE) { mpr("You are floating high above the altar."); return; @@ -1779,7 +1779,7 @@ bool beogh_water_walk() static bool need_water_walking() { return - !player_is_levitating() && you.species != SP_MERFOLK && + !player_is_airborne() && you.species != SP_MERFOLK && grd[you.x_pos][you.y_pos] == DNGN_DEEP_WATER; } diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index 6483f7d01a..f9c7fe8ed5 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -1049,7 +1049,7 @@ void cast_fly(int power) { int dur_change = 25 + random2(power) + random2(power); - const bool was_levitating = player_is_levitating(); + const bool was_levitating = player_is_airborne(); if (you.duration[DUR_LEVITATION] + dur_change > 100) you.duration[DUR_LEVITATION] = 100; diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc index 1742ba2589..7b7c053c71 100644 --- a/crawl-ref/source/spells4.cc +++ b/crawl-ref/source/spells4.cc @@ -1281,7 +1281,7 @@ static int discharge_monsters( int x, int y, int pow, int garbage ) mpr( "You are struck by lightning." ); damage = 3 + random2( 5 + pow / 10 ); damage = check_your_resists( damage, BEAM_ELECTRICITY ); - if ( player_is_levitating() ) + if ( player_is_airborne() ) damage /= 2; ouch( damage, 0, KILLED_BY_WILD_MAGIC ); } diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc index f28062d5e2..c84ec17033 100644 --- a/crawl-ref/source/terrain.cc +++ b/crawl-ref/source/terrain.cc @@ -425,7 +425,7 @@ void dungeon_terrain_changed(const coord_def &pos, { if (!grid_is_solid(grd(pos))) { - if (!you.flies()) + if (!you.airborne()) move_player_to_grid(pos.x, pos.y, false, true, false); } else diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc index aa513293b1..306c898e04 100644 --- a/crawl-ref/source/traps.cc +++ b/crawl-ref/source/traps.cc @@ -110,7 +110,7 @@ void monster_caught_in_net(monsters *mon, bolt &pbolt) } const monsters* mons = static_cast(mon); - bool mon_flies = mons->flies() == FL_FLY; + bool mon_flies = mons->flight_mode() == FL_FLY; if (mon_flies && (!mons_is_confused(mons) || one_chance_in(3))) { simple_monster_message(mon, " darts out from under the net!"); @@ -149,7 +149,7 @@ void player_caught_in_net() return; } - if (you.flies() == FL_FLY && (!you.confused() || one_chance_in(3))) + if (you.flight_mode() == FL_FLY && (!you.confused() || one_chance_in(3))) { mpr("You dart out from under the net!"); return; @@ -163,10 +163,10 @@ void player_caught_in_net() // I guess levitation works differently, keeping both you // and the net hovering above the floor - if (you.flies() == FL_FLY) + if (you.flight_mode() == FL_FLY) { mpr("You fall like a stone!"); - fall_into_a_pool(you.x_pos, you.y_pos, false, grd[you.x_pos][you.y_pos]); + fall_into_a_pool(you.x_pos, you.y_pos, false, grd(you.pos())); } } } -- cgit v1.2.3-54-g00ecf