summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-02 20:27:50 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-02 20:27:50 +0000
commit17125f250661e8430e320f4c05d74094235f0cf3 (patch)
tree9f681260f2fed49c56911637fd13a800a5e993e0 /crawl-ref
parent5a1d2984131beed046555602cee60045ac665212 (diff)
downloadcrawl-ref-17125f250661e8430e320f4c05d74094235f0cf3.tar.gz
crawl-ref-17125f250661e8430e320f4c05d74094235f0cf3.zip
Fixed 2481704: Travel stopping for spellcasting monsters without LOS
spells behind glass. Fixed 2174517: V giving information about unknown items in stashes. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8128 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/command.cc5
-rw-r--r--crawl-ref/source/decks.cc3
-rw-r--r--crawl-ref/source/directn.cc35
-rw-r--r--crawl-ref/source/items.cc3
-rw-r--r--crawl-ref/source/misc.cc3
-rw-r--r--crawl-ref/source/mon-util.cc59
-rw-r--r--crawl-ref/source/mon-util.h1
-rw-r--r--crawl-ref/source/stash.cc30
-rw-r--r--crawl-ref/source/stash.h10
9 files changed, 102 insertions, 47 deletions
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc
index 7751761b85..2c61f637c6 100644
--- a/crawl-ref/source/command.cc
+++ b/crawl-ref/source/command.cc
@@ -1390,7 +1390,6 @@ static bool _handle_FAQ()
return (false);
}
Menu FAQmenu(MF_SINGLESELECT | MF_ANYPRINTABLE | MF_ALLOW_FORMATTING);
-// FAQmenu.set_more(formatted_string::parse_string("Choose a question!"));
MenuEntry *title = new MenuEntry("Frequently Asked Questions");
title->colour = YELLOW;
FAQmenu.set_title(title);
@@ -1438,8 +1437,8 @@ static bool _handle_FAQ()
std::string answer = getFAQ_Answer(key);
if (answer.empty())
{
- mpr("No answer found in the FAQ! Please submit a bug report!");
- return (false);
+ answer = "No answer found in the FAQ! Please submit a "
+ "bug report!";
}
answer = "Q: " + getFAQ_Question(key) + EOL + "A: " + answer;
linebreak_string2(answer, width - 1);
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index f30c907098..080c029e77 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -3037,7 +3037,8 @@ bool card_effect(card_type which_card, deck_rarity_type rarity,
set_hunger(12000, true);
break;
- default:
+ case NUM_CARDS:
+ // The compiler will complain if any card remains unhandled.
mpr("You have drawn a buggy card!");
break;
}
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index a497db3916..53d4a25c4e 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -456,13 +456,10 @@ void full_describe_view()
const coord_def end = start + crawl_view.viewsz - coord_def(1,1);
std::vector<const monsters*> list_mons;
- std::vector<const item_def*> list_items;
+ std::vector<item_def> list_items;
- // Iterate over viewport and get all the items in view.
- // FIXME: This includes unknown stashes. I guess for stashes never
- // seen before I could simply only add the top item (though I don't
- // know how to do that) but what about stashes that changed since
- // you last saw them? Just list the old content?
+ // Iterate over viewport and grab all items known (or thought)
+ // to be in the stashes in view.
for (rectangle_iterator ri(start, end); ri; ++ri)
{
if (!in_bounds(*ri) || !see_grid(*ri))
@@ -470,12 +467,14 @@ void full_describe_view()
const int oid = igrd(*ri);
- if (oid != NON_ITEM)
- {
- std::vector<const item_def*> items;
- item_list_on_square( items, oid, true );
- list_items.insert(list_items.end(), items.begin(), items.end());
- }
+ if (oid == NON_ITEM)
+ continue;
+
+ std::vector<item_def> items = item_list_in_stash(*ri);
+ if (items.empty())
+ continue;
+
+ list_items.insert(list_items.end(), items.begin(), items.end());
}
// Get monsters via the monster_pane_info, sorted by difficulty.
@@ -533,9 +532,6 @@ void full_describe_view()
mon_dam_level_type dam_level;
mons_get_damage_level(list_mons[i], wound_str, dam_level);
- // Get monster description.
- // TODO: Show monsters being friendly or neutral, if not by
- // colour, then by description.
std::vector<formatted_string> fss;
std::string str = get_monster_desc(list_mons[i], true, DESC_CAP_A,
true);
@@ -579,10 +575,9 @@ void full_describe_view()
const char letter = index_to_letter(menu_index);
unsigned glyph_char;
- // TODO: check if this can be used instead of
- // manually doing so with item_specialness --yy
unsigned short glyph_col;
- get_item_glyph( list_items[i], &glyph_char, &glyph_col );
+ const item_def &item = list_items[i];
+ get_item_glyph( &item, &glyph_char, &glyph_col );
const std::string col_string = colour_to_str(glyph_col);
const std::string prefix = "(<" + col_string + ">"
@@ -590,11 +585,11 @@ void full_describe_view()
+ "</" + col_string + ">) ";
const std::string str = prefix +
- uppercase_first(list_items[i]->name(DESC_PLAIN));
+ uppercase_first(item.name(DESC_PLAIN));
MenuEntry *me = new MenuEntry(str, MEL_ITEM, 1, letter);
me->data = reinterpret_cast<void*>(
- const_cast<item_def*>(list_items[i]));
+ const_cast<item_def*>(&item));
me->tag = "i";
me->quantity = 2; // Hack to make items selectable.
desc_menu.add_entry(me);
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index 49c376408e..ac15394084 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -1765,6 +1765,9 @@ bool move_item_to_grid( int *const obj, const coord_def& p )
set_branch_flags(BFLAG_HAS_ORB);
}
+// if (see_grid(p))
+// StashTrack.update_stash(p);
+
return (true);
}
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index 57ec82946c..303fef5864 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -2649,8 +2649,7 @@ bool mons_is_safe(const monsters *mon, bool want_move,
// Only seen through glass walls?
|| !see_grid_no_trans(mon->pos())
&& !_mons_has_path_to_player(mon)
- && !mons_has_ranged_spell(mon)
- && !mons_has_los_ability(mon->type));
+ && !mons_has_los_attack(mon));
#ifdef CLUA_BINDINGS
if (consider_user_options)
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 9cbdf68bb1..871395b42f 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -2956,8 +2956,32 @@ bool ms_waste_of_time( const monsters *mon, spell_type monspell )
return (ret);
}
+static bool _ms_los_spell( spell_type monspell )
+{
+ switch (monspell)
+ {
+ case SPELL_SUMMON_DEMON:
+ case SPELL_SUMMON_GREATER_DEMON:
+ case SPELL_SUMMON_UNDEAD:
+ case SPELL_SUMMON_UFETUBUS:
+ case SPELL_SUMMON_HORRIBLE_THINGS:
+ case SPELL_SUMMON_DRAKES:
+ case SPELL_SUMMON_MUSHROOMS:
+ case SPELL_SUMMON_ICE_BEAST:
+ return (true);
+
+ default:
+ return (false);
+ }
+}
+
+
static bool _ms_ranged_spell( spell_type monspell, bool attack_only )
{
+ // These spells are ranged, but aren't direct attack spells.
+ if (!attack_only && _ms_los_spell(monspell))
+ return (true);
+
switch (monspell)
{
case SPELL_NO_SPELL:
@@ -2969,24 +2993,15 @@ static bool _ms_ranged_spell( spell_type monspell, bool attack_only )
case SPELL_BLINK:
return (false);
- // These spells are ranged, but aren't direct attack spells.
+ // The animation spells don't work through transparent walls and thus
+ // are listed here instead of above.
case SPELL_ANIMATE_DEAD:
case SPELL_ANIMATE_SKELETON:
- case SPELL_SUMMON_DEMON:
- case SPELL_SUMMON_GREATER_DEMON:
- case SPELL_SUMMON_UNDEAD:
- case SPELL_SUMMON_UFETUBUS:
- case SPELL_SUMMON_HORRIBLE_THINGS:
- case SPELL_SUMMON_DRAKES:
- case SPELL_SUMMON_MUSHROOMS:
- case SPELL_SUMMON_ICE_BEAST:
return (!attack_only);
default:
- break;
+ return (true);
}
-
- return (true);
}
bool mons_is_magic_user( const monsters *mon )
@@ -3023,6 +3038,24 @@ bool mons_has_los_ability( int mclass )
return (false);
}
+bool mons_has_los_attack(const monsters *mon)
+{
+ const int mclass = mon->type;
+
+ // Monsters may have spell like abilities.
+ if (mons_has_los_ability(mclass))
+ return (true);
+
+ if (mons_class_flag( mclass, M_SPELLCASTER ))
+ {
+ for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; i++)
+ if (_ms_los_spell( mon->spells[i] ))
+ return (true);
+ }
+
+ return (false);
+}
+
bool mons_has_ranged_spell( const monsters *mon, bool attack_only )
{
const int mclass = mon->type;
@@ -3360,7 +3393,7 @@ bool monsters::wants_submerge() const
return (true);
}
- // Trapdoor spiders only hide themsleves under the floor when they
+ // Trapdoor spiders only hide themselves under the floor when they
// can't see their prey.
if (type == MONS_TRAPDOOR_SPIDER)
{
diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h
index abd25adf7f..b69d594470 100644
--- a/crawl-ref/source/mon-util.h
+++ b/crawl-ref/source/mon-util.h
@@ -714,6 +714,7 @@ bool ms_low_hitpoint_cast( const monsters *mon, spell_type monspell );
bool mons_is_magic_user( const monsters *mon );
bool mons_has_los_ability( int mclass );
+bool mons_has_los_attack(const monsters *mon);
bool mons_has_ranged_spell( const monsters *mon, bool attack_only = false );
bool mons_has_ranged_attack( const monsters *mon );
diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc
index 039286565f..c10737d345 100644
--- a/crawl-ref/source/stash.cc
+++ b/crawl-ref/source/stash.cc
@@ -125,6 +125,26 @@ void describe_stash(int x, int y)
}
}
+
+std::vector<item_def> Stash::get_items() const
+{
+ return items;
+}
+
+std::vector<item_def> item_list_in_stash( coord_def pos )
+{
+ std::vector<item_def> ret;
+
+ LevelStashes *ls = StashTrack.find_current_level();
+ if (ls)
+ {
+ Stash *s = ls->find_stash(pos.x, pos.y);
+ ret = s->get_items();
+ }
+
+ return ret;
+}
+
static void _fully_identify_item(item_def *item)
{
if (!item || !is_valid_item(*item))
@@ -372,7 +392,8 @@ void Stash::update()
// If this is unverified, forget last item on stack. This isn't
// terribly clever, but it prevents the vector swelling forever.
- if (!verified) items.pop_back();
+ if (!verified)
+ items.pop_back();
// Items are different. We'll put this item in the front of our
// vector, and mark this as unverified
@@ -1450,7 +1471,7 @@ void StashTracker::update_visible_stashes(
StashTracker::stash_update_mode mode)
{
if (is_level_untrackable())
- return ;
+ return;
LevelStashes *lev = find_current_level();
for (int cy = crawl_view.glos1.y; cy <= crawl_view.glos2.y; ++cy)
@@ -1823,11 +1844,10 @@ bool StashTracker::display_search_results(
sel = stashmenu.show();
if (stashmenu.request_toggle_sort_method)
- {
return (true);
- }
- if (sel.size() == 1 && stashmenu.menu_action == StashSearchMenu::ACT_EXAMINE)
+ if (sel.size() == 1
+ && stashmenu.menu_action == StashSearchMenu::ACT_EXAMINE)
{
stash_search_result *res =
static_cast<stash_search_result *>(sel[0]->data);
diff --git a/crawl-ref/source/stash.h b/crawl-ref/source/stash.h
index 0c72c07532..4b3811ec05 100644
--- a/crawl-ref/source/stash.h
+++ b/crawl-ref/source/stash.h
@@ -53,6 +53,7 @@ public:
std::string description() const;
std::string feature_description() const;
+ std::vector<item_def> get_items() const;
bool show_menu(const std::string &place, bool can_travel) const;
@@ -100,7 +101,7 @@ private:
dungeon_feature_type feat;
trap_type trap;
- std::vector<item_def> items;
+ std::vector<item_def> items;
/*
* If true (the default), the stash-tracker is a lot more likely to consider
@@ -227,11 +228,13 @@ public:
// Returns true if the square at (x,y) contains potentially interesting
// swag that merits a personal visit (for EXPLORE_GREEDY).
bool needs_visit(int x, int y) const;
- bool needs_visit(const coord_def& c) const {
+ bool needs_visit(const coord_def& c) const
+ {
return needs_visit(c.x, c.y);
}
bool shop_needs_visit(int x, int y) const;
- bool shop_needs_visit(const coord_def& c) const {
+ bool shop_needs_visit(const coord_def& c) const
+ {
return shop_needs_visit(c.x, c.y);
}
@@ -357,6 +360,7 @@ extern StashTracker StashTrack;
bool is_stash(int x, int y);
inline bool is_stash( const coord_def& p ) { return is_stash(p.x, p.y); }
void describe_stash(int x, int y);
+std::vector<item_def> item_list_in_stash( coord_def pos );
std::string userdef_annotate_item(const char *s, const item_def *item,
bool exclusive = false);