From ebe5260773cb5fbb3a47f2d054c0c8c2559d5a2b Mon Sep 17 00:00:00 2001 From: Raphael Langella Date: Sat, 12 Feb 2011 00:34:13 +0100 Subject: [PATCH] Apply the new ground_level method. Also fix the following bugs: Rain message when clinging. Clinging monsters affected by Leda's. In water tiles when clinging over it (both player and monster). --- crawl-ref/source/abl-show.cc | 3 +-- crawl-ref/source/actor.cc | 3 +-- crawl-ref/source/cloud.cc | 2 +- crawl-ref/source/dgn-shoals.cc | 5 ++--- crawl-ref/source/effects.cc | 2 +- crawl-ref/source/it_use2.cc | 2 +- crawl-ref/source/mon-act.cc | 5 ++--- crawl-ref/source/mon-info.cc | 2 +- crawl-ref/source/monster.cc | 9 +++++---- crawl-ref/source/player-act.cc | 2 +- crawl-ref/source/player.cc | 9 +++++---- crawl-ref/source/religion.cc | 2 +- crawl-ref/source/spl-cast.cc | 9 ++++----- crawl-ref/source/spl-miscast.cc | 5 ++--- crawl-ref/source/status.cc | 3 +-- crawl-ref/source/tilepick-p.cc | 2 +- crawl-ref/source/tilepick.cc | 2 +- crawl-ref/source/traps.cc | 5 ++--- 18 files changed, 33 insertions(+), 39 deletions(-) diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index ff4b2a048..1d9ea87b0 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -1618,8 +1618,7 @@ static bool _activate_talent(const talent& tal) } if ((tal.which == ABIL_EVOKE_LEVITATE || tal.which == ABIL_TRAN_BAT) - && liquefied(you.pos()) - && !you.airborne() && !you.is_wall_clinging()) + && liquefied(you.pos()) && !you.ground_level()) { mpr("You can't escape from the ground with such puny magic!", MSGCH_WARN); crawl_state.zero_turns_taken(); diff --git a/crawl-ref/source/actor.cc b/crawl-ref/source/actor.cc index 0036ef387..38eda7166 100644 --- a/crawl-ref/source/actor.cc +++ b/crawl-ref/source/actor.cc @@ -28,8 +28,7 @@ bool actor::has_equipped(equipment_type eq, int sub_type) const bool actor::will_trigger_shaft() const { - return (!(airborne() || is_wall_clinging()) - && total_weight() > 0 && is_valid_shaft_level() + return (ground_level() && total_weight() > 0 && is_valid_shaft_level() // let's pretend that they always make their saving roll && !(atype() == ACT_MONSTER && mons_is_elven_twin(static_cast(this)))); diff --git a/crawl-ref/source/cloud.cc b/crawl-ref/source/cloud.cc index a1015096d..cce42a90e 100644 --- a/crawl-ref/source/cloud.cc +++ b/crawl-ref/source/cloud.cc @@ -337,7 +337,7 @@ static void _maybe_leave_water(const cloud_struct& c) if (grd(c.pos) != feat) { - if (you.pos() == c.pos && !you.airborne()) + if (you.pos() == c.pos && you.ground_level()) mpr("The rain has left you waist-deep in water!"); dungeon_terrain_changed(c.pos, feat); } diff --git a/crawl-ref/source/dgn-shoals.cc b/crawl-ref/source/dgn-shoals.cc index 8782cfb38..59fe46bd5 100644 --- a/crawl-ref/source/dgn-shoals.cc +++ b/crawl-ref/source/dgn-shoals.cc @@ -810,8 +810,7 @@ static bool _shoals_tide_sweep_items_clear(coord_def c) static bool _shoals_tide_sweep_actors_clear(coord_def c) { actor *victim = actor_at(c); - if (!victim || victim->airborne() || victim->is_wall_clinging() - || victim->swimming()) + if (!victim || !victim->ground_level() || victim->swimming()) return true; if (victim->atype() == ACT_MONSTER) @@ -920,7 +919,7 @@ static void _shoals_apply_tide_at(coord_def c, int tide, bool incremental_tide) if (incremental_tide && final_feature == DNGN_DEEP_WATER && c == you.pos() - && (you.airborne() || you.is_wall_clinging()) + && !you.ground_level() && !you.permanent_levitation() && !you.permanent_flight()) { diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index bd07d2205..c06e3b418 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -431,7 +431,7 @@ static bool _conduct_electricity_affects_actor(const bolt& beam, const actor* victim) { return (victim->alive() && victim->res_elec() <= 0 - && !(victim->airborne() || victim->is_wall_clinging())); + && victim->ground_level()); } static bool _conduct_electricity_damage(bolt &beam, actor* victim, diff --git a/crawl-ref/source/it_use2.cc b/crawl-ref/source/it_use2.cc index 06c53570c..f38e226aa 100644 --- a/crawl-ref/source/it_use2.cc +++ b/crawl-ref/source/it_use2.cc @@ -222,7 +222,7 @@ bool potion_effect(potion_type pot_eff, int pow, bool drank_it, bool was_known) break; case POT_LEVITATION: - if (liquefied(you.pos()) && !you.airborne() && !you.is_wall_clinging()) + if (liquefied(you.pos()) && you.ground_level()) { mprf(MSGCH_WARN, "This potion isn't strong enough to pull you from the ground!"); break; diff --git a/crawl-ref/source/mon-act.cc b/crawl-ref/source/mon-act.cc index 65c6bf6b3..cff1fa108 100644 --- a/crawl-ref/source/mon-act.cc +++ b/crawl-ref/source/mon-act.cc @@ -222,8 +222,7 @@ static void _swim_or_move_energy(monster* mon) // FIXME: Replace check with mons_is_swimming()? mon->lose_energy((feat >= DNGN_LAVA && feat <= DNGN_SHALLOW_WATER - && !(mon->airborne() || mon->is_wall_clinging())) ? EUT_SWIM - : EUT_MOVE); + && mon->ground_level()) ? EUT_SWIM : EUT_MOVE); } // Check up to eight grids in the given direction for whether there's a @@ -1883,7 +1882,7 @@ void handle_monster_move(monster* mons) // This seems to need to go here to actually get monsters to slow down. // XXX: Replace with a new ENCH_LIQUEFIED_GROUND or something. - if (liquefied(mons->pos()) && !mons->airborne() && !mons->is_insubstantial()) + if (liquefied(mons->pos()) && mons->ground_level() && !mons->is_insubstantial()) { mon_enchant me = mon_enchant(ENCH_SLOW, 0, KC_OTHER, 20); if (mons->has_ench(ENCH_SLOW)) diff --git a/crawl-ref/source/mon-info.cc b/crawl-ref/source/mon-info.cc index 6df7f8ffb..91081057e 100644 --- a/crawl-ref/source/mon-info.cc +++ b/crawl-ref/source/mon-info.cc @@ -370,7 +370,7 @@ monster_info::monster_info(const monster* m, int milev) mb |= ULL1 << MB_STABBABLE; if (mons_looks_distracted(m)) mb |= ULL1 << MB_DISTRACTED; - if (liquefied(m->pos()) && !m->airborne() && !m->is_insubstantial()) + if (liquefied(m->pos()) && m->ground_level() && !m->is_insubstantial()) mb |= ULL1 << MB_SLOWED; if (m->is_wall_clinging()) mb |= ULL1 << MB_CLINGING; diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc index 9b9e4449a..4b5b12d0a 100644 --- a/crawl-ref/source/monster.cc +++ b/crawl-ref/source/monster.cc @@ -4319,7 +4319,7 @@ void monster::remove_enchantment_effect(const mon_enchant &me, bool quiet) break; case ENCH_SLOW: - if (!quiet && !(liquefied(pos()) && !airborne() && !is_insubstantial())) + if (!quiet && !(liquefied(pos()) && ground_level() && !is_insubstantial())) simple_monster_message(this, " is no longer moving slowly."); calc_speed(); break; @@ -5166,7 +5166,7 @@ void monster::apply_enchantment(const mon_enchant &me) // Assumption: monster::res_fire has already been checked. case ENCH_STICKY_FLAME: { - if (feat_is_watery(grd(pos())) && !(airborne() || is_wall_clinging())) + if (feat_is_watery(grd(pos())) && ground_level()) { if (mons_near(this) && visible_to(&you)) { @@ -5662,7 +5662,8 @@ void monster::calc_speed() { speed = mons_real_base_speed(type); - bool is_liquefied = (liquefied(pos()) && !airborne() && !is_insubstantial()); + bool is_liquefied = (liquefied(pos()) && ground_level() + && !is_insubstantial()); // Going berserk on liquid ground doesn't speed you up any. if (!is_liquefied && (has_ench(ENCH_BERSERK) || has_ench(ENCH_INSANE))) @@ -6055,7 +6056,7 @@ bool monster::do_shaft() return (false); } - if (airborne() || is_wall_clinging() || total_weight() == 0) + if (!ground_level() || total_weight() == 0) { if (mons_near(this)) { diff --git a/crawl-ref/source/player-act.cc b/crawl-ref/source/player-act.cc index cd2fedf7b..44cd6a08f 100644 --- a/crawl-ref/source/player-act.cc +++ b/crawl-ref/source/player-act.cc @@ -444,7 +444,7 @@ bool player::fumbles_attack(bool verbose) bool did_fumble = false; // Fumbling in shallow water. - if (floundering() || (liquefied(pos()) && !airborne() && !clinging)) + if (floundering() || liquefied(pos()) && ground_level()) { if (x_chance_in_y(4, dex()) || one_chance_in(5)) { diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index b832c3a28..49b6028d3 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -294,7 +294,7 @@ void moveto_location_effects(dungeon_feature_type old_feat, return; } - if (!you.airborne() && !you.can_cling_to(you.pos())) + if (you.ground_level()) { if (you.species == SP_MERFOLK) { @@ -384,6 +384,7 @@ void move_player_to_grid(const coord_def& p, bool stepped, bool allow_shift) if (!you.running) check_for_interesting_features(); + you.check_clinging(); moveto_location_effects(old_grid, stepped, allow_shift, old_pos); } @@ -1929,7 +1930,7 @@ int player_movement_speed(bool ignore_burden) mv = 6; // moving on liquefied ground takes longer - if (liquefied(you.pos()) && !you.airborne() && !you.is_wall_clinging()) + if (liquefied(you.pos()) && you.ground_level()) mv += 3; // armour @@ -5500,7 +5501,7 @@ void player::clear_clinging() bool player::in_water() const { - return (!airborne() && !beogh_water_walk() && !is_wall_clinging() + return (ground_level() && !beogh_water_walk() && feat_is_water(grd(pos()))); } @@ -6899,7 +6900,7 @@ bool player::do_shaft() handle_items_on_shaft(pos(), false); - if (airborne() || is_wall_clinging() || total_weight() == 0) + if (!ground_level() || total_weight() == 0) return (true); force_stair = DNGN_TRAP_NATURAL; diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 6691ec71c..46da8fa68 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -970,7 +970,7 @@ void dec_penance(int val) static bool _need_water_walking() { - return (!you.airborne() && you.species != SP_MERFOLK + return (you.ground_level() && you.species != SP_MERFOLK && grd(you.pos()) == DNGN_DEEP_WATER); } diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 8cc8d0951..92f4af506 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -1481,10 +1481,9 @@ static spret_type _do_cast(spell_type spell, int powc, break; case SPELL_LEDAS_LIQUEFACTION: - if (you.airborne() || you.is_wall_clinging() - || !feat_has_solid_floor(grd(you.pos()))) + if (!you.ground_level() || !feat_has_solid_floor(grd(you.pos()))) { - if (you.airborne() || you.is_wall_clinging()) + if (!you.ground_level()) mprf("You can't cast this spell without touching the ground."); else mprf("You need to be on clear, solid ground to cast this spell."); @@ -1836,7 +1835,7 @@ static spret_type _do_cast(spell_type spell, int powc, break; case SPELL_LEVITATION: - if (liquefied(you.pos()) && !you.airborne() && !you.is_wall_clinging()) + if (liquefied(you.pos()) && you.ground_level()) { mprf(MSGCH_WARN, "Such puny magic can't pull you from the ground!"); return (SPRET_ABORT); @@ -1847,7 +1846,7 @@ static spret_type _do_cast(spell_type spell, int powc, break; case SPELL_FLY: - if (liquefied(you.pos()) && !you.airborne() && !you.is_wall_clinging()) + if (liquefied(you.pos()) && you.ground_level()) { mprf(MSGCH_WARN, "Such puny magic can't pull you from the ground!"); return (SPRET_ABORT); diff --git a/crawl-ref/source/spl-miscast.cc b/crawl-ref/source/spl-miscast.cc index 0249dc1ae..1894ceb96 100644 --- a/crawl-ref/source/spl-miscast.cc +++ b/crawl-ref/source/spl-miscast.cc @@ -959,7 +959,7 @@ void MiscastEffect::_enchantment(int severity) { case 0: if (target->atype() == ACT_PLAYER && !liquefied(you.pos()) - && !you.airborne() && !you.is_wall_clinging()) + && you.ground_level()) { you.attribute[ATTR_LEV_UNCANCELLABLE] = 1; levitate_player(20); @@ -2281,8 +2281,7 @@ void MiscastEffect::_ice(int severity) static bool _on_floor(actor* target) { - return (!(target->airborne() || target->is_wall_clinging()) - && grd(target->pos()) == DNGN_FLOOR); + return (target->ground_level() && grd(target->pos()) == DNGN_FLOOR); } void MiscastEffect::_earth(int severity) diff --git a/crawl-ref/source/status.cc b/crawl-ref/source/status.cc index 66d6ef9a6..249dd3f1b 100644 --- a/crawl-ref/source/status.cc +++ b/crawl-ref/source/status.cc @@ -601,8 +601,7 @@ static void _describe_speed(status_info* inf) inf->long_text = "Your actions are hasted."; _mark_expiring(inf, dur_expiring(DUR_HASTE)); } - if (liquefied(you.pos(), true) && !you.airborne() - && !you.is_wall_clinging()) + if (liquefied(you.pos(), true) && you.ground_level()) { inf->light_colour = BROWN; inf->light_text = "SlowM"; diff --git a/crawl-ref/source/tilepick-p.cc b/crawl-ref/source/tilepick-p.cc index 01b875449..bb00eeff8 100644 --- a/crawl-ref/source/tilepick-p.cc +++ b/crawl-ref/source/tilepick-p.cc @@ -400,7 +400,7 @@ tileidx_t tileidx_player() case TRAN_NONE: break; } - if (you.airborne()) + if (!you.ground_level()) ch |= TILE_FLAG_FLYING; if (you.attribute[ATTR_HELD]) diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc index e7b14a907..a26e83390 100644 --- a/crawl-ref/source/tilepick.cc +++ b/crawl-ref/source/tilepick.cc @@ -2450,7 +2450,7 @@ tileidx_t tileidx_monster(const monster* mons) { tileidx_t ch = _tileidx_monster_no_props(mons); - if (mons_flies(mons) && !_tentacle_tile_not_levitating(ch)) + if (!mons->ground_level() && !_tentacle_tile_not_levitating(ch)) ch |= TILE_FLAG_FLYING; if (mons->has_ench(ENCH_HELD)) ch |= TILE_FLAG_NET; diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc index d53a40253..7396f2c69 100644 --- a/crawl-ref/source/traps.cc +++ b/crawl-ref/source/traps.cc @@ -458,7 +458,7 @@ void trap_def::trigger(actor& triggerer, bool flat_footed) || trig_knows && !mons_is_fleeing(m) && !m->pacified()) { // No message for flying monsters to avoid message spam. - if (you_know && !(triggerer.airborne() || triggerer.is_wall_clinging())) + if (you_know && triggerer.ground_level()) simple_monster_message(m, " carefully avoids the shaft."); return; } @@ -471,8 +471,7 @@ void trap_def::trigger(actor& triggerer, bool flat_footed) return; } // Only magical traps affect flying critters. - if ((triggerer.airborne() || triggerer.is_wall_clinging()) - && this->category() != DNGN_TRAP_MAGICAL) + if (!triggerer.ground_level() && this->category() != DNGN_TRAP_MAGICAL) { if (you_know && m && triggerer.airborne()) simple_monster_message(m, " flies safely over a trap."); -- 2.11.4.GIT