summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/fight.cc
diff options
context:
space:
mode:
authorDavid Lawrence Ramsey <dolorous@users.sourceforge.net>2009-09-28 08:15:08 -0500
committerDavid Lawrence Ramsey <dolorous@users.sourceforge.net>2009-09-28 08:15:08 -0500
commitf1842e36777e4d3fe7990887409b8335b760cc97 (patch)
treeb2095cc19e9ef95bf7f9ca5dfdae702fe5ba20e1 /crawl-ref/source/fight.cc
parent56741fe543c9c407d9c9a8a6003bbd02092a525b (diff)
downloadcrawl-ref-f1842e36777e4d3fe7990887409b8335b760cc97.tar.gz
crawl-ref-f1842e36777e4d3fe7990887409b8335b760cc97.zip
Apply caotto's patch in [2868369], with a few cosmetic tweaks: Make
hydras attack adjacent hostiles if they kill their target and have attacks left over.
Diffstat (limited to 'crawl-ref/source/fight.cc')
-rw-r--r--crawl-ref/source/fight.cc50
1 files changed, 47 insertions, 3 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index bb134d5530..ae7b2b8ff8 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -411,7 +411,11 @@ void melee_attack::init_attack()
}
if (defender && defender->submerged())
+ {
+ // Unarmed attacks from tentacles are the only ones that can
+ // reach submerged monsters.
unarmed_ok = (attacker->damage_type() == DVORP_TENTACLE);
+ }
miscast_level = -1;
miscast_type = SPTYP_NONE;
@@ -4050,6 +4054,11 @@ bool melee_attack::mons_attack_mons()
mons_perform_attack();
+ // If a hydra was attacking it may have switched targets and started
+ // hitting the player. -cao
+ if (defender->atype() == ACT_PLAYER)
+ return (did_hit);
+
if (perceived_attack
&& (defender_as_monster()->foe == MHITNOT || one_chance_in(3))
&& attacker->alive() && defender->alive())
@@ -4959,7 +4968,42 @@ void melee_attack::mons_perform_attack_rounds()
{
// Monster went away?
if (!defender->alive() || defender->pos() != pos)
- break;
+ {
+ if (attacker == defender
+ || !attacker_as_monster()->has_hydra_multi_attack())
+ {
+ break;
+ }
+
+ // Hydras can try and pick up a new monster to attack to
+ // finish out their round. -cao
+ bool end = true;
+ for (adjacent_iterator i(attacker->pos()); i; ++i)
+ {
+ if (*i == you.pos() && !mons_friendly(attacker_as_monster()))
+ {
+ attacker_as_monster()->foe = MHITYOU;
+ attacker_as_monster()->target = you.pos();
+ defender = &you;
+ end = false;
+ break;
+ }
+
+ monsters *mons = monster_at(*i);
+ if (mons
+ && !mons_aligned(attacker_as_monster()->mindex(),
+ mons->mindex()))
+ {
+ defender = mons;
+ end = false;
+ break;
+ }
+ }
+
+ // No adjacent hostiles.
+ if (end)
+ break;
+ }
// Monsters hitting themselves get just one round.
if (attack_number > 0 && attacker == defender)
@@ -5114,7 +5158,7 @@ void melee_attack::mons_perform_attack_rounds()
chaos_affects_attacker();
do_miscast();
- break;
+ continue;
}
// Yredelemnul's injury mirroring can kill the attacker.
@@ -5153,7 +5197,7 @@ void melee_attack::mons_perform_attack_rounds()
chaos_affects_attacker();
do_miscast();
- break;
+ continue;
}
if (chaos_attack && attacker->alive())