From 20161f7b196c4e760f8ef9468a4a621018eafd05 Mon Sep 17 00:00:00 2001 From: zelgadis Date: Fri, 16 Nov 2007 08:18:15 +0000 Subject: M_AMPHIBIOUS now means both "land creature can swim through deep water" *and* "deep water creature can walk on land". Most of the supporting features neccessary for the "earth worm" FR [1766532] have been implemented, except for "fleeing towards walls". However, no work has yet been done to update the monster AI to work well when a monster is fighting an earth worm. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2858 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/fight.cc | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'crawl-ref/source/fight.cc') diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 50b5869f77..a77844f618 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -505,6 +505,50 @@ bool melee_attack::attack() xom_is_stimulated(128); } + // Defending monster protects itself from attacks using the + // wall it's in. + if (defender->atype() == ACT_MONSTER && grid_is_solid(def->pos()) + && mons_class_flag(def->type, M_WALL_SHIELDED)) + { + std::string feat_name = raw_feature_description(grd(def->pos())); + + if (attacker->atype() == ACT_PLAYER) + { + player_apply_attack_delay(); + + if (you.can_see(def)) + { + mprf("The %s protects %s from harm.", + feat_name.c_str(), + def->name(DESC_NOCAP_THE).c_str()); + } + else + { + mprf("You hit the %s.", + feat_name.c_str()); + } + } + else if (you.can_see(atk)) + { + // Make sure the monster uses up some energy, even though + // it didn't actually land a blow. + monsterentry *entry = get_monster_data(atk->type); + atk->speed_increment -= entry->energy_usage.attack; + + if (!mons_near(def)) + simple_monster_message(atk, " hits something"); + else if (!you.can_see(atk)) + mprf("%s hits the %s.", def->name(DESC_CAP_THE).c_str(), + feat_name.c_str()); + else + mprf("%s tries to hit the %s, but is blocked by the %s.", + atk->name(DESC_CAP_THE).c_str(), + def->name(DESC_NOCAP_THE).c_str(), + feat_name.c_str()); + } + return (true); + } + // Allow god to get offended, etc. attacker->attacking(defender); -- cgit v1.2.3-54-g00ecf