summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/fight.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-01-09 11:26:53 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-01-09 11:26:53 +0000
commit9415865e90bd96e8241e119291275eef655235dc (patch)
tree25f8ffa0e900150be3dc9c9918e9caff7e11dd9b /crawl-ref/source/fight.cc
parentde47f74ee9a63c58d1c6f512f17d49122333cf1b (diff)
downloadcrawl-ref-9415865e90bd96e8241e119291275eef655235dc.tar.gz
crawl-ref-9415865e90bd96e8241e119291275eef655235dc.zip
[1631021] Interrupt delays only if the player knows he was attacked.
Under the old system, the delay was interrupted when the monster got an attack round against the player; if the monster is invisible and misses, the player received no message, but delays were interrupted. Under the new system, the delay is interrupted only if the player perceives the attempted attack (if the player shield-blocks, or the attacker is visible, or the player actually takes a hit). Also fixed the old behaviour where you would not be aware of an unseen horror if it hits but does no damage. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@816 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/fight.cc')
-rw-r--r--crawl-ref/source/fight.cc34
1 files changed, 22 insertions, 12 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 717a14fb7c..9b609f8d95 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -2031,10 +2031,6 @@ void monster_attack(int monster_attacking)
if (mons_friendly(attacker))
return;
- // This should happen after the mons_friendly check so we're
- // only disturbed by hostiles. -- bwr
- interrupt_activity( AI_MONSTER_ATTACKS, attacker );
-
if (attacker->type == MONS_GIANT_SPORE
|| attacker->type == MONS_BALL_LIGHTNING)
{
@@ -2053,8 +2049,10 @@ void monster_attack(int monster_attacking)
&& mons_holiness( attacker ) == MH_UNDEAD
&& !check_mons_resist_magic( attacker, you.piety ))
{
- simple_monster_message(attacker,
- " tries to attack you, but is repelled by your holy aura.");
+ if (simple_monster_message(
+ attacker,
+ " tries to attack you, but is repelled by your holy aura."))
+ interrupt_activity( AI_MONSTER_ATTACKS, attacker );
return;
}
@@ -2067,8 +2065,10 @@ void monster_attack(int monster_attacking)
// should be scaled {dlb}
if (coinflip())
{
- simple_monster_message(attacker,
- " tries to attack you, but flinches away.");
+ if (simple_monster_message(
+ attacker,
+ " tries to attack you, but flinches away."))
+ interrupt_activity( AI_MONSTER_ATTACKS, attacker );
return;
}
}
@@ -2080,7 +2080,8 @@ void monster_attack(int monster_attacking)
&& monster_habitat( attacker->type ) == DNGN_FLOOR
&& one_chance_in(4))
{
- simple_monster_message(attacker, " splashes around in the water.");
+ if (simple_monster_message(attacker, " splashes around in the water."))
+ interrupt_activity( AI_MONSTER_ATTACKS, attacker );
return;
}
@@ -2094,6 +2095,7 @@ void monster_attack(int monster_attacking)
}
char runthru;
+ bool player_perceives_attack = false;
for (runthru = 0; runthru < 4; runthru++)
{
@@ -2188,6 +2190,7 @@ void monster_attack(int monster_attacking)
blocked = true;
hit = false;
+ player_perceives_attack = true;
if (bearing_shield && one_chance_in(4))
exercise(SK_SHIELDS, 1);
@@ -2281,13 +2284,17 @@ void monster_attack(int monster_attacking)
else if (!blocked)
{
hit = false;
- simple_monster_message(attacker, " misses you.");
+ if (simple_monster_message(attacker, " misses you."))
+ player_perceives_attack = true;
}
+ if ((hit && !blocked) || damage_taken > 0)
+ player_perceives_attack = true;
+
if (damage_taken < 1 && hit && !blocked)
{
- simple_monster_message(attacker,
- " hits you but doesn't do any damage.");
+ mprf("%s hits you but doesn't do any damage.",
+ ptr_monam(attacker, DESC_CAP_THE));
}
if (damage_taken > 0)
@@ -3067,6 +3074,9 @@ commented out for now
}
} // end of for runthru
+ if (player_perceives_attack)
+ interrupt_activity(AI_MONSTER_ATTACKS, attacker);
+
return;
} // end monster_attack()