From 72d9609baca7cbbd5a393e1da9707f1dfd42bdf5 Mon Sep 17 00:00:00 2001 From: zelgadis Date: Tue, 16 Oct 2007 07:08:28 +0000 Subject: Added new field seen_context to the monsters class, which can be set to cause a non-standard context to be passed to interrupt_activity( AI_SEE_MONSTER ) if it is called before the current turn is over. If a submerged monster surfaces in order to shout, it has to wait one turn before being able to submerge again. Added back in a scroll named "forgetfullness", but rather than giving amnesia about the map it gives amnesia about non-equipped inventory items. I tried to make the effects annoying rather than serious. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2481 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/view.cc | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) (limited to 'crawl-ref/source/view.cc') diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index d5994bd05b..cfbb4788df 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -771,6 +771,28 @@ inline static void beogh_follower_convert(monsters *monster) } } +static void handle_seen_interrupt(monsters* monster) +{ + activity_interrupt_data aid(monster); + if (monster->seen_context != "") + aid.context = monster->seen_context; + else if (testbits(monster->flags, MF_WAS_IN_VIEW)) + aid.context = "already seen"; + else + aid.context = "newly seen"; + + if (!mons_is_safe( static_cast(monster) ) + && !mons_class_flag( monster->type, M_NO_EXP_GAIN ) + && !mons_is_mimic( monster->type )) + { + interrupt_activity( AI_SEE_MONSTER, aid ); + } + seen_monster( monster ); + + // Monster was viewed this turn + monster->flags |= MF_WAS_IN_VIEW; +} + void handle_monster_shouts(monsters* monster, bool force) { if (!force @@ -941,7 +963,15 @@ void handle_monster_shouts(monsters* monster, bool force) // Monster must come up from being submerged if it wants to // shout. if (mons_is_submerged(monster)) + { monster->del_ench(ENCH_SUBMERGED); + if (you.can_see(monster)) + { + monster->seen_context = "bursts forth shouting"; + // Give interrupt message before shout message. + handle_seen_interrupt(monster); + } + } msg::streams(channel) << msg << std::endl; } @@ -1035,22 +1065,7 @@ void fire_monster_alerts() || mons_was_seen_this_turn(monster)) && !mons_is_submerged( monster )) { - activity_interrupt_data aid(monster); - if (testbits(monster->flags, MF_WAS_IN_VIEW)) - aid.context = "already seen"; - else - aid.context = "newly seen"; - - if (!mons_is_safe( static_cast(monster) ) - && !mons_class_flag( monster->type, M_NO_EXP_GAIN ) - && !mons_is_mimic( monster->type )) - { - interrupt_activity( AI_SEE_MONSTER, aid ); - } - seen_monster( monster ); - - // Monster was viewed this turn - monster->flags |= MF_WAS_IN_VIEW; + handle_seen_interrupt(monster); if (mons_attitude(monster) == ATT_HOSTILE) num_hostile++; @@ -1066,6 +1081,7 @@ void fire_monster_alerts() // Monster was not viewed this turn monster->flags &= ~MF_WAS_IN_VIEW; } + monster->seen_context = ""; } // Xom thinks it's hilarious the way the player picks up an ever -- cgit v1.2.3-54-g00ecf