diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-10-27 08:41:12 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-10-27 08:41:12 +0000 |
commit | f4395a55e78d890c8af05b57be215cb695a184c3 (patch) | |
tree | 24d106bf597ce4eac536a595c27bc01ae955ad69 | |
parent | e5b0adc995eba28cdaa448e345e0e58d4a8c61a8 (diff) | |
download | crawl-ref-f4395a55e78d890c8af05b57be215cb695a184c3.tar.gz crawl-ref-f4395a55e78d890c8af05b57be215cb695a184c3.zip |
Trunk->0.3 merge (2613): Levitation fixes.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.3@2615 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/abl-show.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/acr.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/clua.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/externs.h | 11 | ||||
-rw-r--r-- | crawl-ref/source/fight.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/food.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/it_use2.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/item_use.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/items.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/misc.cc | 16 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 7 | ||||
-rw-r--r-- | crawl-ref/source/monstuff.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/output.cc | 8 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 34 | ||||
-rw-r--r-- | crawl-ref/source/player.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/religion.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/spells1.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/spells4.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/terrain.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/traps.cc | 8 |
20 files changed, 71 insertions, 58 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index 0b2e1c8856..c3e11e6703 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -1955,7 +1955,7 @@ std::vector<talent> 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 c44123436b..6660f1b755 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -2924,7 +2924,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." ); } @@ -3007,7 +3007,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 e7b8e524d7..7e5eb40bc8 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -735,8 +735,8 @@ LUARET1(you_res_statdrain, number, player_sust_abil(false)) 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_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 e8b2933ec4..854de14dfa 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -154,7 +154,9 @@ 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; virtual bool paralysed() const = 0; virtual bool confused() const = 0; @@ -693,7 +695,6 @@ public: bool in_water() const; bool can_swim() const; - bool is_levitating() const; bool cannot_speak() const; bool invisible() const; bool can_see_invisible() const; @@ -776,7 +777,8 @@ public: int res_poison() const; int res_negative_energy() const; - flight_type flies() const; + bool is_levitating() const; + flight_type flight_mode() const; bool paralysed() const; bool confused() const; @@ -1044,7 +1046,8 @@ public: int res_poison() const; int res_negative_energy() const; - flight_type flies() const; + bool is_levitating() const; + flight_type flight_mode() const; bool invisible() const; bool can_see_invisible() const; bool visible_to(const actor *looker) const ; diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index d132ac4915..b5e54645da 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -1768,7 +1768,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; @@ -3168,7 +3168,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 0e76719387..61593ad88a 100644 --- a/crawl-ref/source/food.cc +++ b/crawl-ref/source/food.cc @@ -225,7 +225,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); @@ -732,7 +732,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 6b32144a26..6e61dcfd30 100644 --- a/crawl-ref/source/it_use2.cc +++ b/crawl-ref/source/it_use2.cc @@ -136,9 +136,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 8ac83cef48..94be68527c 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -3109,7 +3109,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 b88a822574..156e7e852d 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1028,7 +1028,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); @@ -1070,7 +1070,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; @@ -2804,7 +2804,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 6039265869..4e9c911c61 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -437,15 +437,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"); } } @@ -489,7 +489,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) @@ -594,7 +594,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."); @@ -724,7 +724,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; @@ -871,7 +871,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) diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 3b63cba0e9..c80e119850 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -3326,11 +3326,16 @@ 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)); } +bool monsters::is_levitating() const +{ + return (flight_mode() == FL_LEVITATE); +} + int monsters::mons_species() const { return ::mons_species(type); diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 5ae7f18f0c..b03e89f4e4 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -4484,8 +4484,7 @@ static void do_move_monster(monsters *monster, int xi, int yi) void mons_check_pool(monsters *mons, killer_type killer, int killnum) { // Levitating/flying monsters don't make contact with the terrain. - const flight_type lev = mons->flies(); - if (lev == FL_LEVITATE || (lev == FL_FLY && !mons->paralysed())) + if (mons->airborne()) return; int grid = grd(mons->pos()); diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index 22d3deb2a0..e48a9a8884 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -483,7 +483,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 )) @@ -975,7 +975,7 @@ std::vector<formatted_string> 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" @@ -1248,7 +1248,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" @@ -1425,7 +1425,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 7ee7221904..4e657821d0 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -170,7 +170,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. @@ -283,7 +283,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); @@ -316,7 +316,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()) )); } @@ -1552,7 +1552,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 && @@ -2050,7 +2050,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; @@ -2289,7 +2289,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 ) @@ -3117,7 +3117,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()) { @@ -3314,7 +3314,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]) @@ -3378,7 +3378,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); @@ -3663,9 +3663,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 ) @@ -4790,6 +4790,11 @@ actor::~actor() { } +bool actor::airborne() const +{ + return (is_levitating() || (flight_mode() == FL_FLY && !paralysed())); +} + ////////////////////////////////////////////////////////////////////////////// // player @@ -5030,7 +5035,7 @@ bool player::is_levitating() const bool player::in_water() const { - return (!player_is_levitating() && !beogh_water_walk() + return (!player_is_airborne() && !beogh_water_walk() && grid_is_water(grd[you.x_pos][you.y_pos])); } @@ -5493,7 +5498,7 @@ int player::res_negative_energy() const return (player_prot_life()); } -flight_type player::flies() const +flight_type player::flight_mode() const { if ( !is_levitating() ) return (FL_NONE); @@ -5506,7 +5511,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 98a3217740..691532df5f 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -56,7 +56,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 1f28de1c22..cbe613feec 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -826,7 +826,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; @@ -1590,7 +1590,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 5e3ea61e92..2901aa805b 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -1006,7 +1006,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 a90a687893..c76a02a8a1 100644 --- a/crawl-ref/source/spells4.cc +++ b/crawl-ref/source/spells4.cc @@ -1268,7 +1268,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 4a9a930174..a8c6fc2981 100644 --- a/crawl-ref/source/terrain.cc +++ b/crawl-ref/source/terrain.cc @@ -427,7 +427,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 a0d2e68b48..2e54eb13b3 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<const monsters*>(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())); } } } |