summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-16 07:08:28 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-16 07:08:28 +0000
commit72d9609baca7cbbd5a393e1da9707f1dfd42bdf5 (patch)
tree7bbd5635360a189592c81ec4bc414a14d60fd175
parent96f8635d8d1267198304f1aab7ef4275cf8e4852 (diff)
downloadcrawl-ref-72d9609baca7cbbd5a393e1da9707f1dfd42bdf5.tar.gz
crawl-ref-72d9609baca7cbbd5a393e1da9707f1dfd42bdf5.zip
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
-rw-r--r--crawl-ref/source/delay.cc2
-rw-r--r--crawl-ref/source/describe.cc4
-rw-r--r--crawl-ref/source/effects.cc53
-rw-r--r--crawl-ref/source/effects.h2
-rw-r--r--crawl-ref/source/externs.h3
-rw-r--r--crawl-ref/source/item_use.cc7
-rw-r--r--crawl-ref/source/itemname.cc1
-rw-r--r--crawl-ref/source/itemprop.h5
-rw-r--r--crawl-ref/source/makeitem.cc4
-rw-r--r--crawl-ref/source/mon-util.cc24
-rw-r--r--crawl-ref/source/monstuff.cc22
-rw-r--r--crawl-ref/source/shopping.cc1
-rw-r--r--crawl-ref/source/view.cc48
13 files changed, 129 insertions, 47 deletions
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index c9de8e7d4e..4506a1e7f9 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -1115,7 +1115,7 @@ inline static void monster_warning(activity_interrupt_type ai,
}
else if (at.context == "surfaces")
text += " surfaces.";
- else if (at.context == "bursts forth")
+ else if (at.context.find("bursts forth") != std::string::npos)
text += " bursts forth from the water.";
else
text += " comes into view.";
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 10b89729ea..03cc26546c 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -2405,6 +2405,10 @@ static std::string describe_scroll( const item_def &item )
"of one who reads it. ";
break;
+ case SCR_FORGETFULNESS:
+ description += "This annoying scrolls causes you to forget "
+ "about the items in your inventory.";
+
case SCR_ACQUIREMENT:
description += "This wonderful scroll causes the "
"creation of a valuable item to "
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 7fd88fac32..a4db2907b5 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -20,6 +20,7 @@
#include "externs.h"
#include "beam.h"
+#include "decks.h"
#include "direct.h"
#include "food.h"
#include "hiscores.h"
@@ -1820,3 +1821,55 @@ void yell(bool force)
noisy( 10, you.x_pos, you.y_pos );
mpr("Attack!");
} // end yell()
+
+bool forget_inventory(bool quiet)
+{
+ int items_forgotten = 0;
+
+ for (int i = 0; i < ENDOFPACK; i++)
+ {
+ item_def& item(you.inv[i]);
+ if (!is_valid_item(item) || item_is_equipped(item))
+ continue;
+
+ unsigned long orig_flags = item.flags;
+
+ unset_ident_flags(item, ISFLAG_KNOW_CURSE);
+
+ // Don't forget times used or uses left for wands or decks.
+ if (item.base_type != OBJ_WANDS && item.base_type != OBJ_MISCELLANY)
+ unset_ident_flags(item, ISFLAG_KNOW_PLUSES);
+
+ if (!is_artefact(item))
+ {
+ switch (item.base_type)
+ {
+ case OBJ_WEAPONS:
+ case OBJ_ARMOUR:
+ case OBJ_BOOKS:
+ case OBJ_STAVES:
+ case OBJ_MISCELLANY:
+ // Don't forget identity of decks if it the player has
+ // used any of its cards, or knows how many are left.
+ if (!is_deck(item) || item.plus2 == 0)
+ unset_ident_flags(item, ISFLAG_KNOW_TYPE);
+ break;
+
+ default:
+ break;
+ }
+ }
+ // Non-jewellery artifacts can easily be re-identified by
+ // equipping them.
+ else if (item.base_type != OBJ_JEWELLERY)
+ unset_ident_flags(item, ISFLAG_KNOW_TYPE | ISFLAG_KNOW_PROPERTIES);
+
+ if (item.flags != orig_flags)
+ items_forgotten++;
+ }
+
+ if (items_forgotten > 0)
+ mpr("Wait, did you forget something?");
+
+ return (items_forgotten > 0);
+}
diff --git a/crawl-ref/source/effects.h b/crawl-ref/source/effects.h
index de4c71841a..1472fb4b56 100644
--- a/crawl-ref/source/effects.h
+++ b/crawl-ref/source/effects.h
@@ -104,4 +104,6 @@ void torment( int caster, int tx, int ty );
int torment_monsters(int x, int y, int pow, int caster);
+bool forget_inventory(bool quiet = false);
+
#endif
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index e5d72f412e..ec7ea1cd49 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -964,6 +964,9 @@ public:
std::auto_ptr<ghost_demon> ghost; // Ghost information.
+ std::string seen_context; // Non-standard context for
+ // AI_SEE_MONSTER
+
public:
bool has_action_energy() const;
void check_redraw(const coord_def &oldpos) const;
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 8de97f4e69..6cd7ba299a 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -3714,6 +3714,13 @@ void read_scroll(void)
}
break;
+ case SCR_FORGETFULNESS:
+ if (wearing_amulet(AMU_CLARITY))
+ mpr("You feel forgetfull for a moment.");
+ else
+ id_the_scroll = forget_inventory();
+ break;
+
case SCR_MAGIC_MAPPING:
if (you.level_type == LEVEL_PANDEMONIUM)
{
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index 5b8792a5d3..aa55ee08f3 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -532,6 +532,7 @@ static const char* scroll_type_name(int scrolltype)
case SCR_BLINKING: return "blinking";
case SCR_PAPER: return "paper";
case SCR_MAGIC_MAPPING: return "magic mapping";
+ case SCR_FORGETFULNESS: return "forgetfullness";
case SCR_ACQUIREMENT: return "acquirement";
case SCR_ENCHANT_WEAPON_II: return "enchant weapon II";
case SCR_VORPALISE_WEAPON: return "vorpalise weapon";
diff --git a/crawl-ref/source/itemprop.h b/crawl-ref/source/itemprop.h
index 8e49e6c198..c9e037dc14 100644
--- a/crawl-ref/source/itemprop.h
+++ b/crawl-ref/source/itemprop.h
@@ -310,10 +310,11 @@ enum scroll_type
SCR_BLINKING,
SCR_PAPER, // 15
SCR_MAGIC_MAPPING,
+ SCR_FORGETFULNESS,
SCR_ACQUIREMENT,
SCR_ENCHANT_WEAPON_II,
- SCR_VORPALISE_WEAPON,
- SCR_RECHARGING, // 20
+ SCR_VORPALISE_WEAPON, // 20
+ SCR_RECHARGING,
SCR_ENCHANT_WEAPON_III,
NUM_SCROLLS
};
diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc
index 7688ca5872..076da6c5da 100644
--- a/crawl-ref/source/makeitem.cc
+++ b/crawl-ref/source/makeitem.cc
@@ -2530,8 +2530,8 @@ int items( int allow_uniques, // not just true-false,
(temp_rand > 464) ? SCR_FEAR : // 3.26%
(temp_rand > 434) ? SCR_NOISE : // 3.26%
(temp_rand > 404) ? SCR_MAGIC_MAPPING : // 3.26%
- //(temp_rand > 374) ? SCR_FORGETFULNESS : // 3.26%
- (temp_rand > 344) ? SCR_RANDOM_USELESSNESS :// 6.52%
+ (temp_rand > 374) ? SCR_FORGETFULNESS : // 3.26%
+ (temp_rand > 344) ? SCR_RANDOM_USELESSNESS :// 3.26%
(temp_rand > 314) ? SCR_CURSE_WEAPON : // 3.26%
(temp_rand > 284) ? SCR_CURSE_ARMOUR : // 3.26%
(temp_rand > 254) ? SCR_RECHARGING : // 3.26%
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 0be5705717..0151ab8095 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -2316,7 +2316,7 @@ monsters::monsters()
target_x(0), target_y(0), inv(), spells(), attitude(ATT_HOSTILE),
behaviour(BEH_WANDER), foe(MHITYOU), enchantments(), flags(0L),
number(0), colour(BLACK), foe_memory(0), god(GOD_NO_GOD),
- ghost()
+ ghost(), seen_context("")
{
}
@@ -4092,31 +4092,21 @@ void monsters::remove_enchantment_effect(const mon_enchant &me, bool quiet)
if (!mons_is_safe( static_cast<const monsters*>(this))
&& is_run_delay(current_delay_action()))
{
- activity_interrupt_data aid(this);
+ // Already set somewhere else.
+ if (seen_context != "")
+ return;
if (type == MONS_AIR_ELEMENTAL)
- aid.context = "thin air";
+ seen_context = "thin air";
else if (monster_habitable_grid(this, DNGN_FLOOR))
- aid.context = "bursts forth";
+ seen_context = "bursts forth";
else
- aid.context = "surfaces";
-
- interrupt_activity( AI_SEE_MONSTER, aid );
+ seen_context = "surfaces";
}
else if (!quiet)
- {
if (type == MONS_AIR_ELEMENTAL)
mprf("%s forms itself from the air!",
name(DESC_CAP_A, true).c_str() );
- else if (monster_habitable_grid(this, DNGN_FLOOR))
- mprf("%s bursts forth from the water!",
- name(DESC_CAP_A, true).c_str() );
- }
-
- seen_monster( this );
-
- // Monster was viewed this turn
- flags |= MF_WAS_IN_VIEW;
}
else if (mons_near(this) && monster_habitable_grid(this, DNGN_FLOOR))
{
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 5b67a0ed35..38225e2510 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -2304,16 +2304,20 @@ static void handle_nearby_ability(monsters *monster)
case MONS_SWAMP_WORM:
if (monster_can_submerge(monster->type, grd[monster->x][monster->y])
&& ( !player_beheld_by(monster) // no submerging if player entranced
- && (one_chance_in(5) || (grid_distance( monster->x, monster->y,
+ && (one_chance_in(5)
+ || ((grid_distance( monster->x, monster->y,
you.x_pos, you.y_pos ) > 1
- // FIXME This is better expressed as a
- // function such as
- // monster_has_ranged_attack:
- && monster->type != MONS_ELECTRICAL_EEL
- && monster->type != MONS_LAVA_SNAKE
- && (monster->type != MONS_MERMAID
- || you.species == SP_MERFOLK)
- && !one_chance_in(20)) )
+ // FIXME This is better expressed as a
+ // function such as
+ // monster_has_ranged_attack:
+ && monster->type != MONS_ELECTRICAL_EEL
+ && monster->type != MONS_LAVA_SNAKE
+ && (monster->type != MONS_MERMAID
+ || you.species == SP_MERFOLK)
+ // Don't submerge if we just unsubmerged for
+ // the sake of shouting.
+ && monster->seen_context != "bursts forth shouting"
+ && !one_chance_in(20)) ))
|| monster->hit_points <= monster->max_hit_points / 2)
|| env.cgrid[monster->x][monster->y] != EMPTY_CLOUD)
{
diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc
index 5397844e43..a0d6a8192a 100644
--- a/crawl-ref/source/shopping.cc
+++ b/crawl-ref/source/shopping.cc
@@ -1262,6 +1262,7 @@ unsigned int item_value( item_def item, bool ident )
case SCR_CURSE_WEAPON:
case SCR_PAPER:
case SCR_IMMOLATION:
+ case SCR_FORGETFULNESS:
valued++;
break;
}
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<const monsters*>(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<const monsters*>(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