summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-19 06:20:51 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-19 06:20:51 +0000
commit33005dad6d50d774bc4fe6b6afcd5b60c55cd0b6 (patch)
treec2f5fa8878e1237ff9d9f0bfcdb71ed7f72e0cc0 /crawl-ref
parent8f82bd1f8aca60f4d15e3966933dc10cbe019574 (diff)
downloadcrawl-ref-33005dad6d50d774bc4fe6b6afcd5b60c55cd0b6.tar.gz
crawl-ref-33005dad6d50d774bc4fe6b6afcd5b60c55cd0b6.zip
Simplify the code that issues the "comes into view" monster interrupt message,
so we don't have to check in multiple places to make sure that "comes into view" is given before any of the other monster messages. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8572 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/acr.cc2
-rw-r--r--crawl-ref/source/monspeak.cc5
-rw-r--r--crawl-ref/source/monstuff.cc21
-rw-r--r--crawl-ref/source/mstuff2.cc8
-rw-r--r--crawl-ref/source/view.cc71
-rw-r--r--crawl-ref/source/view.h2
6 files changed, 31 insertions, 78 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index f56c16776d..fb8d836261 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -1521,7 +1521,7 @@ static void _input()
you.turn_is_over = false;
_prep_input();
- fire_monster_alerts();
+ update_monsters_in_view();
const bool player_feels_safe = i_feel_safe();
diff --git a/crawl-ref/source/monspeak.cc b/crawl-ref/source/monspeak.cc
index 6bdbfec5e6..b147cf3fa5 100644
--- a/crawl-ref/source/monspeak.cc
+++ b/crawl-ref/source/monspeak.cc
@@ -737,11 +737,6 @@ void mons_speaks_msg(const monsters *monster, const std::string &msg,
if (!mons_near(monster))
return;
- // Make sure the "comes into view" type messages are displayed before
- // the monster speaks.
- if (player_monster_visible(monster) && !(monster->flags & MF_WAS_IN_VIEW))
- fire_monster_alerts();
-
// We have a speech string, now parse and act on it.
std::string _msg = do_mon_str_replacements(msg, monster);
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 2529eca193..8f0f2d793d 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -4885,17 +4885,6 @@ bool mons_avoids_cloud(const monsters *monster, int cloud_num,
careful_friendly));
}
-// Make sure the "comes into view" type messages are displayed before
-// special/nearby abilites are used.
-void _flush_monster_alerts(const monsters* mons)
-{
- if (!(mons->flags & MF_WAS_IN_VIEW) && player_monster_visible(mons)
- && you_are_delayed())
- {
- fire_monster_alerts();
- }
-}
-
//---------------------------------------------------------------
//
// handle_nearby_ability
@@ -4977,12 +4966,9 @@ static void _handle_nearby_ability(monsters *monster)
&& !_is_player_or_mon_sanct(monster))
{
if (you.can_see(monster) && you.can_see(foe))
- {
- _flush_monster_alerts(monster);
mprf("%s stares at %s.",
monster->name(DESC_CAP_THE).c_str(),
foe->name(DESC_NOCAP_THE).c_str());
- }
// Subtly different from old paralysis behaviour, but
// it'll do.
@@ -4998,7 +4984,6 @@ static void _handle_nearby_ability(monsters *monster)
&& !mons_is_pacified(monster)
&& !_is_player_or_mon_sanct(monster))
{
- _flush_monster_alerts(monster);
simple_monster_message(monster, " stares at you.");
dec_mp(5 + random2avg(13, 3));
@@ -5121,8 +5106,6 @@ static bool _handle_special_ability(monsters *monster, bolt & beem)
return (false);
}
- _flush_monster_alerts(monster);
-
const msg_channel_type spl = (mons_friendly(monster) ? MSGCH_FRIEND_SPELL
: MSGCH_MONSTER_SPELL);
@@ -8723,6 +8706,10 @@ void seen_monster(monsters *monster)
if (need_auto_exclude(monster) && !is_exclude_root(monster->pos()))
toggle_exclude(monster->pos());
+ // Monster was viewed this turn
+ monster->flags |= MF_WAS_IN_VIEW;
+ monster->seen_context.clear();
+
if (monster->flags & MF_SEEN)
return;
diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc
index 39adaea987..8182c91008 100644
--- a/crawl-ref/source/mstuff2.cc
+++ b/crawl-ref/source/mstuff2.cc
@@ -135,14 +135,6 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast,
// single calculation permissible {dlb}
bool monsterNearby = mons_near(monster);
- // Make sure the "comes into view" type messages are displayed before
- // the spell is cast.
- if (monsterNearby && player_monster_visible(monster)
- && !(monster->flags & MF_WAS_IN_VIEW))
- {
- fire_monster_alerts();
- }
-
int sumcount = 0;
int sumcount2;
int duration = 0;
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index d92f1632c6..b01456286b 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -872,14 +872,6 @@ int get_mons_colour(const monsters *mons)
return (col);
}
-static std::set<const monsters*> monsters_seen_this_turn;
-
-static bool _mons_was_seen_this_turn(const monsters *mons)
-{
- return (monsters_seen_this_turn.find(mons) !=
- monsters_seen_this_turn.end());
-}
-
static void _good_god_follower_attitude_change(monsters *monster)
{
if (player_is_unholy())
@@ -958,6 +950,12 @@ void beogh_follower_convert(monsters *monster, bool orc_hit)
static void _handle_seen_interrupt(monsters* monster)
{
+ if (mons_is_mimic(monster->type)
+ && !mons_is_known_mimic(monster))
+ {
+ return;
+ }
+
activity_interrupt_data aid(monster);
if (!monster->seen_context.empty())
aid.context = monster->seen_context;
@@ -967,15 +965,12 @@ static void _handle_seen_interrupt(monsters* monster)
aid.context = "newly seen";
if (!mons_is_safe(monster)
- && !mons_class_flag( monster->type, M_NO_EXP_GAIN )
- && !mons_is_mimic( monster->type ))
+ && !mons_class_flag(monster->type, M_NO_EXP_GAIN))
{
interrupt_activity( AI_SEE_MONSTER, aid );
+ monster->seen_context.clear();
}
seen_monster( monster );
-
- // Monster was viewed this turn
- monster->flags |= MF_WAS_IN_VIEW;
}
void handle_monster_shouts(monsters* monster, bool force)
@@ -1083,7 +1078,7 @@ void handle_monster_shouts(monsters* monster, bool force)
// and if no such entry exists then looks simply for "name".
if (you.can_see(monster))
suffix = " seen";
- else
+ else
suffix = " unseen";
msg = getShoutString(key, suffix);
@@ -1226,13 +1221,14 @@ void monster_grid(bool do_updates)
if (monster->alive() && mons_near(monster))
{
+ if (mons_player_visible(monster))
+ _handle_seen_interrupt(monster);
+
if (do_updates && (mons_is_sleeping(monster)
|| mons_is_wandering(monster))
&& check_awaken(monster))
{
behaviour_event(monster, ME_ALERT, MHITYOU);
- if (you.can_see(monster))
- _handle_seen_interrupt(monster);
handle_monster_shouts(monster);
}
@@ -1261,22 +1257,13 @@ void monster_grid(bool do_updates)
tile_place_monster(monster->pos().x, monster->pos().y, s, true);
#endif
- if (player_monster_visible(monster)
- && !mons_is_submerged(monster)
- && !mons_friendly(monster)
- && !mons_class_flag(monster->type, M_NO_EXP_GAIN)
- && !mons_is_mimic(monster->type))
- {
- monsters_seen_this_turn.insert(monster);
- }
-
_good_god_follower_attitude_change(monster);
beogh_follower_convert(monster);
}
}
}
-void fire_monster_alerts()
+void update_monsters_in_view()
{
unsigned int num_hostile = 0;
@@ -1284,29 +1271,23 @@ void fire_monster_alerts()
{
monsters *monster = &menv[s];
- if (monster->alive() && mons_near(monster))
+ if (!monster->alive())
+ continue;
+
+ monster->flags &= ~MF_WAS_IN_VIEW;
+
+ if (mons_near(monster))
{
- if ((player_monster_visible(monster)
- || _mons_was_seen_this_turn(monster))
- && !mons_is_submerged( monster ))
- {
- _handle_seen_interrupt(monster);
+ if (monster->attitude == ATT_HOSTILE)
+ num_hostile++;
- if (monster->attitude == ATT_HOSTILE)
- num_hostile++;
- }
- else
+ if (player_monster_visible(monster)
+ && (!mons_is_mimic(monster->type)
+ || mons_is_known_mimic(monster)))
{
- // Monster was not viewed this turn
- monster->flags &= ~MF_WAS_IN_VIEW;
+ seen_monster(monster);
}
}
- else
- {
- // Monster was not viewed this turn
- monster->flags &= ~MF_WAS_IN_VIEW;
- }
- monster->seen_context.clear();
}
// Xom thinks it's hilarious the way the player picks up an ever
@@ -1323,8 +1304,6 @@ void fire_monster_alerts()
xom_is_stimulated(16 * num_hostile);
}
-
- monsters_seen_this_turn.clear();
}
bool check_awaken(monsters* monster)
diff --git a/crawl-ref/source/view.h b/crawl-ref/source/view.h
index 1337f2f54f..49ebf4693b 100644
--- a/crawl-ref/source/view.h
+++ b/crawl-ref/source/view.h
@@ -251,7 +251,7 @@ void flash_monster_colour(const monsters *mon, unsigned char fmc_colour,
int fmc_delay);
#endif
void viewwindow(bool draw_it, bool do_updates);
-void fire_monster_alerts();
+void update_monsters_in_view();
struct ray_def;
bool find_ray( const coord_def& source, const coord_def& target,